Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Add "User left team" message type #22109

Merged
merged 4 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/lib/lib/MessageTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ Meteor.startup(function() {
};
},
});
MessageTypes.registerType({
id: 'ult',
system: true,
message: 'User_left_team',
data(message) {
return {
user_left: message.u.username,
};
},
});
MessageTypes.registerType({
id: 'uj',
system: true,
Expand All @@ -57,6 +67,16 @@ Meteor.startup(function() {
};
},
});
MessageTypes.registerType({
id: 'ujt',
system: true,
message: 'User_joined_team',
data(message) {
return {
user: message.u.username,
};
},
});
MessageTypes.registerType({
id: 'ut',
system: true,
Expand Down
2 changes: 2 additions & 0 deletions app/lib/server/functions/addUserToRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export const addUserToRoom = function(rid, user, inviter, silenced) {
});
} else if (room.prid) {
Messages.createUserJoinWithRoomIdAndUserDiscussion(rid, user, { ts: now });
} else if (room.teamMain) {
Messages.createUserJoinTeamWithRoomIdAndUser(rid, user, { ts: now });
} else {
Messages.createUserJoinWithRoomIdAndUser(rid, user, { ts: now });
}
Expand Down
2 changes: 2 additions & 0 deletions app/lib/server/functions/removeUserFromRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export const removeUserFromRoom = function(rid, user, options = {}) {
Messages.createUserRemovedWithRoomIdAndUser(rid, user, {
u: options.byUser,
});
} else if (room.teamMain) {
Messages.createUserLeaveTeamWithRoomIdAndUser(rid, removedUser);
} else {
Messages.createUserLeaveWithRoomIdAndUser(rid, removedUser);
}
Expand Down
10 changes: 10 additions & 0 deletions app/models/server/models/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,11 @@ export class Messages extends Base {
return this.createWithTypeRoomIdMessageAndUser('uj', roomId, message, user, extraData);
}

createUserJoinTeamWithRoomIdAndUser(roomId, user, extraData) {
const message = user.username;
return this.createWithTypeRoomIdMessageAndUser('ujt', roomId, message, user, extraData);
}

createUserJoinWithRoomIdAndUserDiscussion(roomId, user, extraData) {
const message = user.username;
return this.createWithTypeRoomIdMessageAndUser('ut', roomId, message, user, extraData);
Expand All @@ -871,6 +876,11 @@ export class Messages extends Base {
return this.createWithTypeRoomIdMessageAndUser('ul', roomId, message, user, extraData);
}

createUserLeaveTeamWithRoomIdAndUser(roomId, user, extraData) {
const message = user.username;
return this.createWithTypeRoomIdMessageAndUser('ult', roomId, message, user, extraData);
}

createUserRemovedWithRoomIdAndUser(roomId, user, extraData) {
const message = user.username;
return this.createWithTypeRoomIdMessageAndUser('ru', roomId, message, user, extraData);
Expand Down
3 changes: 3 additions & 0 deletions app/user-data-download/server/cronProcessDownloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ const getMessageData = function(msg, hideUsers, userData, usersMap) {
case 'ul':
messageObject.msg = TAPi18n.__('User_left');
break;
case 'ult':
messageObject.msg = TAPi18n.__('User_left_team');
break;
case 'au':
messageObject.msg = TAPi18n.__('User_added_by', { user_added: hideUserName(msg.msg, userData, usersMap), user_by: username });
break;
Expand Down
6 changes: 6 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4215,9 +4215,15 @@
"User_joined_channel_female": "Has joined the channel.",
"User_joined_channel_male": "Has joined the channel.",
"User_joined_conversation": "Has joined the conversation",
"User_joined_team": "Has joined the team.",
"User_joined_team_female": "Has joined the team.",
"User_joined_team_male": "Has joined the team.",
"User_left": "Has left the channel.",
"User_left_female": "Has left the channel.",
"User_left_male": "Has left the channel.",
"User_left_team": "Has left the team.",
"User_left_team_female": "Has left the team.",
"User_left_team_male": "Has left the team.",
"User_logged_out": "User is logged out",
"User_management": "User Management",
"User_mentions_only": "User mentions only",
Expand Down
6 changes: 6 additions & 0 deletions packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3435,9 +3435,15 @@
"User_joined_channel_female": "Entrou no canal.",
"User_joined_channel_male": "Entrou no canal.",
"User_joined_conversation": "Entrou na conversa",
"User_joined_team": "Entrou no time.",
"User_joined_team_female": "Entrou no time.",
"User_joined_team_male": "Entrou no time.",
"User_left": "Saiu da conversa.",
"User_left_female": "Saiu da conversa.",
"User_left_male": "Saiu da conversa.",
"User_left_team": "Saiu do time.",
"User_left_team_female": "Saiu do time.",
"User_left_team_male": "Saiu do time.",
"User_logged_out": "Usuário não logado",
"User_management": "Gerenciamento de usuários",
"User_mentions_only": "O usuário menciona apenas",
Expand Down
6 changes: 6 additions & 0 deletions packages/rocketchat-i18n/i18n/pt.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3051,9 +3051,15 @@
"User_joined_channel_female": "Entrou no canal.",
"User_joined_channel_male": "Entrou no canal.",
"User_joined_conversation": "Entrou na conversa",
"User_joined_team": "Entrou no time.",
"User_joined_team_female": "Entrou no time.",
"User_joined_team_male": "Entrou no time.",
"User_left": "Saiu do canal.",
"User_left_female": "Saiu da canal.",
"User_left_male": "Saiu da canal.",
"User_left_team": "Saiu do time.",
"User_left_team_female": "Saiu do time.",
"User_left_team_male": "Saiu do time.",
"User_logged_out": "Utilizador não conectado",
"User_management": "Administração de utilizadores",
"User_mentions_only": "O utilizador menciona apenas",
Expand Down