feat: custom emoji reactions
This commit is contained in:
@ -12,6 +12,11 @@ import { findTag } from "utils";
|
||||
import type { EmojiTag } from "../element/emoji";
|
||||
import uniqBy from "lodash.uniqby";
|
||||
|
||||
export interface Emoji {
|
||||
native?: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface EmojiPack {
|
||||
address: string;
|
||||
name: string;
|
||||
@ -19,13 +24,19 @@ export interface EmojiPack {
|
||||
emojis: EmojiTag[];
|
||||
}
|
||||
|
||||
function cleanShortcode(shortcode?: string) {
|
||||
return shortcode?.replace(/\s+/, "_");
|
||||
}
|
||||
|
||||
function toEmojiPack(ev: NostrEvent): EmojiPack {
|
||||
const d = findTag(ev, "d") || "";
|
||||
return {
|
||||
address: `${ev.kind}:${ev.pubkey}:${d}`,
|
||||
name: d,
|
||||
author: ev.pubkey,
|
||||
emojis: ev.tags.filter((t) => t.at(0) === "emoji") as EmojiTag[],
|
||||
emojis: ev.tags
|
||||
.filter((t) => t.at(0) === "emoji")
|
||||
.map((t) => ["emoji", cleanShortcode(t.at(1)), t.at(2)]) as EmojiTag[],
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user