nodebb-plugin-admin-chats 1.0.1 → 1.0.2
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/library.js +10 -4
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -89,7 +89,6 @@ plugin.canGetPublicChats = async function (payload) {
|
|
|
89
89
|
plugin.onLoadRoom = async function (payload) {
|
|
90
90
|
const { uid, room } = payload;
|
|
91
91
|
const isAdmin = await User.isAdministrator(uid);
|
|
92
|
-
|
|
93
92
|
if (!isAdmin || !room) return payload;
|
|
94
93
|
|
|
95
94
|
const isOfficialMember = await db.isSortedSetMember(`chat:room:${room.roomId}:uids`, uid);
|
|
@@ -100,7 +99,6 @@ plugin.onLoadRoom = async function (payload) {
|
|
|
100
99
|
if (Array.isArray(room.users)) {
|
|
101
100
|
room.users = room.users.filter(user => user && parseInt(user.uid, 10) !== parseInt(uid, 10));
|
|
102
101
|
}
|
|
103
|
-
|
|
104
102
|
if (room.userCount > 0) {
|
|
105
103
|
room.userCount -= 1;
|
|
106
104
|
}
|
|
@@ -118,14 +116,22 @@ plugin.onLoadRoom = async function (payload) {
|
|
|
118
116
|
});
|
|
119
117
|
|
|
120
118
|
room.messages = messages.reverse();
|
|
121
|
-
}
|
|
122
119
|
|
|
120
|
+
room.messages.forEach((msg, index) => {
|
|
121
|
+
if (index === 0) {
|
|
122
|
+
msg.newSet = true;
|
|
123
|
+
} else {
|
|
124
|
+
const prevMsg = room.messages[index - 1];
|
|
125
|
+
msg.newSet = parseInt(msg.fromuid, 10) !== parseInt(prevMsg.fromuid, 10);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
123
130
|
room.isAdmin = true;
|
|
124
131
|
room.isOwner = true;
|
|
125
132
|
} else {
|
|
126
133
|
room.isAdmin = true;
|
|
127
134
|
}
|
|
128
|
-
|
|
129
135
|
return payload;
|
|
130
136
|
};
|
|
131
137
|
|