2023-08-02 16:43:26 +03:00
|
|
|
const TableImporter = require('./TableImporter');
|
2023-01-23 15:47:10 +03:00
|
|
|
const {faker} = require('@faker-js/faker');
|
|
|
|
const dateToDatabaseString = require('../utils/database-date');
|
|
|
|
|
|
|
|
class WebMentionsImporter extends TableImporter {
|
2023-02-16 15:11:00 +03:00
|
|
|
static table = 'mentions';
|
2023-12-13 16:23:30 +03:00
|
|
|
static dependencies = [];
|
2023-12-13 16:48:39 +03:00
|
|
|
defaultQuantity = 23;
|
2023-02-16 15:11:00 +03:00
|
|
|
|
2023-08-02 16:43:26 +03:00
|
|
|
constructor(knex, transaction, {baseUrl}) {
|
|
|
|
super(WebMentionsImporter.table, knex, transaction);
|
2023-01-23 15:47:10 +03:00
|
|
|
|
|
|
|
this.baseUrl = baseUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
generate() {
|
2024-01-05 16:42:30 +03:00
|
|
|
const id = this.fastFakeObjectId();
|
2023-01-23 15:47:10 +03:00
|
|
|
|
|
|
|
const author = `${faker.name.fullName()}`;
|
2023-12-13 16:23:30 +03:00
|
|
|
|
|
|
|
// Generating only incoming recommendations for now, since we don't use webmentions for other things atm
|
2023-01-23 15:47:10 +03:00
|
|
|
return {
|
|
|
|
id,
|
2023-12-13 16:23:30 +03:00
|
|
|
source: `${faker.internet.url()}/.well-known/recommendations.json`,
|
2023-01-23 15:47:10 +03:00
|
|
|
source_title: faker.lorem.sentence(5),
|
|
|
|
source_site_title: `${author}'s ${faker.word.noun()}`,
|
|
|
|
source_excerpt: faker.lorem.paragraph(),
|
|
|
|
source_author: author,
|
2023-02-13 16:16:24 +03:00
|
|
|
source_featured_image: `https://api.dicebear.com/5.x/shapes/png?size=256&seed=${id}`,
|
|
|
|
source_favicon: `https://api.dicebear.com/5.x/bottts/png?size=32&seed=${id}`,
|
2023-12-13 16:23:30 +03:00
|
|
|
target: `${this.baseUrl}`,
|
|
|
|
resource_id: null,
|
|
|
|
resource_type: null,
|
|
|
|
created_at: dateToDatabaseString(faker.date.past()),
|
|
|
|
payload: JSON.stringify({}),
|
|
|
|
deleted: 0,
|
|
|
|
verified: 1
|
2023-01-23 15:47:10 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = WebMentionsImporter;
|