Ghost/ghost/link-tracking/lib/LinkClick.js
Fabien 'egg' O'Carroll bddb0ba754
Wired up link redirects & tracking (#15418)
refs https://github.com/TryGhost/Team/issues/1910
refs https://github.com/TryGhost/Team/issues/1888

- Uses an in-memory repository for now whilst in development
- Updates the LinkReplacementService to choose the slug
- Exposes a `getSlug` method so we can ensure uniqueness
- Emits the RedirectEvent for use by LinkTracking
2022-09-16 10:42:21 +02:00

26 lines
580 B
JavaScript

const ObjectID = require('bson-objectid').default;
module.exports = class ClickEvent {
/** @type {ObjectID} */
event_id;
/** @type {ObjectID} */
member_id;
/** @type {ObjectID} */
link_id;
constructor(data) {
if (!data.id) {
this.event_id = new ObjectID();
}
if (typeof data.id === 'string') {
this.event_id = ObjectID.createFromHexString(data.id);
} else {
this.event_id = data.id;
}
this.member_id = data.member_id;
this.link_id = data.link_id;
}
};