@nodebb/nodebb-plugin-reactions 2.2.9 → 3.0.0

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
@@ -8,6 +8,11 @@ Install via one-click activation in the Admin Control Panel or run the following
8
8
 
9
9
  npm i @nodebb/nodebb-plugin-reactions
10
10
 
11
+ # Emojis in Topic Titles and Notifications
12
+
13
+ In the admin settings of nodebb-plugin-emoji, turn on "Parse emojis in topic titles" to see emojis as images in topic titles and notifications.
14
+ ![](https://private-user-images.githubusercontent.com/2583394/586759879-5b4e6cc9-3568-48fa-a556-83bdb24bd8f2.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Nzc3NDAwNzAsIm5iZiI6MTc3NzczOTc3MCwicGF0aCI6Ii8yNTgzMzk0LzU4Njc1OTg3OS01YjRlNmNjOS0zNTY4LTQ4ZmEtYTU1Ni04M2JkYjI0YmQ4ZjIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDUwMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA1MDJUMTYzNjEwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmJkY2ZhZDE0N2ZiMzRjODMyOGM2ODg1NTlkNWU1NDg5ZmEyNGI1MzlkYjg4ODZlNDFjZWUzNmU0Zjk0ZDUwMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.PoBRMpH7ByDbA-uXoyHAoHFr3eiiN4IYy-Wvqy3p2pM)
15
+
11
16
  # Screenshots
12
17
 
13
18
  ## Reactions:
package/library.js CHANGED
@@ -375,18 +375,18 @@ SocketPlugins.reactions = {
375
375
  }
376
376
 
377
377
  if (postData.uid && postData.uid !== socket.uid) {
378
- const [userData, topicData, parsedPostData] = await Promise.all([
379
- user.getUserFields(socket.uid, ['username', 'fullname']),
380
- topics.getTopicFields(data.tid, ['title']),
378
+ const [displayname, topicTitle, parsedPostData] = await Promise.all([
379
+ user.getNotificationDisplayname(socket.uid),
380
+ topics.getNotificationTitle(data.tid),
381
381
  posts.parsePost(postData),
382
382
  ]);
383
383
  const notifObj = await notifications.create({
384
384
  type: 'reaction',
385
385
  bodyShort: translator.compile(
386
386
  'reactions:notification.user-has-reacted-with-to-your-post-in-topic',
387
- userData.displayname,
387
+ displayname,
388
388
  `:${data.reaction}:`,
389
- topicData.title
389
+ topicTitle
390
390
  ),
391
391
  bodyLong: parsedPostData.content,
392
392
  nid: `uid:${socket.uid}:pid:${data.pid}:reaction:${data.reaction}`,
@@ -560,7 +560,7 @@ SocketPlugins.reactions = {
560
560
  if (!nameToEmoji(data.reaction)) {
561
561
  throw new Error('[[reactions:error.invalid-reaction]]');
562
562
  }
563
- let set = '';
563
+ let set;
564
564
  if (data.type === 'post') {
565
565
  if (!await privileges.posts.can('topics:read', data.pid, socket.uid)) {
566
566
  throw new Error('[[error:not-allowed]]');
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nodebb/nodebb-plugin-reactions",
3
- "version": "2.2.9",
3
+ "version": "3.0.0",
4
4
  "nbbpm": {
5
- "compatibility": "^3.6.0 || ^4.0.0"
5
+ "compatibility": "^4.14.0"
6
6
  },
7
7
  "description": "Reactions plugin for NodeBB",
8
8
  "main": "library.js",
@@ -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');
@@ -1,10 +1,10 @@
1
1
  <form>
2
- <div class="form-group">
3
- <label for="reaction">[[reactions:settings.reaction-reputations.reaction]]</label>
2
+ <div class="mb-3">
3
+ <label class="form-label" for="reaction">[[reactions:settings.reaction-reputations.reaction]]</label>
4
4
  <input type="text" id="reaction" name="reaction" class="form-control" placeholder="[[reactions:settings.reaction-reputations.reaction]]" />
5
5
  </div>
6
- <div class="form-group">
7
- <label for="reputation">[[reactions:settings.reaction-reputations.reputation]]</label>
6
+ <div class="mb-3">
7
+ <label class="form-label" for="reputation">[[reactions:settings.reaction-reputations.reputation]]</label>
8
8
  <input type="number" id="reputation" name="reputation" class="form-control" placeholder="[[reactions:settings.reaction-reputations.reputation]]" />
9
9
  </div>
10
10
  </form>
@@ -1,12 +1,12 @@
1
1
  <li data-type="item" class="list-group-item">
2
- <div class="row">
3
- <div class="col-xs-9">
2
+ <div class="row align-items-center">
3
+ <div class="col-9">
4
4
  <span data-reaction="{reaction}"></span><strong> {reaction}</strong><br />
5
- <small>[[reactions:settings.reaction-reputations.reaction]]: {reputation}</small>
5
+ <small>[[reactions:settings.reaction-reputations.reputation]]: {reputation}</small>
6
6
  </div>
7
- <div class="col-xs-3 text-right">
8
- <button type="button" data-type="edit" class="btn btn-info">[[reactions:settings.reaction-reputations.edit]]</button>
9
- <button type="button" data-type="remove" class="btn btn-danger">[[reactions:settings.reaction-reputations.remove]]</button>
7
+ <div class="col-3 d-flex gap-2">
8
+ <button type="button" data-type="edit" class="btn btn-sm btn-info">[[reactions:settings.reaction-reputations.edit]]</button>
9
+ <button type="button" data-type="remove" class="btn btn-sm btn-danger">[[reactions:settings.reaction-reputations.remove]]</button>
10
10
  </div>
11
11
  </div>
12
12
  </li>
@@ -1,4 +1,4 @@
1
1
  <span class="reaction mb-2 {{{ if ./reacted }}}reacted{{{ end }}}" component="message/reaction" data-mid="{./mid}" data-reaction="{./reaction}">
2
- {./reactionImage}
2
+ {{./reactionImage}}
3
3
  <small class="reaction-emoji-count" data-count="{./reactionCount}"></small>
4
4
  </span>
@@ -1,4 +1,4 @@
1
1
  <span class="reaction {{{ if ./reacted }}}reacted{{{ end }}}" component="post/reaction" data-pid="{./pid}" data-reaction="{./reaction}">
2
- {./reactionImage}
2
+ {{./reactionImage}}
3
3
  <small class="reaction-emoji-count" data-count="{./reactionCount}"></small>
4
4
  </span>