Added quick alert button to actor bio.

This commit is contained in:
2025-03-09 04:12:02 +01:00
parent 45a0631c9b
commit 61ed171c9d
6 changed files with 166 additions and 9 deletions

View File

@@ -166,6 +166,10 @@ export function curateActor(actor, context = {}) {
scenes: actor.scenes,
likes: actor.stashed,
stashes: context.stashes?.map((stash) => curateStash(stash)) || [],
alerts: {
only: context.alerts?.filter((alert) => alert.is_only).flatMap((alert) => alert.alert_ids) || [],
multi: context.alerts?.filter((alert) => !alert.is_only).flatMap((alert) => alert.alert_ids) || [],
},
...context.append?.[actor.id],
};
}
@@ -198,7 +202,7 @@ export function sortActorsByGender(actors, context = {}) {
}
export async function fetchActorsById(actorIds, options = {}, reqUser) {
const [actors, profiles, photos, socials, stashes] = await Promise.all([
const [actors, profiles, photos, socials, stashes, alerts] = await Promise.all([
knex('actors')
.select(
'actors.*',
@@ -253,11 +257,17 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
.where('stashes.user_id', reqUser.id)
.whereIn('stashes_actors.actor_id', actorIds)
: [],
reqUser
? knex('alerts_users_actors')
.where('user_id', reqUser.id)
.whereIn('actor_id', actorIds)
: [],
]);
if (options.order) {
return actors.map((actorEntry) => curateActor(actorEntry, {
stashes: stashes.filter((stash) => stash.actor_id === actorEntry.id),
alerts: alerts.filter((alert) => alert.actor_id === actorEntry.id),
append: options.append,
}));
}
@@ -272,6 +282,7 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
return curateActor(actor, {
stashes: stashes.filter((stash) => stash.actor_id === actor.id),
alerts: alerts.filter((alert) => alert.actor_id === actor.id),
profiles: profiles.filter((profile) => profile.actor_id === actor.id),
photos: photos.filter((photo) => photo.actor_id === actor.id),
socials: socials.filter((social) => social.actor_id === actor.id),