feat: note publishing progress

This commit is contained in:
2023-10-11 15:41:36 +01:00
parent c239fba3df
commit 0e4a040750
22 changed files with 438 additions and 351 deletions

View File

@ -1,9 +1,10 @@
import { TaggedNostrEvent, EventKind, MetadataCache } from "@snort/system";
import { getDisplayName } from "Element/User/DisplayName";
import { MentionRegex } from "Const";
import { defaultAvatar, tagFilterOfTextRepost, unwrap } from "SnortUtils";
import { defaultAvatar, tagFilterOfTextRepost } from "SnortUtils";
import { UserCache } from "Cache";
import { LoginSession } from "Login";
import { removeUndefined } from "@snort/shared";
export interface NotificationRequest {
title: string;
@ -20,10 +21,7 @@ export async function makeNotification(ev: TaggedNostrEvent): Promise<Notificati
}
const pubkeys = new Set([ev.pubkey, ...ev.tags.filter(a => a[0] === "p").map(a => a[1])]);
await UserCache.buffer([...pubkeys]);
const allUsers = [...pubkeys]
.map(a => UserCache.getFromCache(a))
.filter(a => a)
.map(a => unwrap(a));
const allUsers = removeUndefined([...pubkeys].map(a => UserCache.getFromCache(a)));
const fromUser = UserCache.getFromCache(ev.pubkey);
const name = getDisplayName(fromUser, ev.pubkey);
const avatarUrl = fromUser?.picture || defaultAvatar(ev.pubkey);