2022-09-14 01:18:19 +03:00
|
|
|
const ObjectID = require('bson-objectid').default;
|
|
|
|
|
|
|
|
module.exports = class LinkRedirect {
|
|
|
|
/** @type {ObjectID} */
|
|
|
|
link_id;
|
|
|
|
/** @type {URL} */
|
|
|
|
from;
|
|
|
|
/** @type {URL} */
|
|
|
|
to;
|
2022-10-20 15:47:44 +03:00
|
|
|
/** @type {boolean} */
|
|
|
|
edited;
|
2022-09-14 01:18:19 +03:00
|
|
|
|
|
|
|
constructor(data) {
|
|
|
|
if (!data.id) {
|
|
|
|
this.link_id = new ObjectID();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof data.id === 'string') {
|
|
|
|
this.link_id = ObjectID.createFromHexString(data.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.from = data.from;
|
|
|
|
this.to = data.to;
|
2022-10-20 15:47:44 +03:00
|
|
|
this.edited = !!data.edited;
|
2022-09-14 01:18:19 +03:00
|
|
|
}
|
|
|
|
};
|