Syncing alert stash with manticore.

This commit is contained in:
DebaucheryLibrarian 2024-04-29 03:53:17 +02:00
parent db1b72f95f
commit 6339a253c0
3 changed files with 105 additions and 5 deletions

View File

@ -0,0 +1,28 @@
exports.up = async (knex) => {
await knex.schema.alterTable('alerts', (table) => {
table.boolean('all_actors')
.notNullable()
.defaultTo(true);
table.boolean('all_entities')
.notNullable()
.defaultTo(true);
table.boolean('all_tags')
.notNullable()
.defaultTo(true);
table.boolean('all_matches')
.notNullable()
.defaultTo(true);
});
};
exports.down = async (knex) => {
await knex.schema.alterTable('alerts', (table) => {
table.dropColumn('all_actors');
table.dropColumn('all_entities');
table.dropColumn('all_tags');
table.dropColumn('all_matches');
});
};

View File

@ -441,6 +441,10 @@ const tags = [
description: 'Shoving a cock down your throat during a [blowjob](/tag/blowjob) or [facefuck](/tag/facefucking), giving them a tight sensation while showing off your skills. Without practice, a cock hitting the back of your mouth will likely make you [gag](/tag/gagging).',
group: 'oral',
},
{
name: 'dirty talk',
slug: 'dirty-talk',
},
{
name: 'double penetration',
slug: 'dp',
@ -726,6 +730,11 @@ const tags = [
name: 'live',
slug: 'live',
},
{
name: 'living room',
slug: 'living-room',
group: 'location',
},
{
name: 'maid',
slug: 'maid',
@ -828,6 +837,11 @@ const tags = [
slug: 'outdoors',
group: 'location',
},
{
name: 'indoors',
slug: 'indoors',
group: 'location',
},
{
name: 'outie pussy',
slug: 'outie-pussy',
@ -1201,6 +1215,14 @@ const tags = [
name: 'hijab',
slug: 'hijab',
},
{
name: 'straight',
slug: 'straight',
},
{
name: 'real orgasm',
slug: 'real-orgasm',
},
];
const aliases = [
@ -1993,6 +2015,10 @@ const aliases = [
name: 'point-of-view',
for: 'pov',
},
{
name: 'p.o.v.',
for: 'pov',
},
{
name: 'prolapse',
for: 'anal-prolapse',
@ -2449,6 +2475,22 @@ const aliases = [
name: 'cheat',
for: 'cheating',
},
{
name: 'straight porn',
for: 'straight',
},
{
name: 'anal masturbation',
for: 'anal-fingering',
},
{
name: 'indoor',
for: 'indoors',
},
{
name: 'outdoor',
for: 'outdoors',
},
];
const priorities = [ // higher index is higher priority

View File

@ -3,6 +3,7 @@
const escapeRegexp = require('escape-string-regexp');
const knex = require('./knex');
const { indexApi } = require('./manticore');
const bulkInsert = require('./utils/bulk-insert');
const { HttpError } = require('./errors');
@ -203,16 +204,45 @@ async function notify(scenes) {
scene_id: trigger.sceneId,
}));
const stashes = Object.values(Object.fromEntries(triggers.flatMap((trigger) => trigger.alert.stashes.map((stashId) => ({
scene_id: trigger.sceneId,
stash_id: stashId,
const uniqueStashes = Object.values(Object.fromEntries(triggers.flatMap((trigger) => trigger.alert.stashes.map((stashId) => ({
sceneId: trigger.sceneId,
stashId,
userId: trigger.alert.userId,
}))).map((stash) => [`${stash.stash_id}:${stash.scene_id}`, stash])));
await Promise.all([
const stashEntries = uniqueStashes.map((stash) => ({
scene_id: stash.sceneId,
stash_id: stash.stashId,
}));
const [stashed] = await Promise.all([
bulkInsert('stashes_scenes', stashEntries, false),
bulkInsert('notifications', notifications, false),
bulkInsert('stashes_scenes', stashes, false),
]);
// we need created_at from the databased, but user_id is not returned. it's easier to query it than to try and merge it with the input data
const stashedEntries = await knex('stashes_scenes')
.select('stashes_scenes.*', 'stashes.user_id')
.leftJoin('stashes', 'stashes.id', 'stashes_scenes.stash_id')
.whereIn('stashes_scenes.id', stashed.map((stash) => stash.id));
const docs = stashedEntries.map((stash) => ({
replace: {
index: 'scenes_stashed',
id: stash.id,
doc: {
scene_id: stash.scene_id,
user_id: stash.user_id,
stash_id: stash.stash_id,
created_at: Math.round(stash.created_at.getTime() / 1000),
},
},
}));
if (docs.length > 0) {
await indexApi.bulk(docs.map((doc) => JSON.stringify(doc)).join('\n'));
}
return triggers;
}