Added ability to set verified when instantiating Mention

refs https://github.com/TryGhost/Team/issues/2548

We need to be able to do this outside of the verify method so that
repository implementations have the ability to create existing
instances without running expensive verification checks!
This commit is contained in:
Fabien "egg" O'Carroll 2023-02-17 18:38:28 +07:00 committed by Fabien 'egg' O'Carroll
parent 101cabb188
commit 277a563138

View File

@ -166,6 +166,7 @@ module.exports = class Mention {
this.#timestamp = data.timestamp;
this.#payload = data.payload;
this.#resourceId = data.resourceId;
this.#verified = data.verified;
}
/**
@ -223,6 +224,10 @@ module.exports = class Mention {
let payload;
payload = data.payload ? JSON.parse(JSON.stringify(data.payload)) : null;
/** @type boolean */
let verified;
verified = isNew ? false : !!data.verified;
/** @type {ObjectID | null} */
let resourceId = null;
if (data.resourceId) {
@ -239,7 +244,8 @@ module.exports = class Mention {
target,
timestamp,
payload,
resourceId
resourceId,
verified
});
mention.setSourceMetadata(data);