Added getAll method to BookshelfMentionRepository

This is necessary to support the getMentionReport method in MentionsAPI
This commit is contained in:
Fabien "egg" O'Carroll 2023-03-12 23:07:08 +07:00 committed by Rishabh Garg
parent 0262083bb0
commit 018e2654c5

View File

@ -12,6 +12,7 @@ const logging = require('@tryghost/logging');
/**
* @typedef {import('@tryghost/webmentions/lib/MentionsAPI').GetPageOptions} GetPageOptions
* @typedef {import('@tryghost/webmentions/lib/MentionsAPI').GetAllOptions} GetAllOptions
*/
/**
@ -84,6 +85,16 @@ module.exports = class BookshelfMentionRepository {
};
}
/**
* @param {GetAllOptions} options
* @returns {Promise<import('@tryghost/webmentions/lib/Mention')[]>}
*/
async getAll(options) {
const models = await this.#MentionModel.findAll(options);
return await Promise.all(models.map(model => this.#modelToMention(model)));
}
/**
* @param {URL} source
* @param {URL} target