diff --git a/ghost/webmentions/lib/Mention.js b/ghost/webmentions/lib/Mention.js index 15b1990ac9..7b52cbce82 100644 --- a/ghost/webmentions/lib/Mention.js +++ b/ghost/webmentions/lib/Mention.js @@ -12,6 +12,23 @@ module.exports = class Mention { return this.#id; } + /** @type {boolean} */ + #verified = false; + get verified() { + return this.#verified; + } + + /** + * @param {string} html + */ + verify(html) { + if (html.includes(this.target.href)) { + this.#verified = true; + } else { + this.#verified = false; + } + } + /** @type {URL} */ #source; get source() { diff --git a/ghost/webmentions/test/Mention.test.js b/ghost/webmentions/test/Mention.test.js index 6a71158a43..64b3e423aa 100644 --- a/ghost/webmentions/test/Mention.test.js +++ b/ghost/webmentions/test/Mention.test.js @@ -32,6 +32,19 @@ describe('Mention', function () { }); }); + describe('verify', function () { + it('Does basic check for the target URL and updates verified property', async function () { + const mention = await Mention.create(validInput); + assert(!mention.verified); + + mention.verify(''); + assert(mention.verified); + + mention.verify(''); + assert(!mention.verified); + }); + }); + describe('create', function () { it('Will error with invalid inputs', async function () { const invalidInputs = [