@nodebb/nodebb-plugin-reactions 2.1.16 → 2.2.1

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.
Files changed (3) hide show
  1. package/README.md +5 -0
  2. package/library.js +36 -32
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # nodebb-plugin-reactions
2
2
  Reactions plugin for NodeBB
3
3
 
4
+ # Installation
5
+ Install via one-click activation in the Admin Control Panel or run the following command:
6
+
7
+ npm i @nodebb/nodebb-plugin-reactions
8
+
4
9
  # Screenshots
5
10
 
6
11
  ## Reactions:
package/library.js CHANGED
@@ -119,22 +119,24 @@ ReactionsPlugin.getPostReactions = async function (data) {
119
119
  const reactionSetToUsersMap = await getReactionSetsUidsMap(reactionSets);
120
120
 
121
121
  for (const post of data.posts) {
122
- post.maxReactionsReached = pidToIsMaxReactionsReachedMap.get(post.pid);
123
- post.reactions = [];
124
-
125
- const reactions = pidToReactionsMap.get(post.pid);
126
- if (reactions) {
127
- for (const reaction of reactions) {
128
- const reactionSet = `pid:${post.pid}:reaction:${reaction}`;
129
- const uids = reactionSetToUsersMap.get(reactionSet);
130
- if (Array.isArray(uids)) {
131
- post.reactions.push({
132
- pid: post.pid,
133
- reacted: uids.includes(String(data.uid)),
134
- reaction,
135
- reactionImage: parse(reaction),
136
- reactionCount: uids.length,
137
- });
122
+ if (post) {
123
+ post.maxReactionsReached = pidToIsMaxReactionsReachedMap.get(post.pid);
124
+ post.reactions = [];
125
+
126
+ const reactions = pidToReactionsMap.get(post.pid);
127
+ if (reactions) {
128
+ for (const reaction of reactions) {
129
+ const reactionSet = `pid:${post.pid}:reaction:${reaction}`;
130
+ const uids = reactionSetToUsersMap.get(reactionSet);
131
+ if (Array.isArray(uids)) {
132
+ post.reactions.push({
133
+ pid: post.pid,
134
+ reacted: uids.includes(String(data.uid)),
135
+ reaction,
136
+ reactionImage: parse(reaction),
137
+ reactionCount: uids.length,
138
+ });
139
+ }
138
140
  }
139
141
  }
140
142
  }
@@ -179,21 +181,23 @@ ReactionsPlugin.getMessageReactions = async function (data) {
179
181
  const reactionSetToUsersMap = await getReactionSetsUidsMap(reactionSets);
180
182
 
181
183
  for (const msg of data.messages) {
182
- msg.maxReactionsReached = midToIsMaxReactionsReachedMap.get(msg.mid);
183
- msg.reactions = [];
184
- const reactions = midToReactionsMap.get(msg.mid);
185
- if (reactions) {
186
- for (const reaction of reactions) {
187
- const reactionSet = `mid:${msg.mid}:reaction:${reaction}`;
188
- const uids = reactionSetToUsersMap.get(reactionSet);
189
- if (Array.isArray(uids)) {
190
- msg.reactions.push({
191
- mid: msg.mid,
192
- reacted: uids.includes(String(data.uid)),
193
- reaction,
194
- reactionImage: parse(reaction),
195
- reactionCount: uids.length,
196
- });
184
+ if (msg) {
185
+ msg.maxReactionsReached = midToIsMaxReactionsReachedMap.get(msg.mid);
186
+ msg.reactions = [];
187
+ const reactions = midToReactionsMap.get(msg.mid);
188
+ if (reactions) {
189
+ for (const reaction of reactions) {
190
+ const reactionSet = `mid:${msg.mid}:reaction:${reaction}`;
191
+ const uids = reactionSetToUsersMap.get(reactionSet);
192
+ if (Array.isArray(uids)) {
193
+ msg.reactions.push({
194
+ mid: msg.mid,
195
+ reacted: uids.includes(String(data.uid)),
196
+ reaction,
197
+ reactionImage: parse(reaction),
198
+ reactionCount: uids.length,
199
+ });
200
+ }
197
201
  }
198
202
  }
199
203
  }
@@ -490,7 +494,7 @@ SocketPlugins.reactions = {
490
494
  mid: data.mid,
491
495
  roomId: roomId,
492
496
  from: socket.uid,
493
- path: `/chats/${roomId}`,
497
+ path: `/message/${data.mid}`,
494
498
  });
495
499
 
496
500
  await notifications.push(notifObj, [msgData.fromuid]);
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nodebb/nodebb-plugin-reactions",
3
- "version": "2.1.16",
3
+ "version": "2.2.1",
4
4
  "nbbpm": {
5
- "compatibility": "^3.3.0"
5
+ "compatibility": "^3.6.0"
6
6
  },
7
7
  "description": "Reactions plugin for NodeBB",
8
8
  "main": "library.js",