From fb56aec96fbb6e2dce8ef01e63cf26a3a7f8b72b Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Wed, 1 Oct 2014 14:41:13 -0700 Subject: [PATCH] AppId-dependant HCP --- packages/autoupdate/autoupdate_cordova.js | 4 +++- packages/autoupdate/autoupdate_server.js | 8 +++++++- tools/commands-cordova.js | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/autoupdate/autoupdate_cordova.js b/packages/autoupdate/autoupdate_cordova.js index c33a295d2c..a25313bc4d 100644 --- a/packages/autoupdate/autoupdate_cordova.js +++ b/packages/autoupdate/autoupdate_cordova.js @@ -182,7 +182,8 @@ var retry = new Retry({ var failures = 0; Autoupdate._retrySubscription = function () { - Meteor.subscribe("meteor_autoupdate_clientVersions", { + var appId = __meteor_runtime_config__.appId; + Meteor.subscribe("meteor_autoupdate_clientVersions", appId, { onError: function (err) { Meteor._debug("autoupdate subscription failed:", err); failures++; @@ -216,3 +217,4 @@ Autoupdate._retrySubscription = function () { }; Meteor.startup(Autoupdate._retrySubscription); + diff --git a/packages/autoupdate/autoupdate_server.js b/packages/autoupdate/autoupdate_server.js index c27202f0df..bdbbae2233 100644 --- a/packages/autoupdate/autoupdate_server.js +++ b/packages/autoupdate/autoupdate_server.js @@ -49,6 +49,7 @@ ClientVersions = new Mongo.Collection("meteor_autoupdate_clientVersions", Autoupdate.autoupdateVersion = null; Autoupdate.autoupdateVersionRefreshable = null; Autoupdate.autoupdateVersionCordova = null; +Autoupdate.appId = __meteor_runtime_config__.appId = process.env.APP_ID; var syncQueue = new Meteor._SynchronousQueue(); @@ -135,7 +136,12 @@ var updateVersions = function (shouldReloadClientProgram) { Meteor.publish( "meteor_autoupdate_clientVersions", - function () { + function (appId) { + // Don't notify clients using wrong appId such as mobile apps built with a + // different server but pointing at the same local url + if (Autoupdate.appId && appId && Autoupdate.appId !== appId) + return []; + return ClientVersions.find(); }, {is_auto: true} diff --git a/tools/commands-cordova.js b/tools/commands-cordova.js index 664ab6f189..b2df2b84ad 100644 --- a/tools/commands-cordova.js +++ b/tools/commands-cordova.js @@ -279,7 +279,8 @@ var generateCordovaBoilerplate = function (clientDir, options) { options.host + ':' + options.port, autoupdateVersionCordova: version, cleanCache: options.clean, - httpProxyPort: options.httpProxyPort + httpProxyPort: options.httpProxyPort, + appId: project.appId }; if (publicSettings)