@nodebb/nodebb-plugin-reactions 2.2.8 → 2.2.10

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.
@@ -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
@@ -336,7 +336,7 @@ SocketPlugins.reactions = {
336
336
  }
337
337
  const maximumReactions = settings.maximumReactions || DEFAULT_MAX_EMOTES;
338
338
  const [postData, totalReactions, emojiIsAlreadyExist, alreadyReacted, reactionReputation] = await Promise.all([
339
- posts.getPostFields(data.pid, ['tid', 'uid']),
339
+ posts.getPostFields(data.pid, ['pid', 'tid', 'uid', 'content', 'sourceContent']),
340
340
  db.setCount(`pid:${data.pid}:reactions`),
341
341
  db.isSetMember(`pid:${data.pid}:reactions`, data.reaction),
342
342
  db.isSetMember(`pid:${data.pid}:reaction:${data.reaction}`, socket.uid),
@@ -375,9 +375,10 @@ SocketPlugins.reactions = {
375
375
  }
376
376
 
377
377
  if (postData.uid && postData.uid !== socket.uid) {
378
- const [userData, topicData] = await Promise.all([
378
+ const [userData, topicData, parsedPostData] = await Promise.all([
379
379
  user.getUserFields(socket.uid, ['username', 'fullname']),
380
380
  topics.getTopicFields(data.tid, ['title']),
381
+ posts.parsePost(postData),
381
382
  ]);
382
383
  const notifObj = await notifications.create({
383
384
  type: 'reaction',
@@ -387,6 +388,7 @@ SocketPlugins.reactions = {
387
388
  `:${data.reaction}:`,
388
389
  topicData.title
389
390
  ),
391
+ bodyLong: parsedPostData.content,
390
392
  nid: `uid:${socket.uid}:pid:${data.pid}:reaction:${data.reaction}`,
391
393
  pid: data.pid,
392
394
  tid: data.tid,
@@ -452,7 +454,7 @@ SocketPlugins.reactions = {
452
454
  }
453
455
  const maximumReactionsPerMessage = settings.maximumReactionsPerMessage || DEFAULT_MAX_EMOTES;
454
456
  const [msgData, totalReactions, emojiIsAlreadyExist] = await Promise.all([
455
- messaging.getMessageFields(data.mid, ['roomId', 'fromuid']),
457
+ messaging.getMessageFields(data.mid, ['roomId', 'fromuid', 'content']),
456
458
  db.setCount(`mid:${data.mid}:reactions`),
457
459
  db.isSetMember(`mid:${data.mid}:reactions`, data.reaction),
458
460
  ]);
@@ -487,9 +489,10 @@ SocketPlugins.reactions = {
487
489
  ]);
488
490
 
489
491
  if (msgData.fromuid && msgData.fromuid !== socket.uid) {
490
- const [userData, roomData] = await Promise.all([
492
+ const [userData, roomData, parsedMessage] = await Promise.all([
491
493
  user.getUserFields(socket.uid, ['username', 'userslug', 'fullname']),
492
494
  messaging.getRoomData(roomId),
495
+ messaging.parse(msgData.content, socket.uid, msgData.fromuid, roomId, false),
493
496
  ]);
494
497
  const roomName = roomData.roomName || `[[modules:chat.room-id, ${roomId}]]`;
495
498
  const icon = messaging.getRoomIcon(roomData);
@@ -503,6 +506,7 @@ SocketPlugins.reactions = {
503
506
  icon,
504
507
  roomName
505
508
  ),
509
+ bodyLong: parsedMessage,
506
510
  roomIcon: icon,
507
511
  nid: `uid:${socket.uid}:mid:${data.mid}:reaction:${data.reaction}`,
508
512
  mid: data.mid,
@@ -556,7 +560,7 @@ SocketPlugins.reactions = {
556
560
  if (!nameToEmoji(data.reaction)) {
557
561
  throw new Error('[[reactions:error.invalid-reaction]]');
558
562
  }
559
- let set = '';
563
+ let set;
560
564
  if (data.type === 'post') {
561
565
  if (!await privileges.posts.can('topics:read', data.pid, socket.uid)) {
562
566
  throw new Error('[[error:not-allowed]]');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodebb/nodebb-plugin-reactions",
3
- "version": "2.2.8",
3
+ "version": "2.2.10",
4
4
  "nbbpm": {
5
5
  "compatibility": "^3.6.0 || ^4.0.0"
6
6
  },
@@ -38,8 +38,8 @@
38
38
  },
39
39
  "license": "MIT",
40
40
  "devDependencies": {
41
- "eslint": "9.28.0",
42
- "eslint-config-nodebb": "1.1.7"
41
+ "eslint": "10.0.2",
42
+ "eslint-config-nodebb": "^2.0.0"
43
43
  },
44
44
  "scripts": {
45
45
  "lint": "eslint ."
package/public/admin.js CHANGED
@@ -3,7 +3,7 @@
3
3
  define('admin/plugins/reactions', [
4
4
  'settings', 'alerts', 'hooks', 'emoji-dialog', 'emoji',
5
5
  ], function (Settings, alerts, hooks, emojiDialog, emoji) {
6
- var ACP = {};
6
+ const ACP = {};
7
7
  ACP.init = function () {
8
8
  emoji.init(function () {
9
9
  Settings.load('reactions', $('.reactions-settings'), onSettingsLoaded);
package/public/client.js CHANGED
@@ -18,7 +18,7 @@ $(document).ready(function () {
18
18
  hooks.on('action:chat.loaded', function (container) {
19
19
  if (ajaxify.data.template.chats && ajaxify.data.roomId) {
20
20
  setupMessageReactions(container);
21
- } else if (container.hasClass('chat-modal')) {
21
+ } else if (container.hasClass('chat-modal') || container.attr('component') === 'chat/widget') {
22
22
  setupMessageReactions(container);
23
23
  }
24
24
  });
@@ -45,11 +45,11 @@ $(document).ready(function () {
45
45
  setupPostReactionSockets();
46
46
 
47
47
  $('[component="topic"]').on('click', '[component="post/reaction"]', function () {
48
- var reactionElement = $(this);
49
- var pid = reactionElement.attr('data-pid');
50
- var reaction = reactionElement.attr('data-reaction');
51
- var reacted = reactionElement.hasClass('reacted');
52
- var event = 'plugins.reactions.' + (reacted ? 'removePostReaction' : 'addPostReaction');
48
+ const reactionElement = $(this);
49
+ const pid = reactionElement.attr('data-pid');
50
+ const reaction = reactionElement.attr('data-reaction');
51
+ const reacted = reactionElement.hasClass('reacted');
52
+ const event = 'plugins.reactions.' + (reacted ? 'removePostReaction' : 'addPostReaction');
53
53
  socket.emit(event, {
54
54
  pid: pid,
55
55
  reaction: reaction,
@@ -61,8 +61,8 @@ $(document).ready(function () {
61
61
  });
62
62
 
63
63
  $('[component="topic"]').on('click', '[component="post/reaction/add"]', function () {
64
- var reactionAddEl = $(this);
65
- var pid = reactionAddEl.attr('data-pid');
64
+ const reactionAddEl = $(this);
65
+ const pid = reactionAddEl.attr('data-pid');
66
66
  require(['emoji-dialog'], function (emojiDialog) {
67
67
  emojiDialog.toggle(reactionAddEl[0], function (_, name, dialog) {
68
68
  emojiDialog.dialogActions.close(dialog);
@@ -88,11 +88,11 @@ $(document).ready(function () {
88
88
 
89
89
  const messageContent = container.find('[component="chat/message/content"]');
90
90
  messageContent.on('click', '[component="message/reaction"]', function () {
91
- var reactionElement = $(this);
92
- var mid = reactionElement.attr('data-mid');
93
- var reaction = reactionElement.attr('data-reaction');
94
- var reacted = reactionElement.hasClass('reacted');
95
- var event = 'plugins.reactions.' + (reacted ? 'removeMessageReaction' : 'addMessageReaction');
91
+ const reactionElement = $(this);
92
+ const mid = reactionElement.attr('data-mid');
93
+ const reaction = reactionElement.attr('data-reaction');
94
+ const reacted = reactionElement.hasClass('reacted');
95
+ const event = 'plugins.reactions.' + (reacted ? 'removeMessageReaction' : 'addMessageReaction');
96
96
  socket.emit(event, {
97
97
  mid: mid,
98
98
  reaction: reaction,
@@ -147,10 +147,10 @@ $(document).ready(function () {
147
147
  }
148
148
 
149
149
  function updatePostReactionCount(data, type) {
150
- var maxReactionsReached = parseInt(data.totalReactions, 10) > config.maximumReactions;
150
+ const maxReactionsReached = parseInt(data.totalReactions, 10) > config.maximumReactions;
151
151
  $('[component="post/reaction/add"][data-pid="' + data.pid + '"]').toggleClass('max-reactions', maxReactionsReached);
152
152
 
153
- var reactionEl = $(`[component="post/reaction"][data-pid="${data.pid}"][data-reaction="${data.reaction}"]`);
153
+ const reactionEl = $(`[component="post/reaction"][data-pid="${data.pid}"][data-reaction="${data.reaction}"]`);
154
154
 
155
155
  if (parseInt(data.reactionCount, 10) === 0) {
156
156
  reactionEl.tooltip('dispose');
@@ -179,10 +179,10 @@ $(document).ready(function () {
179
179
  }
180
180
 
181
181
  function updateMessageReactionCount(data, type) {
182
- var maxReactionsReached = parseInt(data.totalReactions, 10) > config.maximumReactionsPerMessage;
182
+ const maxReactionsReached = parseInt(data.totalReactions, 10) > config.maximumReactionsPerMessage;
183
183
  $('[component="message/reaction/add"][data-mid="' + data.mid + '"]').toggleClass('max-reactions', maxReactionsReached);
184
184
 
185
- var reactionEl = $(`[component="message/reaction"][data-mid="${data.mid}"][data-reaction="${data.reaction}"]`);
185
+ const reactionEl = $(`[component="message/reaction"][data-mid="${data.mid}"][data-reaction="${data.reaction}"]`);
186
186
 
187
187
  if (parseInt(data.reactionCount, 10) === 0) {
188
188
  reactionEl.tooltip('dispose');