v3: correctly using SITE_NAME across the app, added notifications on comments
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 44s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 44s
This commit is contained in:
@@ -5,7 +5,10 @@ import {
|
||||
} from "../model/interfaces.ts";
|
||||
import { type SQLOutputValue } from "node:sqlite";
|
||||
import { commentRowToApi, db, isCommentRow } from "../model/db.ts";
|
||||
import { notifyMentions } from "./notification-service.ts";
|
||||
import {
|
||||
notifyDumpOwnerNewComment,
|
||||
notifyMentions,
|
||||
} from "./notification-service.ts";
|
||||
import { linkAttachments } from "./attachment-service.ts";
|
||||
|
||||
const SELECT_COLS =
|
||||
@@ -66,6 +69,7 @@ export function createComment(
|
||||
const dumpRow = db.prepare(`SELECT title FROM dumps WHERE id = ?;`).get(
|
||||
dumpId,
|
||||
) as { title: string } | undefined;
|
||||
notifyDumpOwnerNewComment(userId, id, dumpId);
|
||||
notifyMentions(userId, body, "comment", id, dumpRow?.title ?? "", dumpId);
|
||||
linkAttachments(body, id);
|
||||
return comment;
|
||||
|
||||
@@ -276,6 +276,36 @@ export function notifyMentions(
|
||||
}
|
||||
}
|
||||
|
||||
export function notifyDumpOwnerNewComment(
|
||||
commenterId: string,
|
||||
commentId: string,
|
||||
dumpId: string,
|
||||
): void {
|
||||
const commenterRow = db.prepare(
|
||||
`SELECT username FROM users WHERE id = ?;`,
|
||||
).get(commenterId) as { username: string } | undefined;
|
||||
|
||||
const dumpRow = db.prepare(
|
||||
`SELECT title, user_id FROM dumps WHERE id = ?;`,
|
||||
).get(dumpId) as { title: string; user_id: string } | undefined;
|
||||
|
||||
if (!commenterRow || !dumpRow) return;
|
||||
if (commenterId === dumpRow.user_id) return; // no self-notification
|
||||
|
||||
createNotification(
|
||||
dumpRow.user_id,
|
||||
"dump_commented",
|
||||
{
|
||||
commenterId,
|
||||
commenterUsername: commenterRow.username,
|
||||
commentId,
|
||||
dumpId,
|
||||
dumpTitle: dumpRow.title,
|
||||
},
|
||||
`comment:${commentId}`,
|
||||
);
|
||||
}
|
||||
|
||||
export function notifyPlaylistFollowersNewDump(
|
||||
playlistId: string,
|
||||
playlistTitle: string,
|
||||
|
||||
Reference in New Issue
Block a user