You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.0 KiB
99 lines
2.0 KiB
import DirectusAbstractStore from './abstract.js'
|
|
import logger from './../../src/runner/helpers/logger.js'
|
|
|
|
/**
|
|
* Pages from Directus
|
|
*
|
|
* @author Björn Hase <me@herr-hase.wtf>
|
|
* @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
|