Purging expired notifications and alerts. Fixed manticore stash sync.

This commit is contained in:
2026-07-13 17:27:50 +02:00
parent cf758c2494
commit 327885dd17
9 changed files with 194 additions and 9 deletions
+14 -1
View File
@@ -36,6 +36,7 @@ function curateScene(rawScene, assets, reqUser, context) {
entryId: rawScene.entry_id,
date: rawScene.date,
datePrecision: rawScene.date_precision,
isUpcoming: rawScene.date && rawScene.date - new Date() > 0,
createdAt: rawScene.created_at,
effectiveDate: rawScene.effective_date,
description: censor(rawScene.description, context.restriction),
@@ -131,7 +132,6 @@ function curateScene(rawScene, assets, reqUser, context) {
poster: curateMedia(assets.poster, { type: 'poster' }),
photos: assets.photos?.map((photo) => curateMedia(photo, { type: 'photo' })) || [],
caps: assets.caps?.map((cap) => curateMedia(cap, { type: 'cap' })) || [],
stashes: assets.stashes?.map((stash) => curateStash(stash)) || [],
fingerprints: assets.fingerprints?.map((fingerprint) => ({
hash: fingerprint.hash,
type: fingerprint.type,
@@ -143,6 +143,11 @@ function curateScene(rawScene, assets, reqUser, context) {
createdBatchId: rawScene.created_batch_id,
updatedBatchId: rawScene.updated_batch_id,
isNew: assets.lastBatchId === rawScene.created_batch_id,
stashes: assets.stashes?.map((stash) => curateStash(stash)) || [],
alerts: {
only: assets.alerts?.filter((alert) => alert.is_only).flatMap((alert) => alert.alert_ids) || [],
multi: assets.alerts?.filter((alert) => !alert.is_only).flatMap((alert) => alert.alert_ids) || [],
},
};
const isVideoRestricted = config.media.videoRestrictions.includes(curatedScene.channel.slug) || config.media.videoRestrictions.includes(`_${curatedScene.network?.slug}`);
@@ -179,6 +184,7 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
teasers,
fingerprints,
stashes,
alerts,
lastBatch,
} = await promiseProps({
scenes: knex('releases').whereIn('releases.id', sceneIds),
@@ -356,6 +362,11 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
.where('stashes.user_id', reqUser.id)
.whereIn('stashes_scenes.scene_id', sceneIds)
: [],
alerts: reqUser
? knex('alerts_users_scenes')
.where('user_id', reqUser.id)
.whereIn('scene_id', sceneIds)
: [],
});
const actorStashes = reqUser && context.actorStashes
@@ -388,6 +399,7 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
const sceneFingerprints = fingerprints.filter((fingerprint) => fingerprint.scene_id === sceneId);
const sceneStashes = stashes.filter((stash) => stash.scene_id === sceneId);
const sceneActorStashes = sceneActors.map((actor) => actorStashes.find((stash) => stash.actor_id === actor.id)).filter(Boolean);
const sceneAlerts = alerts.filter((alert) => alert.scene_id === sceneId);
return curateScene(scene, {
channel: sceneChannel,
@@ -406,6 +418,7 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
fingerprints: sceneFingerprints,
stashes: sceneStashes,
actorStashes: sceneActorStashes,
alerts: sceneAlerts,
lastBatchId: lastBatch?.id,
}, reqUser, context);
}).filter(Boolean);