@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.
- package/README.md +5 -0
- package/library.js +36 -32
- package/package.json +2 -2
package/README.md
CHANGED
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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: `/
|
|
497
|
+
path: `/message/${data.mid}`,
|
|
494
498
|
});
|
|
495
499
|
|
|
496
500
|
await notifications.push(notifObj, [msgData.fromuid]);
|
package/package.json
CHANGED