fix: no make notification for reposts

This commit is contained in:
kPherox 2023-02-16 18:16:07 +09:00
parent 8e5c9686df
commit dfa2bf5873
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D

View File

@ -10,6 +10,10 @@ import { MentionRegex } from "Const";
export async function makeNotification(db: UsersDb, ev: TaggedRawEvent): Promise<NotificationRequest | null> {
switch (ev.kind) {
case EventKind.TextNote: {
const isRepost = ev.tags.some((a, i) => a[0] === "e" && a[3] === "mention" && ev.content === `#[${i}]`);
if (isRepost) {
return null;
}
const pubkeys = new Set([ev.pubkey, ...ev.tags.filter(a => a[0] === "p").map(a => a[1])]);
const users = await db.bulkGet(Array.from(pubkeys));
const fromUser = users.find(a => a?.pubkey === ev.pubkey);