Skip to content
Snippets Groups Projects
Commit 1977d10e authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Change channel type; Closes #1037

parent 4b8fac9d
No related branches found
No related tags found
No related merge requests found
Showing
with 83 additions and 19 deletions
......@@ -123,6 +123,7 @@ reload@1.1.4
retry@1.0.4
rocketchat:authorization@0.0.1
rocketchat:autolinker@0.0.1
rocketchat:channel-settings@0.0.1
rocketchat:colors@0.0.1
rocketchat:custom-oauth@1.0.0
rocketchat:emojione@0.0.1
......
......@@ -110,13 +110,7 @@ RocketChat.Notifications.onUser 'message', (msg) ->
Meteor.defer ->
RoomManager.updateMentionsMarksOfRoom typeName
# If room was renamed then close current room and send user to the new one
Tracker.nonreactive ->
if msg.t is 'r'
if Session.get('openedRoom') is msg.rid
type = if FlowRouter.current().route.name is 'channel' then 'c' else 'p'
RoomManager.close type + FlowRouter.getParam('name')
FlowRouter.go FlowRouter.current().route.name, name: msg.msg
RocketChat.callbacks.run 'streamMessage', msg
RocketChat.Notifications.onRoom openedRooms[typeName].rid, 'deleteMessage', onDeleteMessageStream
......
Meteor.startup ->
roomNameChangedCallback = (msg) ->
Tracker.nonreactive ->
if msg.t is 'r'
if Session.get('openedRoom') is msg.rid
type = if FlowRouter.current().route.name is 'channel' then 'c' else 'p'
RoomManager.close type + FlowRouter.getParam('name')
FlowRouter.go FlowRouter.current().route.name, name: msg.msg
return msg
RocketChat.callbacks.add 'streamMessage', roomNameChangedCallback, RocketChat.callbacks.priority.HIGH
......@@ -9,7 +9,7 @@ Template.videoCall.helpers
videoActive: ->
webrtc = WebRTC.getInstanceByRoomId(Session.get('openedRoom'))
overlay = @overlay?
if overlay isnt webrtc.overlayEnabled.get()
if overlay isnt webrtc?.overlayEnabled.get()
return false
return webrtc.localUrl.get()? or webrtc.remoteItems.get()?.length > 0
......
Meteor.startup ->
RocketChat.MessageTypes.registerType
id: 'room_changed_privacy'
system: true
message: 'room_changed_privacy'
data: (message) ->
return {
user_by: message.u?.username
room_type: message.msg
}
RocketChat.MessageTypes.registerType
id: 'room_changed_topic'
system: true
message: 'room_changed_topic'
data: (message) ->
return {
user_by: message.u?.username
room_topic: message.msg
}
Meteor.startup ->
RocketChat.callbacks.add 'enter-room', ->
RocketChat.callbacks.add 'enter-room', (subscription) ->
if RocketChat.authz.hasAtLeastOnePermission('edit-room', subscription?.rid)
RocketChat.TabBar.addButton
id: 'channel-settings'
i18nTitle: 'Channel_Settings'
icon: 'octicon octicon-gear'
template: 'channelSettings'
order: 0
, RocketChat.callbacks.priority.MEDIUM, 'enter-room-tabbar-channel-settings'
Meteor.startup ->
roomSettingsChangedCallback = (msg) ->
Tracker.nonreactive ->
if msg.t is 'room_changed_privacy'
if Session.get('openedRoom') is msg.rid
type = if FlowRouter.current().route.name is 'channel' then 'c' else 'p'
RoomManager.close type + FlowRouter.getParam('name')
subscription = ChatSubscription.findOne({ rid: msg.rid })
route = if subscription.t is 'c' then 'channel' else 'group'
FlowRouter.go route, name: subscription.name
return msg
RocketChat.callbacks.add 'streamMessage', roomSettingsChangedCallback, RocketChat.callbacks.priority.HIGH
......@@ -8,9 +8,16 @@ Template.channelSettings.events
'click .save': (e, t) ->
e.preventDefault()
settings =
settings =
roomType: t.$('input[name=roomType]:checked').val()
Meteor.call 'saveRoomSettings', t.data.rid, settings, (err, results) ->
return toastr.error err.reason if err
toastr.success TAPi18n.__ 'Settings_updated'
\ No newline at end of file
toastr.success TAPi18n.__ 'Settings_updated'
# switch room.t
# when 'c'
# FlowRouter.go 'channel', name: name
# when 'p'
# FlowRouter.go 'group', name: name
......@@ -2,5 +2,7 @@
"Channel": "Channel",
"Private_Group": "Private Group",
"Room_Type": "Room Type",
"Room_Settings": "Room Settings"
"Room_Settings": "Room Settings",
"room_changed_privacy": "Room type changed to: <em>__room_type__</em> by <em>__user_by__</em>",
"room_changed_topic": "Room topic changed to: <em>__room_topic__</em> by <em>__user_by__</em>"
}
......@@ -16,15 +16,18 @@ Package.onUse(function(api) {
]);
api.addFiles([
'client/tabBar.coffee',
'client/startup/messageTypes.coffee',
'client/startup/tabBar.coffee',
'client/startup/trackSettingsChange.coffee',
'client/views/channelSettings.html',
'client/views/channelSettings.coffee',
'client/stylesheets/channel-settings.less',
'client/stylesheets/channel-settings.less'
], 'client');
api.addFiles([
'server/functions/changeRoomType.coffee',
'server/methods/saveRoomSettings.coffee'
'server/methods/saveRoomSettings.coffee',
'server/models/Messages.coffee'
], 'server');
// TAPi18n
......
Meteor.methods
Meteor.methods
saveRoomSettings: (rid, settings) ->
console.log '[method] saveRoomSettings'.green, rid, settings
......@@ -16,4 +16,11 @@ Meteor.methods
if settings.roomType isnt room.t
RocketChat.changeRoomType(rid, settings.roomType)
return true
\ No newline at end of file
if settings.roomType is 'c'
message = TAPi18n.__('Channel')
else
message = TAPi18n.__('Private_Group')
RocketChat.models.Messages.createRoomSettingsChangedWithTypeRoomIdMessageAndUser 'room_changed_privacy', rid, message, Meteor.user()
return true
RocketChat.models.Messages.createRoomSettingsChangedWithTypeRoomIdMessageAndUser = (type, roomId, message, user, extraData) ->
return @createWithTypeRoomIdMessageAndUser type, roomId, message, user, extraData
......@@ -62,4 +62,4 @@ currentTracker = undefined
if ChatSubscription.findOne({rid: room._id})?.open is false
Meteor.call 'openRoom', room._id
RocketChat.callbacks.run 'enter-room'
RocketChat.callbacks.run 'enter-room', ChatSubscription.findOne({rid: room._id})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment