Ghost/ghost/audience-feedback/lib/Feedback.js
Simon Backx e540344ef2
Added audience feedback service and storage (#15584)
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.
2022-10-11 16:32:28 +02:00

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;
}
}
};