diff --git a/.meteor/packages b/.meteor/packages index b626ea4eb9ab..63584ba4bf24 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -41,7 +41,6 @@ rocketchat:autolinker rocketchat:emojione rocketchat:file rocketchat:highlight -rocketchat:hubot #rocketchat:irc rocketchat:ldap rocketchat:lib @@ -59,3 +58,4 @@ yasaricli:slugify konecty:nrr konecty:change-case kevohagan:sweetalert +mizzao:partitioner diff --git a/.meteor/versions b/.meteor/versions index bf04d881ccfc..45243173c17f 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -68,6 +68,7 @@ meteorspark:util@0.2.0 minifiers@1.1.5 minimongo@1.0.8 mizzao:autocomplete@0.5.1 +mizzao:partitioner@0.5.4 mizzao:timesync@0.3.1 mobile-status-bar@1.0.3 momentjs:moment@2.10.3 @@ -97,7 +98,6 @@ rocketchat:autolinker@0.0.1 rocketchat:emojione@0.0.1 rocketchat:file@0.0.1 rocketchat:highlight@0.0.1 -rocketchat:hubot@0.0.1 rocketchat:ldap@0.0.1 rocketchat:lib@0.0.1 rocketchat:markdown@0.0.1 diff --git a/client/jaysCode/onLogin.coffee b/client/jaysCode/onLogin.coffee new file mode 100644 index 000000000000..39a8c61b8cf6 --- /dev/null +++ b/client/jaysCode/onLogin.coffee @@ -0,0 +1,2 @@ +Accounts.onLogin () -> + Meteor.call('setDefaultGroup') diff --git a/client/lib/RoomManager.coffee b/client/lib/RoomManager.coffee index 75f27efc820e..c412ee6cc3ef 100644 --- a/client/lib/RoomManager.coffee +++ b/client/lib/RoomManager.coffee @@ -6,8 +6,9 @@ Dep = new Tracker.Dependency init = -> - subscription = Meteor.subscribe('subscription') - return subscription + # Tracker.autorun -> + subscription = Meteor.subscribe('subscription') + return subscription close = (rid) -> if openedRooms[rid] @@ -24,12 +25,12 @@ computation = Tracker.autorun -> for rid, record of openedRooms when record.active is true record.sub = [ - Meteor.subscribe 'room', rid - Meteor.subscribe 'messages', rid + Meteor.subscribe 'room', rid, Partitioner.group() + Meteor.subscribe 'messages', rid, Partitioner.group() ] record.ready = record.sub[0].ready() and record.sub[1].ready() - + Dep.changed() setRoomExpireExcept = (except) -> diff --git a/client/lib/collections.coffee b/client/lib/collections.coffee index aa2e8ebf1cd7..e8fb53da9cee 100644 --- a/client/lib/collections.coffee +++ b/client/lib/collections.coffee @@ -1,9 +1,14 @@ @UserAndRoom = new Meteor.Collection null +Partitioner.partitionCollection(@UserAndRoom) @ChatMessageHistory = new Meteor.Collection null +Partitioner.partitionCollection(@ChatMessageHistory) @ChatRoom = new Meteor.Collection 'data.ChatRoom' +Partitioner.partitionCollection(@ChatRoom) @ChatSubscription = new Meteor.Collection 'data.ChatSubscription' +Partitioner.partitionCollection(@ChatSubscription) @ChatMessage = new Meteor.Collection 'data.ChatMessage' +Partitioner.partitionCollection(@ChatMessage) Meteor.startup -> ChatMessage.find().observe diff --git a/packages/meteor-partitioner b/packages/meteor-partitioner new file mode 160000 index 000000000000..c4d9323d081e --- /dev/null +++ b/packages/meteor-partitioner @@ -0,0 +1 @@ +Subproject commit c4d9323d081ec17ae424ecc0237a7e8e5758e258 diff --git a/packages/rocketchat-oembed/package.js b/packages/rocketchat-oembed/package.js index b4459f25d298..bac7b1d66949 100644 --- a/packages/rocketchat-oembed/package.js +++ b/packages/rocketchat-oembed/package.js @@ -11,7 +11,8 @@ Package.onUse(function(api) { api.use([ 'templating', 'coffeescript', - 'rocketchat:lib@0.0.1' + 'rocketchat:lib@0.0.1', + 'mizzao:partitioner' ]); api.addFiles('client/baseWidget.html', 'client'); diff --git a/packages/rocketchat-oembed/server/server.coffee b/packages/rocketchat-oembed/server/server.coffee index 9d8db27ab6d1..5af4d5ec9155 100644 --- a/packages/rocketchat-oembed/server/server.coffee +++ b/packages/rocketchat-oembed/server/server.coffee @@ -6,6 +6,8 @@ querystring = Npm.require('querystring') OEmbed = cache: new Meteor.Collection 'oembed_cache' +Partitioner.partitionCollection(OEmbed.cache) + getUrlContent = (urlObj, redirectCount = 5, callback) -> if _.isString(urlObj) urlObj = URL.parse urlObj diff --git a/server/lib/_settings.coffee b/server/lib/_settings.coffee index 142f2426cf3d..d4881a2e77fa 100644 --- a/server/lib/_settings.coffee +++ b/server/lib/_settings.coffee @@ -1,4 +1,5 @@ @Settings = new Meteor.Collection 'settings' +Partitioner.partitionCollection(@Settings) loadEnvConfigs = (settings) -> if settings.ENV? diff --git a/server/lib/collections.coffee b/server/lib/collections.coffee index 5bc7b20bf634..5579c77fa64e 100644 --- a/server/lib/collections.coffee +++ b/server/lib/collections.coffee @@ -1,3 +1,6 @@ @ChatMessage = new Meteor.Collection 'data.ChatMessage' +Partitioner.partitionCollection(@ChatMessage); @ChatRoom = new Meteor.Collection 'data.ChatRoom' +Partitioner.partitionCollection(@ChatRoom); @ChatSubscription = new Meteor.Collection 'data.ChatSubscription' +Partitioner.partitionCollection(@ChatSubscription); diff --git a/server/methods/partitionerMethods.coffee b/server/methods/partitionerMethods.coffee new file mode 100644 index 000000000000..40e9c8476b33 --- /dev/null +++ b/server/methods/partitionerMethods.coffee @@ -0,0 +1,5 @@ +Meteor.methods + setDefaultGroup: -> + console.log this.userId + if not Partitioner.group()? + Partitioner.setUserGroup(this.userId, 'lobby') diff --git a/server/startup/initialData.coffee b/server/startup/initialData.coffee index 59f4c59412ce..c79234c48970 100644 --- a/server/startup/initialData.coffee +++ b/server/startup/initialData.coffee @@ -1,7 +1,6 @@ Meteor.startup -> Meteor.defer -> - if not ChatRoom.findOne('name': 'general')? ChatRoom.insert _id: 'GENERAL'