diff --git a/webv2/damus.js b/webv2/damus.js index cd7bb1c..71dc13e 100644 --- a/webv2/damus.js +++ b/webv2/damus.js @@ -124,6 +124,9 @@ async function damus_web_init() function process_reaction_event(model, ev) { + if (!is_valid_reaction_content(ev.content)) + return + let last = {} for (const tag of ev.tags) { @@ -573,9 +576,21 @@ function render_pfp(pk, profile, size="normal") { return `` } +const REACTION_REGEX = /^(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])$/gi; +function is_emoji(str) +{ + return REACTION_REGEX.test(str) +} + +function is_valid_reaction_content(content) +{ + return content === "+" || content === "" || is_emoji(content) +} + function get_reaction_emoji(ev) { if (ev.content === "+" || ev.content === "") return "❤️" + return ev.content } @@ -657,7 +672,11 @@ function gather_reply_tags(pubkey, from) { async function create_reply(pubkey, content, from) { const tags = gather_reply_tags(pubkey, from) const created_at = Math.floor(new Date().getTime() / 1000) - const kind = from.kind + let kind = from.kind + + // convert emoji replies into reactions + if (is_valid_reaction_content(content)) + kind = 7 let reply = { pubkey, tags, content, created_at, kind } diff --git a/webv2/index.html b/webv2/index.html index c22a291..a60fa0c 100644 --- a/webv2/index.html +++ b/webv2/index.html @@ -41,7 +41,7 @@ - +