import DirectusAbstractStore from './abstract.js' import logger from './../../src/runner/helpers/logger.js' /** * Pages from Directus * * @author Björn Hase * @license http://opensource.org/licenses/MIT The MIT License * @link https://gitea.node001.net/HerrHase/super-fastify-directus.git * */ class EventStore extends DirectusAbstractStore { /** * init PageStore * * * @param {string} endpoint * */ constructor() { super('event') } /** * getting page by permalink * * * @param {string} permalink * @return {object} * */ findOneBySource(sourceHost, sourceHash) { return this.items.readByQuery({ fields: [ 'title', 'status', 'source_host', 'source_url', 'source_hash', 'start', 'end', 'excerpt', 'content', 'tags', 'parent', 'media.id', 'media.description', 'permalink', 'date_updated_source' ], filter: { source_host : sourceHost, source_hash : sourceHash }, limit: 1 }) } /** * import media from url * * @param {string} url * @return {object} */ async importMediaFromUrl(url) { try { const file = await this.directus.files.import({ url: url }) if (file) { return file.id } } catch(error) { logger.error(error) } return false } /** * getting page by permalink * * * @param {object} data * @return {object} * */ create(data) { return this.items.createOne(data) } } export default EventStore