Bug 1033579 - Add channel to POST calls for Loop to allow different servers based on the channel. r=dmose
authorAdam Roach [:abr] <adam@nostrum.com>
Thu, 23 Oct 2014 20:37:58 +0100
changeset 212114 e2f7534c7687cd9c4d25b3b073ae6b5906c42f73
parent 211984 a97b95030a94fc51e7bd988c6ccbd1bd2afe0d2d
child 212115 1db368e224b74c29ba7b1447ae9c095778963054
push id27698
push usercbook@mozilla.com
push dateFri, 24 Oct 2014 13:53:50 +0000
treeherdermozilla-central@6e35802ae3e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmose
bugs1033579
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1033579 - Add channel to POST calls for Loop to allow different servers based on the channel. r=dmose
browser/components/loop/content/js/client.js
browser/components/loop/standalone/content/js/standaloneClient.js
browser/components/loop/test/desktop-local/client_test.js
browser/components/loop/test/standalone/standalone_client_test.js
--- a/browser/components/loop/content/js/client.js
+++ b/browser/components/loop/content/js/client.js
@@ -227,17 +227,19 @@ loop.Client = (function($) {
      * @param {Function} cb Callback(err, result)
      */
     setupOutgoingCall: function(calleeIds, callType, cb) {
       // For direct calls, we only ever use the logged-in session. Direct
       // calls by guests aren't valid.
       this.mozLoop.hawkRequest(this.mozLoop.LOOP_SESSION_TYPE.FXA,
         "/calls", "POST", {
           calleeId: calleeIds,
-          callType: callType
+          callType: callType,
+          channel: this.mozLoop.appVersionInfo ?
+                   this.mozLoop.appVersionInfo.channel : "unknown"
         },
         function (err, responseText) {
           if (err) {
             this._failureHandler(cb, err);
             return;
           }
 
           try {
--- a/browser/components/loop/standalone/content/js/standaloneClient.js
+++ b/browser/components/loop/standalone/content/js/standaloneClient.js
@@ -110,17 +110,17 @@ loop.StandaloneClient = (function($) {
         throw new Error("missing required parameter loopToken");
       }
 
       var req = $.ajax({
         url:         this.settings.baseServerUrl + "/calls/" + loopToken,
         method:      "POST",
         contentType: "application/json",
         dataType:    "json",
-        data: JSON.stringify({callType: callType})
+        data: JSON.stringify({callType: callType, channel: "standalone"})
       });
 
       req.done(function(sessionData) {
         try {
           cb(null, this._validate(sessionData, expectedCallsProperties));
         } catch (err) {
           console.error("Error requesting call info", err.message);
           cb(err);
--- a/browser/components/loop/test/desktop-local/client_test.js
+++ b/browser/components/loop/test/desktop-local/client_test.js
@@ -267,17 +267,33 @@ describe("loop.Client", function() {
       it("should make a POST call to /calls", function() {
         client.setupOutgoingCall(calleeIds, callType);
 
         sinon.assert.calledOnce(hawkRequestStub);
         sinon.assert.calledWith(hawkRequestStub,
           mozLoop.LOOP_SESSION_TYPE.FXA,
           "/calls",
           "POST",
-          { calleeId: calleeIds, callType: callType }
+          { calleeId: calleeIds, callType: callType, channel: "unknown" }
+        );
+      });
+
+      it("should include the channel when defined", function() {
+        mozLoop.appVersionInfo = {
+          channel: "beta"
+        };
+
+        client.setupOutgoingCall(calleeIds, callType);
+
+        sinon.assert.calledOnce(hawkRequestStub);
+        sinon.assert.calledWith(hawkRequestStub,
+          mozLoop.LOOP_SESSION_TYPE.FXA,
+          "/calls",
+          "POST",
+          { calleeId: calleeIds, callType: callType, channel: "beta" }
         );
       });
 
       it("should call the callback if the request is successful", function() {
         var requestData = {
           apiKey: "fake",
           callId: "fakeCall",
           progressURL: "fakeurl",
--- a/browser/components/loop/test/standalone/standalone_client_test.js
+++ b/browser/components/loop/test/standalone/standalone_client_test.js
@@ -123,17 +123,17 @@ describe("loop.StandaloneClient", functi
         });
 
       it("should post data for the given call", function() {
         client.requestCallInfo("fake", "audio", callback);
 
         expect(requests).to.have.length.of(1);
         expect(requests[0].url).to.be.equal("http://fake.api/calls/fake");
         expect(requests[0].method).to.be.equal("POST");
-        expect(requests[0].requestBody).to.be.equal('{"callType":"audio"}');
+        expect(requests[0].requestBody).to.be.equal('{"callType":"audio","channel":"standalone"}');
       });
 
       it("should receive call data for the given call", function() {
         client.requestCallInfo("fake", "audio-video", callback);
 
         var sessionData = {
           sessionId: "one",
           sessionToken: "two",