Keep only public settings using notifyAll

pull/5534/head
Rodrigo Nascimento 8 years ago
parent 0e3faccb3c
commit a4df5b2ccc
No known key found for this signature in database
GPG Key ID: 2C85B3AFE75D23F9
  1. 2
      client/notifications/updateAvatar.js
  2. 2
      packages/rocketchat-authorization/client/lib/ChatPermissions.coffee
  3. 2
      packages/rocketchat-authorization/server/methods/addUserToRole.coffee
  4. 2
      packages/rocketchat-authorization/server/methods/removeUserFromRole.coffee
  5. 2
      packages/rocketchat-authorization/server/methods/saveRole.coffee
  6. 2
      packages/rocketchat-authorization/server/publications/permissions.js
  7. 2
      packages/rocketchat-emoji-custom/client/notifications/deleteEmojiCustom.js
  8. 2
      packages/rocketchat-emoji-custom/client/notifications/updateEmojiCustom.js
  9. 2
      packages/rocketchat-emoji-custom/server/methods/deleteEmojiCustom.js
  10. 4
      packages/rocketchat-emoji-custom/server/methods/insertOrUpdateEmoji.js
  11. 2
      packages/rocketchat-emoji-custom/server/methods/uploadEmojiCustom.js
  12. 2
      packages/rocketchat-ldap/server/sync.js
  13. 15
      packages/rocketchat-lib/client/Notifications.coffee
  14. 2
      packages/rocketchat-lib/client/lib/userRoles.js
  15. 4
      packages/rocketchat-lib/server/functions/Notifications.coffee
  16. 2
      packages/rocketchat-lib/server/functions/setUserAvatar.js
  17. 2
      packages/rocketchat-lib/server/publications/settings.coffee
  18. 2
      packages/rocketchat-ui-admin/admin/admin.coffee
  19. 2
      packages/rocketchat-ui-admin/admin/adminFlex.coffee
  20. 2
      server/methods/addRoomModerator.coffee
  21. 2
      server/methods/addRoomOwner.coffee
  22. 2
      server/methods/removeRoomModerator.coffee
  23. 2
      server/methods/removeRoomOwner.coffee
  24. 2
      server/methods/resetAvatar.coffee

@ -1,7 +1,7 @@
/* globals updateAvatarOfUsername */
Meteor.startup(function() {
RocketChat.Notifications.onAll('updateAvatar', function(data) {
RocketChat.Notifications.onLogged('updateAvatar', function(data) {
updateAvatarOfUsername(data.username);
});
});

@ -1,2 +1,2 @@
RocketChat.authz.cachedCollection = new RocketChat.CachedCollection({ name: 'permissions', eventType: 'onAll', initOnLogin: true })
RocketChat.authz.cachedCollection = new RocketChat.CachedCollection({ name: 'permissions', eventType: 'onLogged', initOnLogin: true })
@ChatPermissions = RocketChat.authz.cachedCollection.collection

@ -17,6 +17,6 @@ Meteor.methods
add = RocketChat.models.Roles.addUserRoles user._id, roleName, scope
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: roleName, u: { _id: user._id, username: username }, scope: scope });
RocketChat.Notifications.notifyLogged('roles-change', { type: 'added', _id: roleName, u: { _id: user._id, username: username }, scope: scope });
return add

@ -21,6 +21,6 @@ Meteor.methods
remove = RocketChat.models.Roles.removeUserRoles user._id, roleName, scope
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: roleName, u: { _id: user._id, username: username }, scope: scope });
RocketChat.Notifications.notifyLogged('roles-change', { type: 'removed', _id: roleName, u: { _id: user._id, username: username }, scope: scope });
return remove

@ -12,6 +12,6 @@ Meteor.methods
update = RocketChat.models.Roles.createOrUpdate roleData.name, roleData.scope, roleData.description
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'changed', _id: roleData.name });
RocketChat.Notifications.notifyLogged('roles-change', { type: 'changed', _id: roleData.name });
return update

@ -19,5 +19,5 @@ Meteor.methods({
RocketChat.models.Permissions.on('changed', (type, permission) => {
RocketChat.Notifications.notifyAllInThisInstance('permissions-changed', type, permission);
RocketChat.Notifications.notifyLoggedInThisInstance('permissions-changed', type, permission);
});

@ -1,4 +1,4 @@
/* globals deleteEmojiCustom */
Meteor.startup(() =>
RocketChat.Notifications.onAll('deleteEmojiCustom', data => deleteEmojiCustom(data.emojiData))
RocketChat.Notifications.onLogged('deleteEmojiCustom', data => deleteEmojiCustom(data.emojiData))
);

@ -1,4 +1,4 @@
/* globals updateEmojiCustom */
Meteor.startup(() =>
RocketChat.Notifications.onAll('updateEmojiCustom', data => updateEmojiCustom(data.emojiData))
RocketChat.Notifications.onLogged('updateEmojiCustom', data => updateEmojiCustom(data.emojiData))
);

@ -15,7 +15,7 @@ Meteor.methods({
RocketChatFileEmojiCustomInstance.deleteFile(encodeURIComponent(`${emoji.name}.${emoji.extension}`));
RocketChat.models.EmojiCustom.removeByID(emojiID);
RocketChat.Notifications.notifyAll('deleteEmojiCustom', {emojiData: emoji});
RocketChat.Notifications.notifyLogged('deleteEmojiCustom', {emojiData: emoji});
return true;
}

@ -64,7 +64,7 @@ Meteor.methods({
let _id = RocketChat.models.EmojiCustom.create(createEmoji);
RocketChat.Notifications.notifyAll('updateEmojiCustom', {emojiData: createEmoji});
RocketChat.Notifications.notifyLogged('updateEmojiCustom', {emojiData: createEmoji});
return _id;
} else {
@ -98,7 +98,7 @@ Meteor.methods({
RocketChat.models.EmojiCustom.setAliases(emojiData._id, []);
}
RocketChat.Notifications.notifyAll('updateEmojiCustom', {emojiData});
RocketChat.Notifications.notifyLogged('updateEmojiCustom', {emojiData});
return true;
}

@ -13,7 +13,7 @@ Meteor.methods({
RocketChatFileEmojiCustomInstance.deleteFile(encodeURIComponent(`${emojiData.name}.${emojiData.extension}`));
let ws = RocketChatFileEmojiCustomInstance.createWriteStream(encodeURIComponent(`${emojiData.name}.${emojiData.extension}`), contentType);
ws.on('end', Meteor.bindEnvironment(() =>
Meteor.setTimeout(() => RocketChat.Notifications.notifyAll('updateEmojiCustom', {emojiData})
Meteor.setTimeout(() => RocketChat.Notifications.notifyLogged('updateEmojiCustom', {emojiData})
, 500)
));

@ -145,7 +145,7 @@ syncUserData = function syncUserData(user, ldapUser) {
ws.on('end', Meteor.bindEnvironment(function() {
Meteor.setTimeout(function() {
RocketChat.models.Users.setAvatarOrigin(user._id, 'ldap');
RocketChat.Notifications.notifyAll('updateAvatar', {username: user.username});
RocketChat.Notifications.notifyLogged('updateAvatar', {username: user.username});
}, 500);
}));
rs.pipe(ws);

@ -1,5 +1,13 @@
RocketChat.Notifications = new class
constructor: ->
@logged = Meteor.userId() isnt null
@loginCb = []
Tracker.autorun =>
if Meteor.userId() isnt null and this.logged is false
cb() for cb in this.loginCb
@logged = Meteor.userId() isnt null
@debug = false
@streamAll = new Meteor.Streamer 'notify-all'
@streamLogged = new Meteor.Streamer 'notify-logged'
@ -11,6 +19,10 @@ RocketChat.Notifications = new class
@onAll -> console.log "RocketChat.Notifications: onAll", arguments
@onUser -> console.log "RocketChat.Notifications: onAll", arguments
onLogin: (cb) ->
@loginCb.push(cb)
if @logged
cb()
notifyRoom: (room, eventName, args...) ->
console.log "RocketChat.Notifications: notifyRoom", arguments if @debug is true
@ -34,7 +46,8 @@ RocketChat.Notifications = new class
@streamAll.on eventName, callback
onLogged: (eventName, callback) ->
@streamLogged.on eventName, callback
@onLogin =>
@streamLogged.on eventName, callback
onRoom: (room, eventName, callback) ->
if @debug is true

@ -13,7 +13,7 @@ Meteor.startup(function() {
}
});
RocketChat.Notifications.onAll('roles-change', function(role) {
RocketChat.Notifications.onLogged('roles-change', function(role) {
if (role.type === 'added') {
if (role.scope) {
RoomRoles.upsert({ rid: role.scope, 'u._id': role.u._id }, { $setOnInsert: { u: role.u }, $addToSet: { roles: role._id } });

@ -60,7 +60,7 @@ RocketChat.Notifications = new class
console.log 'notifyLogged', arguments if @debug is true
args.unshift eventName
@streamLogged.emit.apply @streamAll, args
@streamLogged.emit.apply @streamLogged, args
notifyRoom: (room, eventName, args...) ->
console.log 'notifyRoom', arguments if @debug is true
@ -85,7 +85,7 @@ RocketChat.Notifications = new class
console.log 'notifyLogged', arguments if @debug is true
args.unshift eventName
@streamLogged.emitWithoutBroadcast.apply @streamAll, args
@streamLogged.emitWithoutBroadcast.apply @streamLogged, args
notifyRoomInThisInstance: (room, eventName, args...) ->
console.log 'notifyRoomAndBroadcast', arguments if @debug is true

@ -42,7 +42,7 @@ RocketChat.setUserAvatar = function(user, dataURI, contentType, service) {
ws.on('end', Meteor.bindEnvironment(function() {
Meteor.setTimeout(function() {
RocketChat.models.Users.setAvatarOrigin(user._id, service);
RocketChat.Notifications.notifyAll('updateAvatar', {username: user.username});
RocketChat.Notifications.notifyLogged('updateAvatar', {username: user.username});
}, 500);
}));
rs.pipe(ws);

@ -41,7 +41,7 @@ RocketChat.models.Settings.cache.on 'changed', (type, setting) ->
if setting.public is true
RocketChat.Notifications.notifyAllInThisInstance 'public-settings-changed', type, _.pick(setting, '_id', 'value')
RocketChat.Notifications.notifyAllInThisInstance 'private-settings-changed', type, setting
RocketChat.Notifications.notifyLoggedInThisInstance 'private-settings-changed', type, setting
RocketChat.Notifications.streamAll.allowRead 'private-settings-changed', ->

@ -25,7 +25,7 @@ setFieldValue = (settingId, value, type, editor) ->
Template.admin.onCreated ->
if not RocketChat.settings.cachedCollectionPrivate?
RocketChat.settings.cachedCollectionPrivate = new RocketChat.CachedCollection({ name: 'private-settings', eventType: 'onAll' })
RocketChat.settings.cachedCollectionPrivate = new RocketChat.CachedCollection({ name: 'private-settings', eventType: 'onLogged' })
RocketChat.settings.collectionPrivate = RocketChat.settings.cachedCollectionPrivate.collection
RocketChat.settings.cachedCollectionPrivate.init()

@ -2,7 +2,7 @@ Template.adminFlex.onCreated ->
@settingsFilter = new ReactiveVar('')
if not RocketChat.settings.cachedCollectionPrivate?
RocketChat.settings.cachedCollectionPrivate = new RocketChat.CachedCollection({ name: 'private-settings', eventType: 'onAll' })
RocketChat.settings.cachedCollectionPrivate = new RocketChat.CachedCollection({ name: 'private-settings', eventType: 'onLogged' })
RocketChat.settings.collectionPrivate = RocketChat.settings.cachedCollectionPrivate.collection
RocketChat.settings.cachedCollectionPrivate.init()

@ -32,6 +32,6 @@ Meteor.methods
role: 'moderator'
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid });
RocketChat.Notifications.notifyLogged('roles-change', { type: 'added', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid });
return true

@ -32,6 +32,6 @@ Meteor.methods
role: 'owner'
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid });
RocketChat.Notifications.notifyLogged('roles-change', { type: 'added', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid });
return true

@ -32,6 +32,6 @@ Meteor.methods
role: 'moderator'
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid });
RocketChat.Notifications.notifyLogged('roles-change', { type: 'removed', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid });
return true

@ -36,6 +36,6 @@ Meteor.methods
role: 'owner'
if RocketChat.settings.get('UI_DisplayRoles')
RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid });
RocketChat.Notifications.notifyLogged('roles-change', { type: 'removed', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid });
return true

@ -12,7 +12,7 @@ Meteor.methods
RocketChat.models.Users.unsetAvatarOrigin user._id
RocketChat.Notifications.notifyAll 'updateAvatar', {username: user.username}
RocketChat.Notifications.notifyLogged 'updateAvatar', {username: user.username}
return
# Limit changing avatar once per minute

Loading…
Cancel
Save