From c0a205d55e9a5d4b7548f6826406c8f8b7c6c78a Mon Sep 17 00:00:00 2001 From: Leonardo Ostjen Couto Date: Tue, 18 Jan 2022 16:00:20 -0300 Subject: [PATCH 01/11] improved some system message texts --- packages/rocketchat-i18n/i18n/en.i18n.json | 10 +++------- packages/rocketchat-i18n/i18n/pt-BR.i18n.json | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 9c712fc1ade9..ff5901afcfbb 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1001,7 +1001,7 @@ "Conversations_per_day": "Conversations per Day", "Convert": "Convert", "Convert_Ascii_Emojis": "Convert ASCII to Emoji", - "Converting_channel_to_a_team": "You are converting this Channel to a Team. All members will be kept.", + "Converting_channel_to_a_team": "This can't be undone. Once you convert a Channel to a Team, you can not turn it back to a Channel.", "Copied": "Copied", "Copy": "Copy", "Copy_text": "Copy Text", @@ -2321,7 +2321,7 @@ "Invite_user_to_join_channel": "Invite one user to join this channel", "Invite_user_to_join_channel_all_from": "Invite all users from [#channel] to join this channel", "Invite_user_to_join_channel_all_to": "Invite all users from this channel to join [#channel]", - "Invite_Users": "Invite Users", + "Invite_Users": "Invite Members", "IP": "IP", "IRC_Channel_Join": "Output of the JOIN command.", "IRC_Channel_Leave": "Output of the PART command.", @@ -4460,11 +4460,7 @@ "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_left_team": "left the team.", "User_logged_out": "User is logged out", "User_management": "User Management", "User_mentions_only": "User mentions only", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index bbc5b76b274f..a5546c4c630d 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -1001,7 +1001,7 @@ "Conversations_per_day": "Conversas por dia", "Convert": "Converter", "Convert_Ascii_Emojis": "Converter ASCII para Emoji", - "Converting_channel_to_a_team": "Você está convertendo esse Canal para uma Equipe. Todos os membros serão mantidos.", + "Converting_channel_to_a_team": " Esta ação não pode ser desfeita. Uma vez que convertido a um time, não é possível converter de volta a um canal.", "Copied": "Copiado", "Copy": "Copiar", "Copy_text": "Copiar Texto", @@ -2318,7 +2318,7 @@ "Invite_user_to_join_channel": "Convidar um usuário para este canal", "Invite_user_to_join_channel_all_from": "Convide todos os usuários de [#channel] a participar deste canal", "Invite_user_to_join_channel_all_to": "Convide todos os usuários deste canal a participar [#canal]", - "Invite_Users": "Convidar Usuários", + "Invite_Users": "Convidar Membros", "IP": "IP", "IRC_Channel_Join": "Saída do comando JOIN.", "IRC_Channel_Leave": "Saída do comando PART.", From 8c2d78104099dfe4d49fe30d732a48b18e1a9352 Mon Sep 17 00:00:00 2001 From: dougfabris Date: Thu, 27 Jan 2022 16:40:12 -0300 Subject: [PATCH 02/11] wip --- app/api/server/v1/channels.js | 23 +++++++-- app/api/server/v1/teams.ts | 8 ++- app/lib/lib/MessageTypes.js | 50 +++++++++++++++++++ app/models/server/models/Messages.js | 16 ++++++ app/ui-message/client/message.html | 7 +++ .../server/cronProcessDownloads.js | 5 ++ .../Info/RoomInfo/RoomInfoWithData.js | 2 +- packages/rocketchat-i18n/i18n/en.i18n.json | 11 ++-- 8 files changed, 114 insertions(+), 8 deletions(-) diff --git a/app/api/server/v1/channels.js b/app/api/server/v1/channels.js index 24b3da99e45f..d00d1963d9c5 100644 --- a/app/api/server/v1/channels.js +++ b/app/api/server/v1/channels.js @@ -296,7 +296,15 @@ API.v1.addRoute( bodyParams.members = [...membersToAdd]; } - return API.v1.success(API.channels.create.execute(userId, bodyParams)); + const { channel } = API.channels.create.execute(userId, bodyParams); + + if (bodyParams.extraData.teamId) { + const user = Meteor.users.findOne(this.userId); + const team = Promise.await(Team.getOneById(bodyParams.extraData.teamId)); + Messages.createUserAddRoomToTeamWithRoomIdAndUser(team.roomId, channel.name, user); + } + + return API.v1.success({ channel }); }, }, ); @@ -306,13 +314,19 @@ API.v1.addRoute( { authRequired: true }, { post() { - const findResult = findChannelByIdOrName({ + const room = findChannelByIdOrName({ params: this.requestParams(), checkedArchived: false, }); + if (room.teamId) { + const team = Promise.await(Team.getOneById(room.teamId)); + const user = Meteor.users.findOne(this.userId); + Messages.createUserDeleteRoomFromTeamWithRoomIdAndUser(team.roomId, room.name, user); + } + Meteor.runAsUser(this.userId, () => { - Meteor.call('eraseRoom', findResult._id); + Meteor.call('eraseRoom', room._id); }); return API.v1.success(); @@ -1388,6 +1402,9 @@ API.v1.addRoute( const team = Promise.await(Team.create(this.userId, teamData)); + const user = Meteor.users.findOne(this.userId); + Messages.createUserConvertChannelInTeamWithRoomIdAndUser(room._id, room.name, user); + return API.v1.success({ team }); }, }, diff --git a/app/api/server/v1/teams.ts b/app/api/server/v1/teams.ts index 4407071d31cc..cdb3d2d3b891 100644 --- a/app/api/server/v1/teams.ts +++ b/app/api/server/v1/teams.ts @@ -6,7 +6,7 @@ import { escapeRegExp } from '@rocket.chat/string-helpers'; import { API } from '../api'; import { Team } from '../../../../server/sdk'; import { hasAtLeastOnePermission, hasPermission } from '../../../authorization/server'; -import { Users } from '../../../models/server'; +import { Users, Messages } from '../../../models/server'; import { removeUserFromRoom } from '../../../lib/server/functions/removeUserFromRoom'; import { IUser } from '../../../../definition/IUser'; import { isTeamsConvertToChannelProps } from '../../../../definition/rest/v1/teams/TeamsConvertToChannelProps'; @@ -183,6 +183,9 @@ API.v1.addRoute( const { rooms } = this.bodyParams; const validRooms = await Team.addRooms(this.userId, rooms, team._id); + const user = Meteor.users.findOne(this.userId); + + validRooms?.length > 0 && validRooms.map((room) => Messages.createUserAddRoomToTeamWithRoomIdAndUser(team.roomId, room.name, user)); return API.v1.success({ rooms: validRooms }); }, @@ -213,6 +216,9 @@ API.v1.addRoute( const room = await Team.removeRoom(this.userId, roomId, team._id, canRemoveAny); + const user = Meteor.users.findOne(this.userId); + Messages.createUserRemoveRoomFromTeamWithRoomIdAndUser(team.roomId, room.name, user); + return API.v1.success({ room }); }, }, diff --git a/app/lib/lib/MessageTypes.js b/app/lib/lib/MessageTypes.js index 19bcc537dd72..8ac9a4fa939a 100644 --- a/app/lib/lib/MessageTypes.js +++ b/app/lib/lib/MessageTypes.js @@ -57,6 +57,56 @@ Meteor.startup(function () { }; }, }); + MessageTypes.registerType({ + id: 'userConvertToTeam', + system: true, + message: 'Converted__roomName__to_team', + data(message) { + return { + roomName: message.msg, + }; + }, + }); + MessageTypes.registerType({ + id: 'userRemoveRoomFromTeam', + system: true, + message: 'Removed__roomName__from_this_team', + data(message) { + return { + roomName: message.msg, + }; + }, + }); + MessageTypes.registerType({ + id: 'userRemoveRoomFromTeam', + system: true, + message: 'Removed__roomName__from_this_team', + data(message) { + return { + roomName: message.msg, + }; + }, + }); + MessageTypes.registerType({ + id: 'userDeleteRoomFromTeam', + system: true, + message: 'Deleted__roomName__', + data(message) { + return { + roomName: message.msg, + }; + }, + }); + MessageTypes.registerType({ + id: 'userAddRoomToTeam', + system: true, + message: 'added__roomName__to_team', + data(message) { + return { + roomName: message.msg, + }; + }, + }); MessageTypes.registerType({ id: 'uj', system: true, diff --git a/app/models/server/models/Messages.js b/app/models/server/models/Messages.js index 9b7f3b708dff..67552b3e4c45 100644 --- a/app/models/server/models/Messages.js +++ b/app/models/server/models/Messages.js @@ -911,6 +911,22 @@ export class Messages extends Base { return this.createWithTypeRoomIdMessageAndUser('ult', roomId, message, user, extraData); } + createUserConvertChannelInTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { + return this.createWithTypeRoomIdMessageAndUser('userConvertToTeam', roomId, roomName, user, extraData); + } + + createUserRemoveRoomFromTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { + return this.createWithTypeRoomIdMessageAndUser('userRemoveRoomFromTeam', roomId, roomName, user, extraData); + } + + createUserDeleteRoomFromTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { + return this.createWithTypeRoomIdMessageAndUser('userDeleteRoomFromTeam', roomId, roomName, user, extraData); + } + + createUserAddRoomToTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { + return this.createWithTypeRoomIdMessageAndUser('userAddRoomToTeam', roomId, roomName, user, extraData); + } + createUserRemovedWithRoomIdAndUser(roomId, user, extraData) { const message = user.username; return this.createWithTypeRoomIdMessageAndUser('ru', roomId, message, user, extraData); diff --git a/app/ui-message/client/message.html b/app/ui-message/client/message.html index b94d7a22e262..e7c563c3cc4f 100644 --- a/app/ui-message/client/message.html +++ b/app/ui-message/client/message.html @@ -49,7 +49,9 @@ {{#if isBot}} {{_ "Bot"}} {{/if}} + {{#unless system}} + {{/unless}} {{#if showTranslated}} @@ -111,6 +113,11 @@ {{> messageLocation location=msg.location}} {{/if}} + {{#if system}} +
+ +
+ {{/if}} {{#if hasOembed}} diff --git a/app/user-data-download/server/cronProcessDownloads.js b/app/user-data-download/server/cronProcessDownloads.js index e4b5df7a4a2a..4ee3aaa1d8bc 100644 --- a/app/user-data-download/server/cronProcessDownloads.js +++ b/app/user-data-download/server/cronProcessDownloads.js @@ -165,6 +165,11 @@ const getMessageData = function (msg, hideUsers, userData, usersMap) { case 'ult': messageObject.msg = TAPi18n.__('User_left_team'); break; + case 'userConvertToTeam': + messageObject.msg = TAPi18n.__('Converted__roomName__to_team', { + roomName: msg.msg, + }); + break; case 'au': messageObject.msg = TAPi18n.__('User_added_by', { user_added: hideUserName(msg.msg, userData, usersMap), diff --git a/client/views/room/contextualBar/Info/RoomInfo/RoomInfoWithData.js b/client/views/room/contextualBar/Info/RoomInfo/RoomInfoWithData.js index 18123cf657a6..fd07b31967a7 100644 --- a/client/views/room/contextualBar/Info/RoomInfo/RoomInfoWithData.js +++ b/client/views/room/contextualBar/Info/RoomInfo/RoomInfoWithData.js @@ -57,7 +57,7 @@ const RoomInfoWithData = ({ rid, openEditing, onClickBack, onEnterRoom, resetSta const leaveRoom = useMethod('leaveRoom'); const router = useRoute('home'); - const moveChannelToTeam = useEndpointActionExperimental('POST', 'teams.addRooms', t('Success')); + const moveChannelToTeam = useEndpointActionExperimental('POST', 'teams.addRooms', t('Rooms_added_successfully')); const convertRoomToTeam = useEndpointActionExperimental( 'POST', type === 'c' ? 'channels.convertToTeam' : 'groups.convertToTeam', diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index e621501c3a33..7e307e268e7a 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -284,6 +284,7 @@ "add-user-to-any-p-room_description": "Permission to add a user to any private channel", "add-user-to-joined-room": "Add User to Any Joined Channel", "add-user-to-joined-room_description": "Permission to add a user to a currently joined channel", + "added__roomName__to_team": "added #__roomName__ to this Team", "Adding_OAuth_Services": "Adding OAuth Services", "Adding_permission": "Adding permission", "Adding_user": "Adding user", @@ -774,7 +775,7 @@ "Channel_to_listen_on": "Channel to listen on", "Channel_Unarchived": "Channel with name `#%s` has been Unarchived successfully", "Channels": "Channels", - "Channels_added": "Channels added", + "Channels_added": "Channels added sucessfully", "Channels_are_where_your_team_communicate": "Channels are where your team communicate", "Channels_list": "List of public channels", "Channel_what_is_this_channel_about": "What is this channel about?", @@ -955,8 +956,6 @@ "Compact": "Compact", "Condensed": "Condensed", "Condition": "Condition", - "Convert_to_channel": "Convert to Channel", - "Converting_team_to_channel": "Converting Team to Channel", "Commit_details": "Commit Details", "Completed": "Completed", "Computer": "Computer", @@ -1005,6 +1004,9 @@ "Convert": "Convert", "Convert_Ascii_Emojis": "Convert ASCII to Emoji", "Converting_channel_to_a_team": "This can't be undone. Once you convert a Channel to a Team, you can not turn it back to a Channel.", + "Converting_team_to_channel": "Converting Team to Channel", + "Convert_to_channel": "Convert to Channel", + "Converted__roomName__to_team": "converted __roomName__ to a Team", "Copied": "Copied", "Copy": "Copy", "Copy_text": "Copy Text", @@ -1399,6 +1401,7 @@ "delete-user": "Delete User", "delete-user_description": "Permission to delete users", "Deleted": "Deleted!", + "Deleted__roomName__": "deleted #__roomName__", "Department": "Department", "Department_name": "Department name", "Department_not_found": "Department not found", @@ -3521,6 +3524,7 @@ "remove-user_description": "Permission to remove a user from a room", "Removed": "Removed", "Removed_User": "Removed User", + "Removed__roomName__from_this_team": "removed __roomName__ from this Team", "Replay": "Replay", "Replied_on": "Replied on", "Replies": "Replies", @@ -3664,6 +3668,7 @@ "Room_uploaded_file_list": "Files List", "Room_uploaded_file_list_empty": "No files available.", "Rooms": "Rooms", + "Rooms_added_successfully": "Rooms added successfully", "Routing": "Routing", "Run_only_once_for_each_visitor": "Run only once for each visitor", "run-import": "Run Import", From a965b43e387c71afbc83b3999d9d2dd446b8e325 Mon Sep 17 00:00:00 2001 From: matheusbsilva137 Date: Mon, 7 Feb 2022 14:03:09 -0300 Subject: [PATCH 03/11] Add missing team's system messages --- app/api/server/v1/channels.js | 15 ----- app/api/server/v1/teams.ts | 16 +++-- app/lib/lib/MessageTypes.js | 60 ++++++++++++++++++- app/lib/server/functions/addUserToRoom.js | 9 ++- app/lib/server/functions/createRoom.js | 7 ++- .../server/functions/removeUserFromRoom.js | 10 +++- app/models/server/models/Messages.js | 16 ++++- .../server/cronProcessDownloads.js | 15 +++++ packages/rocketchat-i18n/i18n/en.i18n.json | 24 ++++++-- server/methods/eraseRoom.js | 9 ++- server/sdk/types/ITeamService.ts | 2 +- server/services/team/service.ts | 30 ++++++++-- 12 files changed, 169 insertions(+), 44 deletions(-) diff --git a/app/api/server/v1/channels.js b/app/api/server/v1/channels.js index d00d1963d9c5..e2d85ccc45b8 100644 --- a/app/api/server/v1/channels.js +++ b/app/api/server/v1/channels.js @@ -298,12 +298,6 @@ API.v1.addRoute( const { channel } = API.channels.create.execute(userId, bodyParams); - if (bodyParams.extraData.teamId) { - const user = Meteor.users.findOne(this.userId); - const team = Promise.await(Team.getOneById(bodyParams.extraData.teamId)); - Messages.createUserAddRoomToTeamWithRoomIdAndUser(team.roomId, channel.name, user); - } - return API.v1.success({ channel }); }, }, @@ -319,12 +313,6 @@ API.v1.addRoute( checkedArchived: false, }); - if (room.teamId) { - const team = Promise.await(Team.getOneById(room.teamId)); - const user = Meteor.users.findOne(this.userId); - Messages.createUserDeleteRoomFromTeamWithRoomIdAndUser(team.roomId, room.name, user); - } - Meteor.runAsUser(this.userId, () => { Meteor.call('eraseRoom', room._id); }); @@ -1402,9 +1390,6 @@ API.v1.addRoute( const team = Promise.await(Team.create(this.userId, teamData)); - const user = Meteor.users.findOne(this.userId); - Messages.createUserConvertChannelInTeamWithRoomIdAndUser(room._id, room.name, user); - return API.v1.success({ team }); }, }, diff --git a/app/api/server/v1/teams.ts b/app/api/server/v1/teams.ts index cdb3d2d3b891..76b98eec842c 100644 --- a/app/api/server/v1/teams.ts +++ b/app/api/server/v1/teams.ts @@ -6,7 +6,7 @@ import { escapeRegExp } from '@rocket.chat/string-helpers'; import { API } from '../api'; import { Team } from '../../../../server/sdk'; import { hasAtLeastOnePermission, hasPermission } from '../../../authorization/server'; -import { Users, Messages } from '../../../models/server'; +import { Users } from '../../../models/server'; import { removeUserFromRoom } from '../../../lib/server/functions/removeUserFromRoom'; import { IUser } from '../../../../definition/IUser'; import { isTeamsConvertToChannelProps } from '../../../../definition/rest/v1/teams/TeamsConvertToChannelProps'; @@ -140,7 +140,11 @@ API.v1.addRoute( }); } - await Promise.all([Team.unsetTeamIdOfRooms(team._id), Team.removeAllMembersFromTeam(team._id), Team.deleteById(team._id)]); + await Promise.all([ + Team.unsetTeamIdOfRooms(this.userId, team._id), + Team.removeAllMembersFromTeam(team._id), + Team.deleteById(team._id), + ]); return API.v1.success(); }, @@ -183,9 +187,6 @@ API.v1.addRoute( const { rooms } = this.bodyParams; const validRooms = await Team.addRooms(this.userId, rooms, team._id); - const user = Meteor.users.findOne(this.userId); - - validRooms?.length > 0 && validRooms.map((room) => Messages.createUserAddRoomToTeamWithRoomIdAndUser(team.roomId, room.name, user)); return API.v1.success({ rooms: validRooms }); }, @@ -216,9 +217,6 @@ API.v1.addRoute( const room = await Team.removeRoom(this.userId, roomId, team._id, canRemoveAny); - const user = Meteor.users.findOne(this.userId); - Messages.createUserRemoveRoomFromTeamWithRoomIdAndUser(team.roomId, room.name, user); - return API.v1.success({ room }); }, }, @@ -623,7 +621,7 @@ API.v1.addRoute( } // Move every other room back to the workspace - await Team.unsetTeamIdOfRooms(team._id); + await Team.unsetTeamIdOfRooms(this.userId, team._id); // Delete all team memberships Team.removeAllMembersFromTeam(team._id); diff --git a/app/lib/lib/MessageTypes.js b/app/lib/lib/MessageTypes.js index 8ac9a4fa939a..d633b927f622 100644 --- a/app/lib/lib/MessageTypes.js +++ b/app/lib/lib/MessageTypes.js @@ -26,6 +26,16 @@ Meteor.startup(function () { }; }, }); + MessageTypes.registerType({ + id: 'aut', + system: true, + message: 'Added__username__to_team', + data(message) { + return { + user_added: message.msg, + }; + }, + }); MessageTypes.registerType({ id: 'ru', system: true, @@ -37,6 +47,16 @@ Meteor.startup(function () { }; }, }); + MessageTypes.registerType({ + id: 'rut', + system: true, + message: 'Removed__username__from_team', + data(message) { + return { + user_removed: message.msg, + }; + }, + }); MessageTypes.registerType({ id: 'ul', system: true, @@ -68,9 +88,9 @@ Meteor.startup(function () { }, }); MessageTypes.registerType({ - id: 'userRemoveRoomFromTeam', + id: 'userConvertToChannel', system: true, - message: 'Removed__roomName__from_this_team', + message: 'Converted__roomName__to_channel', data(message) { return { roomName: message.msg, @@ -296,18 +316,34 @@ export const MessageTypesValues = [ key: 'uj', i18nLabel: 'Message_HideType_uj', }, + { + key: 'ujt', + i18nLabel: 'Message_HideType_ujt', + }, { key: 'ul', i18nLabel: 'Message_HideType_ul', }, + { + key: 'ult', + i18nLabel: 'Message_HideType_ult', + }, { key: 'ru', i18nLabel: 'Message_HideType_ru', }, + { + key: 'rut', + i18nLabel: 'Message_HideType_rut', + }, { key: 'au', i18nLabel: 'Message_HideType_au', }, + { + key: 'aut', + i18nLabel: 'Message_HideType_aut', + }, { key: 'mute_unmute', i18nLabel: 'Message_HideType_mute_unmute', @@ -380,4 +416,24 @@ export const MessageTypesValues = [ key: 'room-allowed-reacting', i18nLabel: 'Message_HideType_room_allowed_reacting', }, + { + key: 'userAddRoomToTeam', + i18nLabel: 'Message_HideType_userAddRoomToTeam', + }, + { + key: 'userConvertToChannel', + i18nLabel: 'Message_HideType_userConvertToChannel', + }, + { + key: 'userConvertToTeam', + i18nLabel: 'Message_HideType_userConvertToTeam', + }, + { + key: 'userDeleteRoomFromTeam', + i18nLabel: 'Message_HideType_userDeleteRoomFromTeam', + }, + { + key: 'userRemoveRoomFromTeam', + i18nLabel: 'Message_HideType_userRemoveRoomFromTeam', + }, ]; diff --git a/app/lib/server/functions/addUserToRoom.js b/app/lib/server/functions/addUserToRoom.js index 40e356846341..26c7dc51d514 100644 --- a/app/lib/server/functions/addUserToRoom.js +++ b/app/lib/server/functions/addUserToRoom.js @@ -61,13 +61,18 @@ export const addUserToRoom = function (rid, user, inviter, silenced) { if (!silenced) { if (inviter) { - Messages.createUserAddedWithRoomIdAndUser(rid, user, { + const extraData = { ts: now, u: { _id: inviter._id, username: inviter.username, }, - }); + }; + if (room.teamMain) { + Messages.createUserAddedToTeamWithRoomIdAndUser(rid, user, extraData); + } else { + Messages.createUserAddedWithRoomIdAndUser(rid, user, extraData); + } } else if (room.prid) { Messages.createUserJoinWithRoomIdAndUserDiscussion(rid, user, { ts: now }); } else if (room.teamMain) { diff --git a/app/lib/server/functions/createRoom.js b/app/lib/server/functions/createRoom.js index 2569f8ea5df0..96cd49c579d0 100644 --- a/app/lib/server/functions/createRoom.js +++ b/app/lib/server/functions/createRoom.js @@ -6,7 +6,7 @@ import s from 'underscore.string'; import { Apps } from '../../../apps/server'; import { addUserRoles } from '../../../authorization'; import { callbacks } from '../../../../lib/callbacks'; -import { Rooms, Subscriptions, Users } from '../../../models'; +import { Messages, Rooms, Subscriptions, Users } from '../../../models'; import { getValidRoomName } from '../../../utils'; import { createDirectRoom } from './createDirectRoom'; import { Team } from '../../../../server/sdk'; @@ -131,6 +131,11 @@ export const createRoom = function (type, name, owner, members = [], readOnly, { addUserRoles(owner._id, ['owner'], room._id); + if (room.teamId) { + const team = Promise.await(Team.getOneById(room.teamId)); + Messages.createUserAddRoomToTeamWithRoomIdAndUser(team.roomId, room.name, owner); + } + if (type === 'c') { Meteor.defer(() => { callbacks.run('afterCreateChannel', owner, room); diff --git a/app/lib/server/functions/removeUserFromRoom.js b/app/lib/server/functions/removeUserFromRoom.js index 32eea62a5215..9745a69bc42b 100644 --- a/app/lib/server/functions/removeUserFromRoom.js +++ b/app/lib/server/functions/removeUserFromRoom.js @@ -29,9 +29,15 @@ export const removeUserFromRoom = function (rid, user, options = {}) { if (subscription) { const removedUser = user; if (options.byUser) { - Messages.createUserRemovedWithRoomIdAndUser(rid, user, { + const extraData = { u: options.byUser, - }); + }; + + if (room.teamMain) { + Messages.createUserRemovedFromTeamWithRoomIdAndUser(rid, user, extraData); + } else { + Messages.createUserRemovedWithRoomIdAndUser(rid, user, extraData); + } } else if (room.teamMain) { Messages.createUserLeaveTeamWithRoomIdAndUser(rid, removedUser); } else { diff --git a/app/models/server/models/Messages.js b/app/models/server/models/Messages.js index 67552b3e4c45..1762427a567b 100644 --- a/app/models/server/models/Messages.js +++ b/app/models/server/models/Messages.js @@ -911,10 +911,14 @@ export class Messages extends Base { return this.createWithTypeRoomIdMessageAndUser('ult', roomId, message, user, extraData); } - createUserConvertChannelInTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { + createUserConvertChannelToTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { return this.createWithTypeRoomIdMessageAndUser('userConvertToTeam', roomId, roomName, user, extraData); } + createUserConvertTeamToChannelWithRoomIdAndUser(roomId, roomName, user, extraData) { + return this.createWithTypeRoomIdMessageAndUser('userConvertToChannel', roomId, roomName, user, extraData); + } + createUserRemoveRoomFromTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { return this.createWithTypeRoomIdMessageAndUser('userRemoveRoomFromTeam', roomId, roomName, user, extraData); } @@ -932,11 +936,21 @@ export class Messages extends Base { return this.createWithTypeRoomIdMessageAndUser('ru', roomId, message, user, extraData); } + createUserRemovedFromTeamWithRoomIdAndUser(roomId, user, extraData) { + const message = user.username; + return this.createWithTypeRoomIdMessageAndUser('rut', roomId, message, user, extraData); + } + createUserAddedWithRoomIdAndUser(roomId, user, extraData) { const message = user.username; return this.createWithTypeRoomIdMessageAndUser('au', roomId, message, user, extraData); } + createUserAddedToTeamWithRoomIdAndUser(roomId, user, extraData) { + const message = user.username; + return this.createWithTypeRoomIdMessageAndUser('aut', roomId, message, user, extraData); + } + createCommandWithRoomIdAndUser(command, roomId, user, extraData) { return this.createWithTypeRoomIdMessageAndUser('command', roomId, command, user, extraData); } diff --git a/app/user-data-download/server/cronProcessDownloads.js b/app/user-data-download/server/cronProcessDownloads.js index 4ee3aaa1d8bc..069f11b4862e 100644 --- a/app/user-data-download/server/cronProcessDownloads.js +++ b/app/user-data-download/server/cronProcessDownloads.js @@ -170,12 +170,22 @@ const getMessageData = function (msg, hideUsers, userData, usersMap) { roomName: msg.msg, }); break; + case 'userConvertToChannel': + messageObject.msg = TAPi18n.__('Converted__roomName__to_channel', { + roomName: msg.msg, + }); + break; case 'au': messageObject.msg = TAPi18n.__('User_added_by', { user_added: hideUserName(msg.msg, userData, usersMap), user_by: username, }); break; + case 'aut': + messageObject.msg = TAPi18n.__('Added__username__to_team', { + user_added: msg.msg, + }); + break; case 'r': messageObject.msg = TAPi18n.__('Room_name_changed', { room_name: msg.msg, @@ -188,6 +198,11 @@ const getMessageData = function (msg, hideUsers, userData, usersMap) { user_by: username, }); break; + case 'rut': + messageObject.msg = TAPi18n.__('Removed__username__from_team', { + user_removed: hideUserName(msg.msg, userData, usersMap), + }); + break; case 'wm': messageObject.msg = TAPi18n.__('Welcome', { user: username }); break; diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 7e307e268e7a..8353f7de9d45 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -285,6 +285,7 @@ "add-user-to-joined-room": "Add User to Any Joined Channel", "add-user-to-joined-room_description": "Permission to add a user to a currently joined channel", "added__roomName__to_team": "added #__roomName__ to this Team", + "Added__username__to_team": "added @__user_added__ to this Team", "Adding_OAuth_Services": "Adding OAuth Services", "Adding_permission": "Adding permission", "Adding_user": "Adding user", @@ -1006,7 +1007,8 @@ "Converting_channel_to_a_team": "This can't be undone. Once you convert a Channel to a Team, you can not turn it back to a Channel.", "Converting_team_to_channel": "Converting Team to Channel", "Convert_to_channel": "Convert to Channel", - "Converted__roomName__to_team": "converted __roomName__ to a Team", + "Converted__roomName__to_team": "converted #__roomName__ to a Team", + "Converted__roomName__to_channel": "converted #__roomName__ to a Channel", "Copied": "Copied", "Copy": "Copy", "Copy_text": "Copy Text", @@ -2924,6 +2926,7 @@ "Message_has_been_unpinned": "Message has been unpinned", "Message_has_been_unstarred": "Message has been unstarred", "Message_HideType_au": "Hide \"User Added\" messages", + "Message_HideType_aut": "Hide \"User Added to Team\" messages", "Message_HideType_mute_unmute": "Hide \"User Muted / Unmuted\" messages", "Message_HideType_r": "Hide \"Room Name Changed\" messages", "Message_HideType_rm": "Hide \"Message Removed\" messages", @@ -2939,10 +2942,18 @@ "Message_HideType_room_removed_read_only": "Hide \"Room added writing permission\" messages", "Message_HideType_room_unarchived": "Hide \"Room Unarchived\" messages", "Message_HideType_ru": "Hide \"User Removed\" messages", + "Message_HideType_rut": "Hide \"User Removed from Team\" messages", "Message_HideType_subscription_role_added": "Hide \"Was Set Role\" messages", "Message_HideType_subscription_role_removed": "Hide \"Role No Longer Defined\" messages", "Message_HideType_uj": "Hide \"User Join\" messages", + "Message_HideType_ujt": "Hide \"User Joined Team\" messages", "Message_HideType_ul": "Hide \"User Leave\" messages", + "Message_HideType_ult": "Hide \"User Left Team\" messages", + "Message_HideType_userAddRoomToTeam": "Hide \"User Added Room to Team\" messages", + "Message_HideType_userConvertToChannel": "Hide \"User converted team to a Channel\" messages", + "Message_HideType_userConvertToTeam": "Hide \"User converted channel to a Team\" messages", + "Message_HideType_userDeleteRoomFromTeam": "Hide \"User deleted room from Team\" messages", + "Message_HideType_userRemoveRoomFromTeam": "Hide \"User removed room from Team\" messages", "Message_HideType_ut": "Hide \"User Joined Conversation\" messages", "Message_HideType_wm": "Hide \"Welcome\" messages", "Message_Id": "Message Id", @@ -3524,7 +3535,8 @@ "remove-user_description": "Permission to remove a user from a room", "Removed": "Removed", "Removed_User": "Removed User", - "Removed__roomName__from_this_team": "removed __roomName__ from this Team", + "Removed__roomName__from_this_team": "removed #__roomName__ from this Team", + "Removed__username__from_team": "removed @__user_removed__ from this Team", "Replay": "Replay", "Replied_on": "Replied on", "Replies": "Replies", @@ -4480,11 +4492,11 @@ "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_joined_team": "joined this Team", + "User_joined_team_female": "joined this Team", + "User_joined_team_male": "joined this Team", "User_left": "Has left the channel.", - "User_left_team": "left the team.", + "User_left_team": "left this Team", "User_logged_out": "User is logged out", "User_management": "User Management", "User_mentions_only": "User mentions only", diff --git a/server/methods/eraseRoom.js b/server/methods/eraseRoom.js index f5d8d2261d84..95dae4a02c7c 100644 --- a/server/methods/eraseRoom.js +++ b/server/methods/eraseRoom.js @@ -3,9 +3,10 @@ import { check } from 'meteor/check'; import { deleteRoom } from '../../app/lib'; import { hasPermission } from '../../app/authorization'; -import { Rooms } from '../../app/models'; +import { Rooms, Messages } from '../../app/models'; import { Apps } from '../../app/apps/server'; import { roomTypes } from '../../app/utils'; +import { Team } from '../sdk'; Meteor.methods({ eraseRoom(rid) { @@ -40,6 +41,12 @@ Meteor.methods({ const result = deleteRoom(rid); + if (room.teamId) { + const team = Promise.await(Team.getOneById(room.teamId)); + const user = Meteor.user(); + Messages.createUserDeleteRoomFromTeamWithRoomIdAndUser(team.roomId, room.name, user); + } + if (Apps && Apps.isLoaded()) { Apps.getBridges().getListenerBridge().roomEvent('IPostRoomDeleted', room); } diff --git a/server/sdk/types/ITeamService.ts b/server/sdk/types/ITeamService.ts index 1ab8016e0260..c94baedefb73 100644 --- a/server/sdk/types/ITeamService.ts +++ b/server/sdk/types/ITeamService.ts @@ -94,7 +94,7 @@ export interface ITeamService { getInfoById(teamId: string): Promise | null>; deleteById(teamId: string): Promise; deleteByName(teamName: string): Promise; - unsetTeamIdOfRooms(teamId: string): void; + unsetTeamIdOfRooms(uid: string, teamId: string): void; getOneById(teamId: string, options?: FindOneOptions): Promise; getOneById

(teamId: string, options?: FindOneOptions

): Promise; getOneByName(teamName: string | RegExp, options?: FindOneOptions): Promise; diff --git a/server/services/team/service.ts b/server/services/team/service.ts index c13300ab0305..491767401c27 100644 --- a/server/services/team/service.ts +++ b/server/services/team/service.ts @@ -15,6 +15,7 @@ import { UsersRaw } from '../../../app/models/server/raw/Users'; import { IRoom } from '../../../definition/IRoom'; import { IPaginationOptions, IQueryOptions, IRecordsWithTotal, ITeam, ITeamMember, ITeamStats, TEAM_TYPE } from '../../../definition/ITeam'; import { IUser } from '../../../definition/IUser'; +import { Messages } from '../../../app/models/server'; import { Room, Authorization } from '../../sdk'; import { IListRoomsFilter, @@ -147,6 +148,8 @@ export class TeamService extends ServiceClass implements ITeamService { await this.TeamModel.updateMainRoomForTeam(teamId, roomId); teamData.roomId = roomId; + Messages.createUserConvertChannelToTeamWithRoomIdAndUser(roomId, team.name, createdBy); + return { _id: teamId, ...teamData, @@ -342,7 +345,7 @@ export class TeamService extends ServiceClass implements ITeamService { throw new Error('missing-userId'); } - const team = await this.TeamModel.findOneById(teamId, { projection: { _id: 1 } }); + const team = await this.TeamModel.findOneById>(teamId, { projection: { _id: 1, roomId: 1 } }); if (!team) { throw new Error('invalid-team'); } @@ -373,6 +376,8 @@ export class TeamService extends ServiceClass implements ITeamService { throw new Error('error-no-owner-channel'); } + Messages.createUserAddRoomToTeamWithRoomIdAndUser(team.roomId, room.name, user); + room.teamId = teamId; } @@ -396,15 +401,15 @@ export class TeamService extends ServiceClass implements ITeamService { throw new Error('invalid-room'); } + const user = await this.Users.findOneById(uid); if (!canRemoveAnyRoom) { - const user = await this.Users.findOneById(uid); const canSeeRoom = await canAccessRoom(room, user); if (!canSeeRoom) { throw new Error('invalid-room'); } } - const team = await this.TeamModel.findOneById(teamId, { projection: { _id: 1 } }); + const team = await this.TeamModel.findOneById>(teamId, { projection: { _id: 1, roomId: 1 } }); if (!team) { throw new Error('invalid-team'); } @@ -416,16 +421,33 @@ export class TeamService extends ServiceClass implements ITeamService { delete room.teamId; delete room.teamDefault; this.RoomsModel.unsetTeamById(room._id); + + Messages.createUserRemoveRoomFromTeamWithRoomIdAndUser(team.roomId, room.name, user); + return { ...room, }; } - async unsetTeamIdOfRooms(teamId: string): Promise { + async unsetTeamIdOfRooms(uid: string, teamId: string): Promise { if (!teamId) { throw new Error('missing-teamId'); } + const team = await this.TeamModel.findOneById>(teamId, { projection: { roomId: 1 } }); + if (!team) { + throw new Error('invalid-team'); + } + + const room = await this.RoomsModel.findOneById(team.roomId, { projection: { name: 1 } }); + if (!room) { + throw new Error('invalid-room'); + } + + const user = await this.Users.findOneById(uid); + + Messages.createUserConvertTeamToChannelWithRoomIdAndUser(team.roomId, room.name, user); + await this.RoomsModel.unsetTeamId(teamId); } From 03c24b96c6e2f3a87cf838861bf69e29c416b4d4 Mon Sep 17 00:00:00 2001 From: matheusbsilva137 Date: Mon, 7 Feb 2022 16:17:09 -0300 Subject: [PATCH 04/11] Add missing type --- server/services/team/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/services/team/service.ts b/server/services/team/service.ts index 491767401c27..3b8b7e125ac1 100644 --- a/server/services/team/service.ts +++ b/server/services/team/service.ts @@ -439,7 +439,7 @@ export class TeamService extends ServiceClass implements ITeamService { throw new Error('invalid-team'); } - const room = await this.RoomsModel.findOneById(team.roomId, { projection: { name: 1 } }); + const room = await this.RoomsModel.findOneById>(team.roomId, { projection: { name: 1 } }); if (!room) { throw new Error('invalid-room'); } From b14a7171f6f313e634c9a4e19285b591cb20cad7 Mon Sep 17 00:00:00 2001 From: matheusbsilva137 Date: Fri, 11 Feb 2022 18:34:53 -0300 Subject: [PATCH 05/11] Revert 'convert channel to team' i18n string changes, fix teams.delete --- app/api/server/v1/teams.ts | 6 +++--- packages/rocketchat-i18n/i18n/en.i18n.json | 2 +- packages/rocketchat-i18n/i18n/pt-BR.i18n.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/api/server/v1/teams.ts b/app/api/server/v1/teams.ts index 76b98eec842c..476a933febca 100644 --- a/app/api/server/v1/teams.ts +++ b/app/api/server/v1/teams.ts @@ -610,9 +610,6 @@ API.v1.addRoute( const rooms: string[] = await Team.getMatchingTeamRooms(team._id, roomsToRemove); - // Remove the team's main room - Meteor.call('eraseRoom', team.roomId); - // If we got a list of rooms to delete along with the team, remove them first if (rooms.length) { rooms.forEach((room) => { @@ -623,6 +620,9 @@ API.v1.addRoute( // Move every other room back to the workspace await Team.unsetTeamIdOfRooms(this.userId, team._id); + // Remove the team's main room + Meteor.call('eraseRoom', team.roomId); + // Delete all team memberships Team.removeAllMembersFromTeam(team._id); diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 5a0dafd7553b..5bc3c72f13a4 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1004,7 +1004,7 @@ "Conversations_per_day": "Conversations per Day", "Convert": "Convert", "Convert_Ascii_Emojis": "Convert ASCII to Emoji", - "Converting_channel_to_a_team": "This can't be undone. Once you convert a Channel to a Team, you can not turn it back to a Channel.", + "Converting_channel_to_a_team": "You are converting this Channel to a Team. All members will be kept.", "Converting_team_to_channel": "Converting Team to Channel", "Convert_to_channel": "Convert to Channel", "Converted__roomName__to_team": "converted #__roomName__ to a Team", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index cb1428439b5a..9a5523ac5490 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -1004,7 +1004,7 @@ "Conversations_per_day": "Conversas por dia", "Convert": "Converter", "Convert_Ascii_Emojis": "Converter ASCII para Emoji", - "Converting_channel_to_a_team": " Esta ação não pode ser desfeita. Uma vez que convertido a um time, não é possível converter de volta a um canal.", + "Converting_channel_to_a_team": "Você está convertendo esse Canal para uma Equipe. Todos os membros serão mantidos.", "Copied": "Copiado", "Copy": "Copiar", "Copy_text": "Copiar Texto", From 70d52e0da04033363d13a5c1452f1c7fe0782d6f Mon Sep 17 00:00:00 2001 From: matheusbsilva137 Date: Mon, 14 Feb 2022 12:54:01 -0300 Subject: [PATCH 06/11] Fix 'converted channel to team' message being sent on team creation --- server/services/team/service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/services/team/service.ts b/server/services/team/service.ts index 3b8b7e125ac1..40b8eacb0a83 100644 --- a/server/services/team/service.ts +++ b/server/services/team/service.ts @@ -126,6 +126,7 @@ export class TeamService extends ServiceClass implements ITeamService { let roomId = room.id; if (roomId) { await this.RoomsModel.setTeamMainById(roomId, teamId); + Messages.createUserConvertChannelToTeamWithRoomIdAndUser(roomId, team.name, createdBy); } else { const roomType: IRoom['t'] = team.type === TEAM_TYPE.PRIVATE ? 'p' : 'c'; @@ -148,8 +149,6 @@ export class TeamService extends ServiceClass implements ITeamService { await this.TeamModel.updateMainRoomForTeam(teamId, roomId); teamData.roomId = roomId; - Messages.createUserConvertChannelToTeamWithRoomIdAndUser(roomId, team.name, createdBy); - return { _id: teamId, ...teamData, From 0f1ff46344867000883120a81b58b0ecb3457b26 Mon Sep 17 00:00:00 2001 From: dougfabris Date: Tue, 15 Feb 2022 20:58:25 -0300 Subject: [PATCH 07/11] chore: remove unecessary translation keys --- app/theme/client/imports/general/base_old.css | 2 -- packages/rocketchat-i18n/i18n/en.i18n.json | 18 ++---------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/app/theme/client/imports/general/base_old.css b/app/theme/client/imports/general/base_old.css index 687adb5be2a0..3563ba9a5435 100644 --- a/app/theme/client/imports/general/base_old.css +++ b/app/theme/client/imports/general/base_old.css @@ -1880,8 +1880,6 @@ & .user { display: inline-block; - margin-right: 5px; - font-family: inherit; font-size: 0.875rem; diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index ca6cb58691bc..1aa9dac16caa 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -619,10 +619,6 @@ "Avg_response_time": "Average of Response Time", "away": "away", "Away": "Away", - "away_female": "away", - "Away_female": "Away", - "away_male": "away", - "Away_male": "Away", "Back": "Back", "Back_to_applications": "Back to applications", "Back_to_chat": "Back to chat", @@ -700,10 +696,6 @@ "Business_hours_updated": "Business hours updated", "busy": "busy", "Busy": "Busy", - "busy_female": "busy", - "Busy_female": "Busy", - "busy_male": "busy", - "Busy_male": "Busy", "By": "By", "by": "by", "By_author": "By __author__", @@ -1004,11 +996,11 @@ "Conversations_per_day": "Conversations per Day", "Convert": "Convert", "Convert_Ascii_Emojis": "Convert ASCII to Emoji", - "Converting_channel_to_a_team": "You are converting this Channel to a Team. All members will be kept.", - "Converting_team_to_channel": "Converting Team to Channel", "Convert_to_channel": "Convert to Channel", + "Converting_channel_to_a_team": "You are converting this Channel to a Team. All members will be kept.", "Converted__roomName__to_team": "converted #__roomName__ to a Team", "Converted__roomName__to_channel": "converted #__roomName__ to a Channel", + "Converting_team_to_channel": "Converting Team to Channel", "Copied": "Copied", "Copy": "Copy", "Copy_text": "Copy Text", @@ -2352,8 +2344,6 @@ "IRC_Private_Message": "Output of the PRIVMSG command.", "IRC_Quit": "Output upon quitting an IRC session.", "is_typing": "is typing", - "is_typing_female": "is typing", - "is_typing_male": "is typing", "Issue_Links": "Issue tracker links", "IssueLinks_Incompatible": "Warning: do not enable this and the 'Hex Color Preview' at the same time.", "IssueLinks_LinkTemplate": "Template for issue links", @@ -4493,12 +4483,8 @@ "User_is_now_an_admin": "User is now an admin", "User_is_unblocked": "User is unblocked", "User_joined_channel": "Has joined the channel.", - "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": "joined this Team", - "User_joined_team_female": "joined this Team", - "User_joined_team_male": "joined this Team", "User_left": "Has left the channel.", "User_left_team": "left this Team", "User_logged_out": "User is logged out", From 8af040047477d691395e03f1af0d5908fd543f6c Mon Sep 17 00:00:00 2001 From: matheusbsilva137 Date: Wed, 16 Feb 2022 14:27:30 -0300 Subject: [PATCH 08/11] Update teams' system messages ids --- app/lib/lib/MessageTypes.js | 42 +++++++++---------- app/models/server/models/Messages.js | 14 +++---- .../server/cronProcessDownloads.js | 8 ++-- packages/rocketchat-i18n/i18n/en.i18n.json | 16 +++---- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/app/lib/lib/MessageTypes.js b/app/lib/lib/MessageTypes.js index d633b927f622..3915ec8f0dbb 100644 --- a/app/lib/lib/MessageTypes.js +++ b/app/lib/lib/MessageTypes.js @@ -27,7 +27,7 @@ Meteor.startup(function () { }, }); MessageTypes.registerType({ - id: 'aut', + id: 'added-user-to-team', system: true, message: 'Added__username__to_team', data(message) { @@ -48,7 +48,7 @@ Meteor.startup(function () { }, }); MessageTypes.registerType({ - id: 'rut', + id: 'removed-user-from-team', system: true, message: 'Removed__username__from_team', data(message) { @@ -78,7 +78,7 @@ Meteor.startup(function () { }, }); MessageTypes.registerType({ - id: 'userConvertToTeam', + id: 'user-converted-to-team', system: true, message: 'Converted__roomName__to_team', data(message) { @@ -88,7 +88,7 @@ Meteor.startup(function () { }, }); MessageTypes.registerType({ - id: 'userConvertToChannel', + id: 'user-converted-to-channel', system: true, message: 'Converted__roomName__to_channel', data(message) { @@ -98,7 +98,7 @@ Meteor.startup(function () { }, }); MessageTypes.registerType({ - id: 'userRemoveRoomFromTeam', + id: 'user-removed-room-from-team', system: true, message: 'Removed__roomName__from_this_team', data(message) { @@ -108,7 +108,7 @@ Meteor.startup(function () { }, }); MessageTypes.registerType({ - id: 'userDeleteRoomFromTeam', + id: 'user-deleted-room-from-team', system: true, message: 'Deleted__roomName__', data(message) { @@ -118,7 +118,7 @@ Meteor.startup(function () { }, }); MessageTypes.registerType({ - id: 'userAddRoomToTeam', + id: 'user-added-room-to-team', system: true, message: 'added__roomName__to_team', data(message) { @@ -333,16 +333,16 @@ export const MessageTypesValues = [ i18nLabel: 'Message_HideType_ru', }, { - key: 'rut', - i18nLabel: 'Message_HideType_rut', + key: 'removed-user-from-team', + i18nLabel: 'Message_HideType_removed_user_from_team', }, { key: 'au', i18nLabel: 'Message_HideType_au', }, { - key: 'aut', - i18nLabel: 'Message_HideType_aut', + key: 'added-user-to-team', + i18nLabel: 'Message_HideType_added_user_to_team', }, { key: 'mute_unmute', @@ -417,23 +417,23 @@ export const MessageTypesValues = [ i18nLabel: 'Message_HideType_room_allowed_reacting', }, { - key: 'userAddRoomToTeam', - i18nLabel: 'Message_HideType_userAddRoomToTeam', + key: 'user-added-room-to-team', + i18nLabel: 'Message_HideType_user_added_room_to_team', }, { - key: 'userConvertToChannel', - i18nLabel: 'Message_HideType_userConvertToChannel', + key: 'user-converted-to-channel', + i18nLabel: 'Message_HideType_user_converted_to_channel', }, { - key: 'userConvertToTeam', - i18nLabel: 'Message_HideType_userConvertToTeam', + key: 'user-converted-to-team', + i18nLabel: 'Message_HideType_user_converted_to_team', }, { - key: 'userDeleteRoomFromTeam', - i18nLabel: 'Message_HideType_userDeleteRoomFromTeam', + key: 'user-deleted-room-from-team', + i18nLabel: 'Message_HideType_user_deleted_room_from_team', }, { - key: 'userRemoveRoomFromTeam', - i18nLabel: 'Message_HideType_userRemoveRoomFromTeam', + key: 'user-removed-room-from-team', + i18nLabel: 'Message_HideType_user_removed_room_from_team', }, ]; diff --git a/app/models/server/models/Messages.js b/app/models/server/models/Messages.js index 1762427a567b..afa93228da97 100644 --- a/app/models/server/models/Messages.js +++ b/app/models/server/models/Messages.js @@ -912,23 +912,23 @@ export class Messages extends Base { } createUserConvertChannelToTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { - return this.createWithTypeRoomIdMessageAndUser('userConvertToTeam', roomId, roomName, user, extraData); + return this.createWithTypeRoomIdMessageAndUser('user-converted-to-team', roomId, roomName, user, extraData); } createUserConvertTeamToChannelWithRoomIdAndUser(roomId, roomName, user, extraData) { - return this.createWithTypeRoomIdMessageAndUser('userConvertToChannel', roomId, roomName, user, extraData); + return this.createWithTypeRoomIdMessageAndUser('user-converted-to-channel', roomId, roomName, user, extraData); } createUserRemoveRoomFromTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { - return this.createWithTypeRoomIdMessageAndUser('userRemoveRoomFromTeam', roomId, roomName, user, extraData); + return this.createWithTypeRoomIdMessageAndUser('user-removed-room-from-team', roomId, roomName, user, extraData); } createUserDeleteRoomFromTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { - return this.createWithTypeRoomIdMessageAndUser('userDeleteRoomFromTeam', roomId, roomName, user, extraData); + return this.createWithTypeRoomIdMessageAndUser('user-deleted-room-from-team', roomId, roomName, user, extraData); } createUserAddRoomToTeamWithRoomIdAndUser(roomId, roomName, user, extraData) { - return this.createWithTypeRoomIdMessageAndUser('userAddRoomToTeam', roomId, roomName, user, extraData); + return this.createWithTypeRoomIdMessageAndUser('user-added-room-to-team', roomId, roomName, user, extraData); } createUserRemovedWithRoomIdAndUser(roomId, user, extraData) { @@ -938,7 +938,7 @@ export class Messages extends Base { createUserRemovedFromTeamWithRoomIdAndUser(roomId, user, extraData) { const message = user.username; - return this.createWithTypeRoomIdMessageAndUser('rut', roomId, message, user, extraData); + return this.createWithTypeRoomIdMessageAndUser('removed-user-from-team', roomId, message, user, extraData); } createUserAddedWithRoomIdAndUser(roomId, user, extraData) { @@ -948,7 +948,7 @@ export class Messages extends Base { createUserAddedToTeamWithRoomIdAndUser(roomId, user, extraData) { const message = user.username; - return this.createWithTypeRoomIdMessageAndUser('aut', roomId, message, user, extraData); + return this.createWithTypeRoomIdMessageAndUser('added-user-to-team', roomId, message, user, extraData); } createCommandWithRoomIdAndUser(command, roomId, user, extraData) { diff --git a/app/user-data-download/server/cronProcessDownloads.js b/app/user-data-download/server/cronProcessDownloads.js index 069f11b4862e..e1efa188de30 100644 --- a/app/user-data-download/server/cronProcessDownloads.js +++ b/app/user-data-download/server/cronProcessDownloads.js @@ -165,12 +165,12 @@ const getMessageData = function (msg, hideUsers, userData, usersMap) { case 'ult': messageObject.msg = TAPi18n.__('User_left_team'); break; - case 'userConvertToTeam': + case 'user-converted-to-team': messageObject.msg = TAPi18n.__('Converted__roomName__to_team', { roomName: msg.msg, }); break; - case 'userConvertToChannel': + case 'user-converted-to-channel': messageObject.msg = TAPi18n.__('Converted__roomName__to_channel', { roomName: msg.msg, }); @@ -181,7 +181,7 @@ const getMessageData = function (msg, hideUsers, userData, usersMap) { user_by: username, }); break; - case 'aut': + case 'added-user-to-team': messageObject.msg = TAPi18n.__('Added__username__to_team', { user_added: msg.msg, }); @@ -198,7 +198,7 @@ const getMessageData = function (msg, hideUsers, userData, usersMap) { user_by: username, }); break; - case 'rut': + case 'removed-user-from-team': messageObject.msg = TAPi18n.__('Removed__username__from_team', { user_removed: hideUserName(msg.msg, userData, usersMap), }); diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 5bc3c72f13a4..d7cc8b4969dd 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2927,7 +2927,7 @@ "Message_has_been_unpinned": "Message has been unpinned", "Message_has_been_unstarred": "Message has been unstarred", "Message_HideType_au": "Hide \"User Added\" messages", - "Message_HideType_aut": "Hide \"User Added to Team\" messages", + "Message_HideType_added_user_to_team": "Hide \"User Added to Team\" messages", "Message_HideType_mute_unmute": "Hide \"User Muted / Unmuted\" messages", "Message_HideType_r": "Hide \"Room Name Changed\" messages", "Message_HideType_rm": "Hide \"Message Removed\" messages", @@ -2943,18 +2943,18 @@ "Message_HideType_room_removed_read_only": "Hide \"Room added writing permission\" messages", "Message_HideType_room_unarchived": "Hide \"Room Unarchived\" messages", "Message_HideType_ru": "Hide \"User Removed\" messages", - "Message_HideType_rut": "Hide \"User Removed from Team\" messages", + "Message_HideType_removed_user_from_team": "Hide \"User Removed from Team\" messages", "Message_HideType_subscription_role_added": "Hide \"Was Set Role\" messages", "Message_HideType_subscription_role_removed": "Hide \"Role No Longer Defined\" messages", "Message_HideType_uj": "Hide \"User Join\" messages", - "Message_HideType_ujt": "Hide \"User Joined Team\" messages", + "Message_HideType_user_joined_team": "Hide \"User Joined Team\" messages", "Message_HideType_ul": "Hide \"User Leave\" messages", "Message_HideType_ult": "Hide \"User Left Team\" messages", - "Message_HideType_userAddRoomToTeam": "Hide \"User Added Room to Team\" messages", - "Message_HideType_userConvertToChannel": "Hide \"User converted team to a Channel\" messages", - "Message_HideType_userConvertToTeam": "Hide \"User converted channel to a Team\" messages", - "Message_HideType_userDeleteRoomFromTeam": "Hide \"User deleted room from Team\" messages", - "Message_HideType_userRemoveRoomFromTeam": "Hide \"User removed room from Team\" messages", + "Message_HideType_user_added_room_to_team": "Hide \"User Added Room to Team\" messages", + "Message_HideType_user_converted_to_channel": "Hide \"User converted team to a Channel\" messages", + "Message_HideType_user_converted_to_team": "Hide \"User converted channel to a Team\" messages", + "Message_HideType_user_deleted_room_from_team": "Hide \"User deleted room from Team\" messages", + "Message_HideType_user_removed_room_from_team": "Hide \"User removed room from Team\" messages", "Message_HideType_ut": "Hide \"User Joined Conversation\" messages", "Message_HideType_wm": "Hide \"Welcome\" messages", "Message_Id": "Message Id", From b29928906f68b64bdb67245864316f6901dd26f4 Mon Sep 17 00:00:00 2001 From: matheusbsilva137 Date: Wed, 16 Feb 2022 14:45:26 -0300 Subject: [PATCH 09/11] Fix hidetype ujt i18n string --- packages/rocketchat-i18n/i18n/en.i18n.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 576592e29819..48ae6ed210dc 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -2938,7 +2938,7 @@ "Message_HideType_subscription_role_added": "Hide \"Was Set Role\" messages", "Message_HideType_subscription_role_removed": "Hide \"Role No Longer Defined\" messages", "Message_HideType_uj": "Hide \"User Join\" messages", - "Message_HideType_user_joined_team": "Hide \"User Joined Team\" messages", + "Message_HideType_ujt": "Hide \"User Joined Team\" messages", "Message_HideType_ul": "Hide \"User Leave\" messages", "Message_HideType_ult": "Hide \"User Left Team\" messages", "Message_HideType_user_added_room_to_team": "Hide \"User Added Room to Team\" messages", From 4cd8122aefe0e7c0cb732f876d89878896e23d1f Mon Sep 17 00:00:00 2001 From: matheusbsilva137 Date: Wed, 16 Feb 2022 20:13:24 -0300 Subject: [PATCH 10/11] Add missing message ids to cronProcessDownloads --- .../server/cronProcessDownloads.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/user-data-download/server/cronProcessDownloads.js b/app/user-data-download/server/cronProcessDownloads.js index e1efa188de30..c93272dc1e31 100644 --- a/app/user-data-download/server/cronProcessDownloads.js +++ b/app/user-data-download/server/cronProcessDownloads.js @@ -165,6 +165,11 @@ const getMessageData = function (msg, hideUsers, userData, usersMap) { case 'ult': messageObject.msg = TAPi18n.__('User_left_team'); break; + case 'user-added-room-to-team': + messageObject.msg = TAPi18n.__('added__roomName__to_team', { + roomName: msg.msg, + }); + break; case 'user-converted-to-team': messageObject.msg = TAPi18n.__('Converted__roomName__to_team', { roomName: msg.msg, @@ -175,6 +180,19 @@ const getMessageData = function (msg, hideUsers, userData, usersMap) { roomName: msg.msg, }); break; + case 'user-deleted-room-from-team': + messageObject.msg = TAPi18n.__('Deleted__roomName__', { + roomName: msg.msg, + }); + break; + case 'user-removed-room-from-team': + messageObject.msg = TAPi18n.__('Removed__roomName__from_this_team', { + roomName: msg.msg, + }); + break; + case 'ujt': + messageObject.msg = TAPi18n.__('User_joined_team'); + break; case 'au': messageObject.msg = TAPi18n.__('User_added_by', { user_added: hideUserName(msg.msg, userData, usersMap), From 3fda0a47ff34c69ee1677881903556ef732cc3a2 Mon Sep 17 00:00:00 2001 From: Matheus Barbosa Silva <36537004+matheusbsilva137@users.noreply.github.com> Date: Thu, 17 Feb 2022 16:19:17 -0300 Subject: [PATCH 11/11] Update channels.create return statement --- app/api/server/v1/channels.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/api/server/v1/channels.js b/app/api/server/v1/channels.js index e2d85ccc45b8..371a2de3d1c2 100644 --- a/app/api/server/v1/channels.js +++ b/app/api/server/v1/channels.js @@ -296,9 +296,7 @@ API.v1.addRoute( bodyParams.members = [...membersToAdd]; } - const { channel } = API.channels.create.execute(userId, bodyParams); - - return API.v1.success({ channel }); + return API.v1.success(API.channels.create.execute(userId, bodyParams)); }, }, );