diff --git a/app/channel-settings/client/views/channelSettings.js b/app/channel-settings/client/views/channelSettings.js index 997f390ee7cdf..366332d5315f0 100644 --- a/app/channel-settings/client/views/channelSettings.js +++ b/app/channel-settings/client/views/channelSettings.js @@ -248,7 +248,8 @@ Template.channelSettingsEditing.onCreated(function() { _id: room._id, name: value, }); - + // To update webhooks name + call('changeChannelNameInWebhook', room.name, value); return toastr.success(t('Room_name_changed_successfully')); }); }, diff --git a/app/channel-settings/server/methods/saveRoomSettings.js b/app/channel-settings/server/methods/saveRoomSettings.js index b6d82a3044a4c..4d5ca2fbd8e01 100644 --- a/app/channel-settings/server/methods/saveRoomSettings.js +++ b/app/channel-settings/server/methods/saveRoomSettings.js @@ -1,8 +1,8 @@ import { Meteor } from 'meteor/meteor'; import { Match, check } from 'meteor/check'; -import { hasPermission } from '/app/authorization'; -import { Rooms } from '/app/models'; -import { callbacks } from '/app/callbacks'; +import { hasPermission } from 'meteor/rocketchat:authorization'; +import { Rooms, Integrations } from 'meteor/rocketchat:models'; +import { callbacks } from 'meteor/rocketchat:callbacks'; import { saveRoomName } from '../functions/saveRoomName'; import { saveRoomTopic } from '../functions/saveRoomTopic'; @@ -231,4 +231,10 @@ Meteor.methods({ rid: room._id, }; }, + changeChannelNameInWebhook(oldRoomName, newRoomName) { + const hashedOldRoomName = `#${ oldRoomName }`; + const hashedNewRoomName = `#${ newRoomName }`; + const changedNumber = Integrations.update({ channel: hashedOldRoomName }, { $set: { 'channel.$': hashedNewRoomName } }, { multi: true }); + return changedNumber; + }, });