Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
knrt10 committed Mar 13, 2019
1 parent 761ad9b commit e92dbaa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/channel-settings/client/views/channelSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
},
Expand Down
12 changes: 9 additions & 3 deletions app/channel-settings/server/methods/saveRoomSettings.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
},
});

0 comments on commit e92dbaa

Please sign in to comment.