mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-24 16:29:51 +01:00
feat: add new language string for chat usernames
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
"chat.chatting_with": "Chat with",
|
||||
"chat.placeholder": "Type chat message here, drag & drop images, press enter to send",
|
||||
"chat.scroll-up-alert": "You are looking at older messages, click here to go to most recent message.",
|
||||
"chat.usernames-and-x-others": "%1 & %2 others",
|
||||
"chat.send": "Send",
|
||||
"chat.no_active": "You have no active chats.",
|
||||
"chat.user_typing": "%1 is typing ...",
|
||||
|
||||
@@ -9,6 +9,7 @@ const privileges = require('../privileges');
|
||||
const plugins = require('../plugins');
|
||||
const meta = require('../meta');
|
||||
const utils = require('../utils');
|
||||
const translator = require('../translator');
|
||||
|
||||
const Messaging = module.exports;
|
||||
|
||||
@@ -137,8 +138,18 @@ Messaging.getRecentChats = async (callerUid, uid, start, stop) => {
|
||||
});
|
||||
};
|
||||
|
||||
Messaging.generateUsernames = (users, excludeUid) => users.filter(user => user && parseInt(user.uid, 10) !== excludeUid)
|
||||
.map(user => user.username).join(', ');
|
||||
Messaging.generateUsernames = function (users, excludeUid) {
|
||||
users = users.filter(u => u && parseInt(u.uid, 10) !== excludeUid);
|
||||
const usernames = users.map(u => u.username);
|
||||
if (users.length > 2) {
|
||||
return translator.compile(
|
||||
'modules:chat.usernames-and-x-others',
|
||||
usernames.slice(0, 2).join(', '),
|
||||
usernames.length - 2
|
||||
);
|
||||
}
|
||||
return usernames.join(', ');
|
||||
};
|
||||
|
||||
Messaging.getTeaser = async (uid, roomId) => {
|
||||
const mid = await Messaging.getLatestUndeletedMessage(uid, roomId);
|
||||
|
||||
Reference in New Issue
Block a user