@nodebb/nodebb-plugin-reactions 2.1.12 → 2.1.14
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/languages/de/reactions.json +25 -0
- package/languages/en-GB/reactions.json +3 -1
- package/library.js +58 -5
- package/package.json +1 -1
- package/lib/.eslintrc +0 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"reactions": "Reaktionen",
|
|
3
|
+
"add-reaction": "Reaktion hinzufügen",
|
|
4
|
+
"error.invalid-reaction": "Ungültige Reaktion",
|
|
5
|
+
"error.maximum-reached": "Maximale Reaktionen erreicht",
|
|
6
|
+
"error.maximum-per-user-per-post-reached": "Maximale Reaktionen pro Nutzer und Beitrag erreicht",
|
|
7
|
+
"settings.title": "Plugin-Einstellungen für Reaktionen",
|
|
8
|
+
"settings.enable-post-reactions": "Reaktionen auf Posts aktivieren",
|
|
9
|
+
"settings.max-reactions-per-post": "Maximale eindeutige Reaktionen pro Beitrag (0 für unbegrenzt, Standard: 4)",
|
|
10
|
+
"settings.max-reactions-per-user-per-post": "Maximale Reaktionen pro Nutzer und Beitrag (0 für unbegrenzt)",
|
|
11
|
+
"settings.max-reactions-per-user-per-post-help": "Der Grenzwert wird nur beim Hinzufügen einer neuen Reaktion und nicht beim Hinzufügen zu einer bestehenden Reaktion eingehalten.",
|
|
12
|
+
"settings.enable-message-reactions": "Reaktionen auf Nachrichten aktivieren",
|
|
13
|
+
"settings.max-reactions-per-message": "Maximale eindeutige Reaktionen pro Nachricht (0 für unbegrenzt, Standard: 4)",
|
|
14
|
+
"settings.max-reactions-per-user-per-message": "Maximale Reaktionen pro Benutzer und Nachricht (0 für unbegrenzt)",
|
|
15
|
+
"settings.max-reactions-per-user-per-message-help": "Der Grenzwert wird nur beim Hinzufügen einer neuen Reaktion und nicht beim Hinzufügen zu einer bestehenden Reaktion eingehalten.",
|
|
16
|
+
"settings.reaction-reputations": "Reaktion Ansehen (optional)",
|
|
17
|
+
"settings.reaction-reputations-help": "Sie können den einzelnen Reaktionen Ansehen zuweisen. Wenn eine Reaktion auf einen Beitrag angewendet wird, erhält der Eigentümer dieses Beitrags dieses Ansehen.",
|
|
18
|
+
"settings.reaction-reputations.add": "Regel hinzufügen",
|
|
19
|
+
"settings.reaction-reputations.reaction": "Reaktion",
|
|
20
|
+
"settings.reaction-reputations.reputation": "Ansehen",
|
|
21
|
+
"settings.reaction-reputations.remove": "Löschen",
|
|
22
|
+
"settings.reaction-reputations.edit": "Bearbeiten",
|
|
23
|
+
"notification.user-has-reacted-with-to-your-post-in-topic": "<strong>%1</strong> hat mit %2 auf deinen Beitrag in <strong>%3</strong> reagiert",
|
|
24
|
+
"notification.user-has-reacted-with-to-your-message-in-room": "<strong>%1</strong> hat mit %2 auf deine Nachricht in <strong class=\"text-nowrap\"><i class=\"fa %3\"></i>%4</strong> reagiert"
|
|
25
|
+
}
|
|
@@ -19,5 +19,7 @@
|
|
|
19
19
|
"settings.reaction-reputations.reaction": "Reaction",
|
|
20
20
|
"settings.reaction-reputations.reputation": "Reputation",
|
|
21
21
|
"settings.reaction-reputations.remove": "Delete",
|
|
22
|
-
"settings.reaction-reputations.edit": "Edit"
|
|
22
|
+
"settings.reaction-reputations.edit": "Edit",
|
|
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>"
|
|
23
25
|
}
|
package/library.js
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
const meta = require.main.require('./src/meta');
|
|
4
4
|
const user = require.main.require('./src/user');
|
|
5
5
|
const posts = require.main.require('./src/posts');
|
|
6
|
+
const topics = require.main.require('./src/topics');
|
|
6
7
|
const messaging = require.main.require('./src/messaging');
|
|
7
8
|
const privileges = require.main.require('./src/privileges');
|
|
8
9
|
const db = require.main.require('./src/database');
|
|
10
|
+
const translator = require.main.require('./src/translator');
|
|
11
|
+
const notifications = require.main.require('./src/notifications');
|
|
9
12
|
const routesHelpers = require.main.require('./src/routes/helpers');
|
|
10
13
|
const websockets = require.main.require('./src/socket.io/index');
|
|
11
14
|
const SocketPlugins = require.main.require('./src/socket.io/plugins');
|
|
@@ -316,13 +319,14 @@ SocketPlugins.reactions = {
|
|
|
316
319
|
throw new Error('[[error:post-reactions-disabled]]');
|
|
317
320
|
}
|
|
318
321
|
const maximumReactions = settings.maximumReactions || DEFAULT_MAX_EMOTES;
|
|
319
|
-
const [
|
|
320
|
-
posts.
|
|
322
|
+
const [postData, totalReactions, emojiIsAlreadyExist, alreadyReacted, reactionReputation] = await Promise.all([
|
|
323
|
+
posts.getPostFields(data.pid, ['tid', 'uid']),
|
|
321
324
|
db.setCount(`pid:${data.pid}:reactions`),
|
|
322
325
|
db.isSetMember(`pid:${data.pid}:reactions`, data.reaction),
|
|
323
326
|
db.isSetMember(`pid:${data.pid}:reaction:${data.reaction}`, socket.uid),
|
|
324
327
|
getReactionReputation(data.reaction),
|
|
325
328
|
]);
|
|
329
|
+
const { tid } = postData;
|
|
326
330
|
if (!tid) {
|
|
327
331
|
throw new Error('[[error:no-post]]');
|
|
328
332
|
}
|
|
@@ -354,6 +358,28 @@ SocketPlugins.reactions = {
|
|
|
354
358
|
await giveOwnerReactionReputation(reactionReputation, data.pid);
|
|
355
359
|
}
|
|
356
360
|
|
|
361
|
+
if (postData.uid && postData.uid !== socket.uid) {
|
|
362
|
+
const [userData, topicData] = await Promise.all([
|
|
363
|
+
user.getUserFields(socket.uid, ['username', 'fullname']),
|
|
364
|
+
topics.getTopicFields(data.tid, ['title']),
|
|
365
|
+
]);
|
|
366
|
+
const notifObj = await notifications.create({
|
|
367
|
+
bodyShort: translator.compile(
|
|
368
|
+
'reactions:notification.user-has-reacted-with-to-your-post-in-topic',
|
|
369
|
+
userData.displayname,
|
|
370
|
+
`:${data.reaction}:`,
|
|
371
|
+
topicData.title
|
|
372
|
+
),
|
|
373
|
+
nid: `uid:${socket.uid}:pid:${data.pid}:reaction:${data.reaction}`,
|
|
374
|
+
pid: data.pid,
|
|
375
|
+
tid: data.tid,
|
|
376
|
+
from: socket.uid,
|
|
377
|
+
path: `/post/${data.pid}`,
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
await notifications.push(notifObj, [postData.uid]);
|
|
381
|
+
}
|
|
382
|
+
|
|
357
383
|
await sendPostEvent(data, 'event:reactions.addPostReaction');
|
|
358
384
|
},
|
|
359
385
|
removePostReaction: async function (socket, data) {
|
|
@@ -408,12 +434,12 @@ SocketPlugins.reactions = {
|
|
|
408
434
|
throw new Error('[[error:post-reactions-disabled]]');
|
|
409
435
|
}
|
|
410
436
|
const maximumReactionsPerMessage = settings.maximumReactionsPerMessage || DEFAULT_MAX_EMOTES;
|
|
411
|
-
const [
|
|
412
|
-
messaging.
|
|
437
|
+
const [msgData, totalReactions, emojiIsAlreadyExist] = await Promise.all([
|
|
438
|
+
messaging.getMessageFields(data.mid, ['roomId', 'fromuid']),
|
|
413
439
|
db.setCount(`mid:${data.mid}:reactions`),
|
|
414
440
|
db.isSetMember(`mid:${data.mid}:reactions`, data.reaction),
|
|
415
441
|
]);
|
|
416
|
-
|
|
442
|
+
const { roomId } = msgData;
|
|
417
443
|
if (!roomId) {
|
|
418
444
|
throw new Error('[[error:no-message]]');
|
|
419
445
|
}
|
|
@@ -443,6 +469,33 @@ SocketPlugins.reactions = {
|
|
|
443
469
|
db.setAdd(`mid:${data.mid}:reaction:${data.reaction}`, socket.uid),
|
|
444
470
|
]);
|
|
445
471
|
|
|
472
|
+
if (msgData.fromuid && msgData.fromuid !== socket.uid) {
|
|
473
|
+
const [userData, roomData] = await Promise.all([
|
|
474
|
+
user.getUserFields(socket.uid, ['username', 'userslug', 'fullname']),
|
|
475
|
+
messaging.getRoomData(roomId),
|
|
476
|
+
]);
|
|
477
|
+
const roomName = roomData.roomName || `[[modules:chat.room-id, ${roomId}]]`;
|
|
478
|
+
const icon = messaging.getRoomIcon(roomData);
|
|
479
|
+
|
|
480
|
+
const notifObj = await notifications.create({
|
|
481
|
+
bodyShort: translator.compile(
|
|
482
|
+
'reactions:notification.user-has-reacted-with-to-your-message-in-room',
|
|
483
|
+
userData.displayname,
|
|
484
|
+
`:${data.reaction}:`,
|
|
485
|
+
icon,
|
|
486
|
+
roomName
|
|
487
|
+
),
|
|
488
|
+
roomIcon: icon,
|
|
489
|
+
nid: `uid:${socket.uid}:mid:${data.mid}:reaction:${data.reaction}`,
|
|
490
|
+
mid: data.mid,
|
|
491
|
+
roomId: roomId,
|
|
492
|
+
from: socket.uid,
|
|
493
|
+
path: `/chats/${roomId}`,
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
await notifications.push(notifObj, [msgData.fromuid]);
|
|
497
|
+
}
|
|
498
|
+
|
|
446
499
|
await sendMessageEvent(data, 'event:reactions.addMessageReaction');
|
|
447
500
|
},
|
|
448
501
|
removeMessageReaction: async function (socket, data) {
|
package/package.json
CHANGED
package/lib/.eslintrc
DELETED