mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-04 12:44:57 +03:00
e540344ef2
fixes https://github.com/TryGhost/Team/issues/2049 fixes https://github.com/TryGhost/Team/issues/2053 - This adds a new audience feedback package to Ghost. - A new members API to give feedback on posts using the `/api/feedback` endpoint. - Added a new authentication middleware that supports both uuid-based and session based authentication.
36 lines
876 B
JavaScript
36 lines
876 B
JavaScript
const ObjectID = require('bson-objectid').default;
|
|
|
|
module.exports = class Feedback {
|
|
/** @type {ObjectID} */
|
|
id;
|
|
/** @type {number} */
|
|
score;
|
|
/** @type {ObjectID} */
|
|
memberId;
|
|
/** @type {ObjectID} */
|
|
postId;
|
|
|
|
constructor(data) {
|
|
if (!data.id) {
|
|
this.id = new ObjectID();
|
|
}
|
|
|
|
if (typeof data.id === 'string') {
|
|
this.id = ObjectID.createFromHexString(data.id);
|
|
}
|
|
|
|
this.score = data.score ?? 0;
|
|
if (typeof data.memberId === 'string') {
|
|
this.memberId = ObjectID.createFromHexString(data.memberId);
|
|
} else {
|
|
this.memberId = data.memberId;
|
|
}
|
|
|
|
if (typeof data.postId === 'string') {
|
|
this.postId = ObjectID.createFromHexString(data.postId);
|
|
} else {
|
|
this.postId = data.postId;
|
|
}
|
|
}
|
|
};
|