[nodebb-plugin-reactions] Reactions plugin for NodeBB
-
This is really a plugin with great potential that is used a lot in our forum. But I am missing some elements:
-
notifications of how and by whom a post was reacted to. Currently you only see this when you go back to your post.
-
on a mobile device you can not see who all has reacted to a post. You can see the number but not by whom. You can only tap on the reaction and then react as well. A listing as with Likes would be nice.
-
I would like to see a separate selection of reaction emojis, not identical to the (custom) emojis list. I'm thinking of providing only 3-5 emojis to react.
@julian is it still possible that you reintroduce another reactions plugin?
-
-
@julian The problem I see is that the actually very cool feature of linking a reaction to reputation is not clear with the mass of emojis unless you add a rule to each emoji. I already have over 60 custom emojis, plus the standard emojis. Also, why should you be able to react to a post with a mountain cableway emoji. .
The idea I have is to completely dispense with upvotes and instead regulate reputation solely through a few reactions. Thumbs up , thank you , helpful - something like that.
But I completely understand your point about the previous way being easier. I think the first two points are much more important anyway, as I've received quite a few inquiries about why there are no notifications on reactions and the presentation on mobile devices.
-
Published a new version(2.1.6) of this plugin for NodeBB 3.3.0
Changes:
- Update acp with the new design
- Add chat message reactions
- Ability to toggle reaction support on posts/chats from the ACP
- Optimized loading of data, tooltips are only created if you mouseover a reaction instead of loading every single user who reacted on page load.
-
I'm trying to implement basic notification for this plugin.
In the
library.js
I've added the following code afterawait Promise.all([...]);
.const notifications = require.main.require('./src/notifications'); ... SocketPlugins.reactions = { addPostReaction: async function (socket, data) { ... await Promise.all([ db.setAdd(`pid:${data.pid}:reactions`, data.reaction), db.setAdd(`pid:${data.pid}:reaction:${data.reaction}`, socket.uid), ]); // Get the author id const postOwnerUid = await posts.getPostField(data.pid, 'uid'); console.log(`postOwnerUid: ${postOwnerUid}`); // Create and send notification if (postOwnerUid && postOwnerUid !== socket.uid) { console.log(`Attempting to create notification for postOwnerUid: ${postOwnerUid}`); await notifications.create({ bodyShort: `User ${socket.uid} has reacted with ${data.reaction} to your post`, nid: `user:${socket.uid}:reacted:${data.pid}`, pid: data.pid, uid: postOwnerUid, tid: data.tid, from: socket.uid, path: `/post/${data.pid}` }); console.log('Notification created successfully'); console.log(`Attempting to push notification for postOwnerUid: ${postOwnerUid}`); await notifications.push(`user:${socket.uid}:reacted:${data.pid}`, [postOwnerUid]); console.log('Notification pushed successfully'); }
In the log it seems fine (at least without any errors):
postOwnerUid: 8 Attempting to create notification for postOwnerUid: 8 Notification created successfully Attempting to push notification for postOwnerUid: 8 Notification pushed successfully
But I receive no notifications so there must be something wrong. I'm not very familiar with JS yet so console.log is the only way I know to "debug" my code. Help would be appreciated.
-
@dave1904 The first argument of
notifications.push
takes the entire notification object, which is what is returned fromnotifications.create
We should probably add some sanity checks in case you pass in an incorrect format to
notifications.push
, heh. -
@baris said in [nodebb-plugin-reactions] Reactions plugin for NodeBB:
@dave1904 correct. Right now the bodyShort property isn't parsed like a post so plugins like markdown/emoji aren't turning the markup into html.
Maybe you would have to associate the emoji alias with the file name, find the image and replace the alias in bodyShort.
For now I will use this basic solution. You get a notification for every reaction without any aggregation but I'm happy with it.
-
@dave1904 you can try to use this code https://github.com/NodeBB-Community/nodebb-plugin-reactions/blob/master/library.js#L20C10-L33 to turn the reaction into an emoji for use in bodyShort. Maybe like this
const notifObj = await notifications.create({ bodyShort: `User ${socket.uid} has reacted with ${parse(data.reaction)} to your post`, nid: `user:${socket.uid}:reacted:${data.pid}`, pid: data.pid, uid: postOwnerUid, tid: data.tid, from: socket.uid, path: `/post/${data.pid}` });
-
@dave1904 I've added support for this in reactions plugin with a proper language string so it can be translated. https://github.com/NodeBB-Community/nodebb-plugin-reactions/commit/da7d546129bb79341790c609e9d08b86419b8012
Feel free to send translations for other languages.
-
@baris Thanks! May I ask how did you manage to render the emojis without calling the
parse()
function? Istranslator.compile()
doing the same and does this also work for custom emojis that are not unicode?Here is the
reactions.json
forde-DE
{ "reactions": "Reaktionen", "add-reaction": "Reaktion hinzufügen", "error.invalid-reaction": "Ungültige Reaktion", "error.maximum-reached": "Maximale Reaktionen erreicht", "error.maximum-per-user-per-post-reached": "Maximale Reaktionen pro Nutzer und Beitrag erreicht", "settings.title": "Plugin-Einstellungen für Reaktionen", "settings.enable-post-reactions": "Reaktionen auf Posts aktivieren", "settings.max-reactions-per-post": "Maximale eindeutige Reaktionen pro Beitrag (0 für unbegrenzt, Standard: 4)", "settings.max-reactions-per-user-per-post": "Maximale Reaktionen pro Nutzer und Beitrag (0 für unbegrenzt)", "settings.max-reactions-per-user-per-post-help": "Der Grenzwert wird nur beim Hinzufügen einer neuen Reaktion und nicht beim Hinzufügen zu einer bestehenden Reaktion eingehalten.", "settings.enable-message-reactions": "Reaktionen auf Nachrichten aktivieren", "settings.max-reactions-per-message": "Maximale eindeutige Reaktionen pro Nachricht (0 für unbegrenzt, Standard: 4)", "settings.max-reactions-per-user-per-message": "Maximale Reaktionen pro Benutzer und Nachricht (0 für unbegrenzt)", "settings.max-reactions-per-user-per-message-help": "Der Grenzwert wird nur beim Hinzufügen einer neuen Reaktion und nicht beim Hinzufügen zu einer bestehenden Reaktion eingehalten.", "settings.reaction-reputations": "Reaktion Ansehen (optional)", "settings.reaction-reputations-help": "Sie können den einzelnen Reaktionen Ansehen zuweisen. Wenn eine Reaktion auf einen Beitrag angewendet wird, erhält der Eigentümer dieses Beitrags dieses Ansehen.", "settings.reaction-reputations.add": "Regel hinzufügen", "settings.reaction-reputations.reaction": "Reaktion", "settings.reaction-reputations.reputation": "Ansehen", "settings.reaction-reputations.remove": "Löschen", "settings.reaction-reputations.edit": "Bearbeiten", "notification.user-has-reacted-with-to-your-post-in-topic": "<strong>%1</strong> hat mit %2 auf deinen Beitrag in <strong>%3</strong> reagiert", "notification.user-has-reacted-with-to-your-message-in-room": "<strong>%1</strong> hat mit %2 auf deine Nachricht in <strong class=\"text-nowrap\"><i class=\"fa %3\"></i>%4</strong> reagiert" }
edit: No luck on my dev instance: