Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
knrt10 committed Mar 11, 2019
1 parent c42b43f commit c7c9714
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { hasPermission } from 'meteor/rocketchat:authorization';
import { Rooms } from 'meteor/rocketchat:models';
import { Rooms, Integrations } from 'meteor/rocketchat:models';
import { callbacks } from 'meteor/rocketchat:callbacks';

import { saveRoomName } from '../functions/saveRoomName';
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 c7c9714

Please sign in to comment.