mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
28 lines
895 B
TypeScript
28 lines
895 B
TypeScript
import { type NostrEvent } from '@/deps.ts';
|
|
import { getAuthor } from '@/queries.ts';
|
|
import { nostrDate } from '@/utils.ts';
|
|
import { accountFromPubkey } from '@/views/mastodon/accounts.ts';
|
|
import { renderStatus } from '@/views/mastodon/statuses.ts';
|
|
|
|
function renderNotification(event: NostrEvent, viewerPubkey?: string) {
|
|
switch (event.kind) {
|
|
case 1:
|
|
return renderNotificationMention(event, viewerPubkey);
|
|
}
|
|
}
|
|
|
|
async function renderNotificationMention(event: NostrEvent, viewerPubkey?: string) {
|
|
const author = await getAuthor(event.pubkey);
|
|
const status = await renderStatus({ ...event, author }, { viewerPubkey: viewerPubkey });
|
|
if (!status) return;
|
|
|
|
return {
|
|
id: event.id,
|
|
type: 'mention',
|
|
created_at: nostrDate(event.created_at).toISOString(),
|
|
account: status.account,
|
|
status: status,
|
|
};
|
|
}
|
|
|
|
export { accountFromPubkey, renderNotification };
|