mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 11:54:33 +03:00
4c5ba4ed7d
closes https://github.com/TryGhost/Team/issues/1916 closes https://github.com/TryGhost/Team/issues/1917 - Added database storage for link redirects and click events via repositories (hides away database layer) defined in the wrapper services - Added LinkClickRepository to store click events to database - Added LinkRedirectRepository to store link redirects to database - Added PostLinkRepository to link LinkRedirects with posts - Renamed link-replacement package to link-replacer, and made it dependency less (it only replaces links now, doesn't do anything else) - The link-tracking service has a new `addTrackingToUrl` which returns a new URL that includes tracking. The new `addRedirectToUrl` method does the same but without tracking for now. - MEGA service now uses the link-replacer to replace links in the emails using a combination of different services (member attribution + link-tracking service)
30 lines
777 B
JavaScript
30 lines
777 B
JavaScript
const ObjectID = require('bson-objectid').default;
|
|
|
|
/**
|
|
* Stores the connection between a LinkRedirect and a Post
|
|
*/
|
|
module.exports = class PostLink {
|
|
/** @type {ObjectID} */
|
|
post_id;
|
|
/** @type {ObjectID} */
|
|
link_id;
|
|
|
|
/**
|
|
* @param {object} data
|
|
* @param {string|ObjectID} data.post_id
|
|
* @param {string|ObjectID} data.link_id
|
|
*/
|
|
constructor(data) {
|
|
if (typeof data.post_id === 'string') {
|
|
this.post_id = ObjectID.createFromHexString(data.post_id);
|
|
} else {
|
|
this.post_id = data.post_id;
|
|
}
|
|
if (typeof data.link_id === 'string') {
|
|
this.link_id = ObjectID.createFromHexString(data.link_id);
|
|
} else {
|
|
this.link_id = data.link_id;
|
|
}
|
|
}
|
|
};
|