feat(notifications) : add profile pictures and guide previews
This commit is contained in:
@@ -40,9 +40,9 @@ export async function sendCommentPush(id: string, version?: number) {
|
||||
} catch { return; }
|
||||
if (!destination.writable) return;
|
||||
url = `/admin/comments?target=${encodeURIComponent(destination.target)}&comment=${id}`;
|
||||
title = `แสดงความคิดเห็นใหม่ใน ${destination.name}`;
|
||||
title = destination.target.startsWith("guide:") ? `แสดงความคิดเห็นใหม่ในไกด์ ${destination.name}` : `แสดงความคิดเห็นใหม่ใน ${destination.name}`;
|
||||
}
|
||||
const [author] = await getDb().select({ name: users.name }).from(users).where(eq(users.id, reply.authorId)).limit(1);
|
||||
const [author] = await getDb().select({ name: users.name, image: users.image }).from(users).where(eq(users.id, reply.authorId)).limit(1);
|
||||
const [revision] = await getDb().select({ text: commentRevisions.text }).from(commentRevisions)
|
||||
.where(and(eq(commentRevisions.commentId, id), eq(commentRevisions.version, notificationVersion))).limit(1);
|
||||
if (!revision) return;
|
||||
@@ -56,7 +56,7 @@ export async function sendCommentPush(id: string, version?: number) {
|
||||
if (!subscriptions.length) return;
|
||||
webPush.setVapidDetails(process.env.WEB_PUSH_SUBJECT!, process.env.WEB_PUSH_PUBLIC_KEY!, process.env.WEB_PUSH_PRIVATE_KEY!);
|
||||
const payload = JSON.stringify({ id: `comment-${id}`, title: notificationTitle,
|
||||
body, icon: "/icon/nav/Comment.webp",
|
||||
body, icon: author?.image || "/icon/nav/Comment.webp",
|
||||
url });
|
||||
for (let offset = 0; offset < subscriptions.length; offset += 10) {
|
||||
await Promise.all(subscriptions.slice(offset, offset + 10).map(async (subscription) => {
|
||||
|
||||
Reference in New Issue
Block a user