@nodebb/nodebb-plugin-reactions 2.2.7 → 2.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # nodebb-plugin-reactions
2
2
  Reactions plugin for NodeBB
3
3
 
4
+ This plugin requires nodebb-plugin-emoji to be active.
5
+
4
6
  # Installation
5
7
  Install via one-click activation in the Admin Control Panel or run the following command:
6
8
 
@@ -12,4 +14,4 @@ Install via one-click activation in the Admin Control Panel or run the following
12
14
  ![demo](./assets/demo.png)
13
15
 
14
16
  ## ACP:
15
- ![acp](./assets/acp.png)
17
+ ![acp](./assets/acp.png)
@@ -0,0 +1,3 @@
1
+ {
2
+ "notificationType-reaction": "When someone reacts to your posts & chats"
3
+ }
@@ -21,5 +21,5 @@
21
21
  "settings.reaction-reputations.remove": "Delete",
22
22
  "settings.reaction-reputations.edit": "Edit",
23
23
  "notification.user-has-reacted-with-to-your-post-in-topic": "<strong>%1</strong> has reacted with %2 to your post in <strong>%3</strong>",
24
- "notification.user-has-reacted-with-to-your-message-in-room": "<strong>%1</strong> has reacted with %2 to your message in <strong class=\"text-nowrap\"><i class=\"fa %3\"></i>%4</strong>"
24
+ "notification.user-has-reacted-with-to-your-message-in-room": "<strong>%1</strong> has reacted with %2 to your message in <strong class=\"text-nowrap\"><i class=\"fa %3\"></i> %4</strong>"
25
25
  }
package/library.js CHANGED
@@ -81,6 +81,16 @@ ReactionsPlugin.filterSettingsGet = async function (hookData) {
81
81
  return hookData;
82
82
  };
83
83
 
84
+ ReactionsPlugin.addNotificationFilters = async (data) => {
85
+ data.regularFilters.push({ name: '[[reactions:reactions]]', filter: 'reaction' });
86
+ return data;
87
+ };
88
+
89
+ ReactionsPlugin.notificationTypes = async (data) => {
90
+ data.types.push('notificationType_reaction');
91
+ return data;
92
+ };
93
+
84
94
  ReactionsPlugin.getPostReactions = async function (data) {
85
95
  if (data.uid === 0) {
86
96
  return data;
@@ -326,7 +336,7 @@ SocketPlugins.reactions = {
326
336
  }
327
337
  const maximumReactions = settings.maximumReactions || DEFAULT_MAX_EMOTES;
328
338
  const [postData, totalReactions, emojiIsAlreadyExist, alreadyReacted, reactionReputation] = await Promise.all([
329
- posts.getPostFields(data.pid, ['tid', 'uid']),
339
+ posts.getPostFields(data.pid, ['pid', 'tid', 'uid', 'content', 'sourceContent']),
330
340
  db.setCount(`pid:${data.pid}:reactions`),
331
341
  db.isSetMember(`pid:${data.pid}:reactions`, data.reaction),
332
342
  db.isSetMember(`pid:${data.pid}:reaction:${data.reaction}`, socket.uid),
@@ -365,17 +375,20 @@ SocketPlugins.reactions = {
365
375
  }
366
376
 
367
377
  if (postData.uid && postData.uid !== socket.uid) {
368
- const [userData, topicData] = await Promise.all([
378
+ const [userData, topicData, parsedPostData] = await Promise.all([
369
379
  user.getUserFields(socket.uid, ['username', 'fullname']),
370
380
  topics.getTopicFields(data.tid, ['title']),
381
+ posts.parsePost(postData),
371
382
  ]);
372
383
  const notifObj = await notifications.create({
384
+ type: 'reaction',
373
385
  bodyShort: translator.compile(
374
386
  'reactions:notification.user-has-reacted-with-to-your-post-in-topic',
375
387
  userData.displayname,
376
388
  `:${data.reaction}:`,
377
389
  topicData.title
378
390
  ),
391
+ bodyLong: parsedPostData.content,
379
392
  nid: `uid:${socket.uid}:pid:${data.pid}:reaction:${data.reaction}`,
380
393
  pid: data.pid,
381
394
  tid: data.tid,
@@ -441,7 +454,7 @@ SocketPlugins.reactions = {
441
454
  }
442
455
  const maximumReactionsPerMessage = settings.maximumReactionsPerMessage || DEFAULT_MAX_EMOTES;
443
456
  const [msgData, totalReactions, emojiIsAlreadyExist] = await Promise.all([
444
- messaging.getMessageFields(data.mid, ['roomId', 'fromuid']),
457
+ messaging.getMessageFields(data.mid, ['roomId', 'fromuid', 'content']),
445
458
  db.setCount(`mid:${data.mid}:reactions`),
446
459
  db.isSetMember(`mid:${data.mid}:reactions`, data.reaction),
447
460
  ]);
@@ -476,14 +489,16 @@ SocketPlugins.reactions = {
476
489
  ]);
477
490
 
478
491
  if (msgData.fromuid && msgData.fromuid !== socket.uid) {
479
- const [userData, roomData] = await Promise.all([
492
+ const [userData, roomData, parsedMessage] = await Promise.all([
480
493
  user.getUserFields(socket.uid, ['username', 'userslug', 'fullname']),
481
494
  messaging.getRoomData(roomId),
495
+ messaging.parse(msgData.content, socket.uid, msgData.fromuid, roomId, false),
482
496
  ]);
483
497
  const roomName = roomData.roomName || `[[modules:chat.room-id, ${roomId}]]`;
484
498
  const icon = messaging.getRoomIcon(roomData);
485
499
 
486
500
  const notifObj = await notifications.create({
501
+ type: 'reaction',
487
502
  bodyShort: translator.compile(
488
503
  'reactions:notification.user-has-reacted-with-to-your-message-in-room',
489
504
  userData.displayname,
@@ -491,6 +506,7 @@ SocketPlugins.reactions = {
491
506
  icon,
492
507
  roomName
493
508
  ),
509
+ bodyLong: parsedMessage,
494
510
  roomIcon: icon,
495
511
  nid: `uid:${socket.uid}:mid:${data.mid}:reaction:${data.reaction}`,
496
512
  mid: data.mid,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodebb/nodebb-plugin-reactions",
3
- "version": "2.2.7",
3
+ "version": "2.2.9",
4
4
  "nbbpm": {
5
5
  "compatibility": "^3.6.0 || ^4.0.0"
6
6
  },
package/plugin.json CHANGED
@@ -16,29 +16,15 @@
16
16
  "../admin/plugins/reactions.js": "./public/admin.js"
17
17
  },
18
18
  "hooks": [
19
- {
20
- "hook": "static:app.load", "method": "init"
21
- },
22
- {
23
- "hook": "filter:admin.header.build", "method": "addAdminNavigation"
24
- },
25
- {
26
- "hook": "filter:config.get", "method": "getPluginConfig"
27
- },
28
- {
29
- "hook": "filter:settings.get", "method": "filterSettingsGet"
30
- },
31
- {
32
- "hook": "filter:post.getPosts", "method": "getPostReactions"
33
- },
34
- {
35
- "hook": "filter:messaging.getMessages", "method": "getMessageReactions"
36
- },
37
- {
38
- "hook": "filter:post.get", "method": "onReply"
39
- },
40
- {
41
- "hook": "action:posts.purge", "method": "deleteReactions"
42
- }
19
+ { "hook": "static:app.load", "method": "init" },
20
+ { "hook": "filter:admin.header.build", "method": "addAdminNavigation"},
21
+ { "hook": "filter:config.get", "method": "getPluginConfig" },
22
+ { "hook": "filter:settings.get", "method": "filterSettingsGet" },
23
+ { "hook": "filter:post.getPosts", "method": "getPostReactions" },
24
+ { "hook": "filter:messaging.getMessages", "method": "getMessageReactions" },
25
+ { "hook": "filter:post.get", "method": "onReply" },
26
+ { "hook": "action:posts.purge", "method": "deleteReactions" },
27
+ { "hook": "filter:notifications.addFilters", "method": "addNotificationFilters" },
28
+ { "hook": "filter:user.notificationTypes", "method": "notificationTypes" }
43
29
  ]
44
30
  }