From a9073b0b9d6988a22eb8159a1c8fce98877e0927 Mon Sep 17 00:00:00 2001 From: vulet Date: Fri, 19 Feb 2021 14:09:40 +0800 Subject: [PATCH] fix(reactions): match redaction codepoint. && fix/styling(feed): bad pathing, cleanup. --- commands/fediverse/utils.js | 31 +++++++++++++++++++------------ utils.js | 8 ++++---- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/commands/fediverse/utils.js b/commands/fediverse/utils.js index 782428b..d55f676 100644 --- a/commands/fediverse/utils.js +++ b/commands/fediverse/utils.js @@ -9,6 +9,7 @@ const sendEventWithMeta = async (roomId, content, meta) => { }; const hasAttachment = (res) => { + if (res.status) res = res.status; if (!res.media_attachments) return '
'; return res.media_attachments.map((media) => { const mediaURL = new URL(media.remote_url); @@ -19,14 +20,14 @@ const hasAttachment = (res) => { const notifyFormatter = (res, roomId) => { userDetails = ` - ${res.account.acct}`; + ${res.account.acct}`; switch (res.type) { case 'follow': fediverse.auth.me !== res.account.url ? res.meta = 'follow' : res.meta = 'redact'; meta = `${res.meta} ${res.account.id}`; content = `${userDetails} - has followed you. -
${res.account.note}
`; + has followed you. +
${res.account.note}
`; sendEventWithMeta(roomId, content, meta); break; case 'favourite': @@ -34,8 +35,11 @@ const notifyFormatter = (res, roomId) => { meta = `${res.meta} ${res.status.id}`; content = `${userDetails} has favorited - your post: -
${res.status.content}
`; + your post: +
${res.status.content}
+ ${hasAttachment(res)} +
(id: ${res.id}) ${registrar.post.visibilityEmoji(res.status.visibility)} +
`; sendEventWithMeta(roomId, content, res.meta); break; case 'mention': @@ -43,9 +47,10 @@ const notifyFormatter = (res, roomId) => { meta = `${res.meta} ${res.status.id}`; content = `${userDetails} has mentioned - you:
${res.status.content} -
(id: ${res.status.id}) ${registrar.post.visibilityEmoji(res.status.visibility)}
-
`; + you:
${res.status.content}
+ ${hasAttachment(res)} +
(id: ${res.id}) ${registrar.post.visibilityEmoji(res.status.visibility)} +
`; sendEventWithMeta(roomId, content, meta); break; case 'reblog': @@ -53,8 +58,10 @@ const notifyFormatter = (res, roomId) => { meta = `${res.meta} ${res.status.id}`; content = `${userDetails} has repeated - your post:
-
${res.status.content}
`; + your post:
${res.status.content}
+ ${hasAttachment(res)} +
(id: ${res.id}) ${registrar.post.visibilityEmoji(res.status.visibility)} +
`; sendEventWithMeta(roomId, content, meta); break; default: @@ -83,8 +90,8 @@ const isReblog = (res, roomId) => { fediverse.auth.me !== res.account.url ? res.meta = 'status' : res.meta = 'unreblog'; meta = `${res.meta} ${res.reblog.id}`; content = `${userDetails} - has repeated - ${res.reblog.account.acct}'s post: + has repeated + ${res.reblog.account.acct}'s post:
${res.content}
${hasAttachment(res)}
(id: ${res.reblog.id}) ${registrar.post.visibilityEmoji(res.visibility)} diff --git a/utils.js b/utils.js index 4f920af..cc453f7 100644 --- a/utils.js +++ b/utils.js @@ -96,9 +96,9 @@ module.exports.handleReact = async (event) => { if (!isMeta.includes(args[0])) return; let command = []; args.shift().toLowerCase(); - if (reaction.key === '🔃') command = 'copy'; + if (reaction.key === '🔁') command = 'copy'; if (reaction.key === '👏') command = 'clap'; - if (reaction.key === '🗑') command = 'redact'; + if (reaction.key === '🗑️️') command = 'redact'; eventHandler(args, roomId, command, event); }; @@ -123,9 +123,9 @@ module.exports.selfReact = async (event) => { const { meta } = event.getContent(); if (!meta) return; const type = meta.split(' ')[0]; - if (type === 'redact' || type === 'unreblog') addReact(event, '🗑️'); + if (type === 'redact' || type === 'unreblog') addReact(event, '🗑️️'); if (type === 'status' || type === 'reblog' || type === 'mention') { - addReact(event, '🔃'); + addReact(event, '🔁'); addReact(event, '👏'); } };