mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 16:14:25 +03:00
5fcf5098a8
closes https://github.com/TryGhost/Team/issues/1927 This expose the /links endpoint on the Admin API, which is filterable by Post ID. Co-authored-by: Simon Backx <simon@ghost.org>
37 lines
907 B
JavaScript
37 lines
907 B
JavaScript
const ObjectID = require('bson-objectid').default;
|
|
|
|
/**
|
|
* @typedef {Object} FullPostLinkCount
|
|
* @property {number} clicks
|
|
*/
|
|
|
|
/**
|
|
* Stores the connection between a LinkRedirect and a Post
|
|
*/
|
|
module.exports = class FullPostLink {
|
|
/** @type {ObjectID} */
|
|
post_id;
|
|
|
|
/** @type {import('@tryghost/link-redirects/lib/LinkRedirect')} */
|
|
link;
|
|
|
|
/** @type {FullPostLinkCount} */
|
|
count;
|
|
|
|
/**
|
|
* @param {object} data
|
|
* @param {string|ObjectID} data.post_id
|
|
* @param {import('@tryghost/link-redirects/lib/LinkRedirect')} data.link
|
|
* @param {FullPostLinkCount} data.count
|
|
*/
|
|
constructor(data) {
|
|
if (typeof data.post_id === 'string') {
|
|
this.post_id = ObjectID.createFromHexString(data.post_id);
|
|
} else {
|
|
this.post_id = data.post_id;
|
|
}
|
|
this.link = data.link;
|
|
this.count = data.count;
|
|
}
|
|
};
|