Skip to content

Commit

Permalink
Rebased branch
Browse files Browse the repository at this point in the history
  • Loading branch information
knrt10 committed Mar 13, 2019
1 parent e92dbaa commit 0a4f607
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
3 changes: 1 addition & 2 deletions app/channel-settings/client/views/channelSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ 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
8 changes: 7 additions & 1 deletion app/channel-settings/server/functions/saveRoomName.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ export const saveRoomName = function(rid, displayName, user, sendMessage = true)

const update = Rooms.setNameById(rid, slugifiedRoomName, displayName) && Subscriptions.updateNameAndAlertByRoomId(rid, slugifiedRoomName, displayName);

if (update && sendMessage) {
if (!update) {
return;
}

Integrations.updateRoomName(room.name, displayName);

if (sendMessage) {
Messages.createRoomRenamedWithRoomIdRoomNameAndUser(rid, displayName, user);
}
return displayName;
Expand Down
12 changes: 3 additions & 9 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 'meteor/rocketchat:authorization';
import { Rooms, Integrations } from 'meteor/rocketchat:models';
import { callbacks } from 'meteor/rocketchat:callbacks';
import { hasPermission } from '/app/authorization';
import { Rooms } from '/app/models';
import { callbacks } from '/app/callbacks';

import { saveRoomName } from '../functions/saveRoomName';
import { saveRoomTopic } from '../functions/saveRoomTopic';
Expand Down Expand Up @@ -231,10 +231,4 @@ 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;
},
});
7 changes: 7 additions & 0 deletions app/models/server/models/Integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export class Integrations extends Base {
disableByUserId(userId) {
return this.update({ userId }, { $set: { enabled: false } }, { multi: true });
}

updateRoomName(oldRoomName, newRoomName) {
const hashedOldRoomName = `#${ oldRoomName }`;
const hashedNewRoomName = `#${ newRoomName }`;
const changedNumber = Integrations.update({ channel: hashedOldRoomName }, { $set: { 'channel.$': hashedNewRoomName } }, { multi: true });
return changedNumber;
}
}

export default new Integrations();

0 comments on commit 0a4f607

Please sign in to comment.