Bug 1045569 - Revoke the correct call url in loop desktop client, r=rgauthier@mozilla.com
This commit is contained in:
@@ -263,7 +263,7 @@ loop.conversation = (function(OT, mozL10n) {
|
|||||||
*/
|
*/
|
||||||
declineAndBlock: function() {
|
declineAndBlock: function() {
|
||||||
navigator.mozLoop.stopAlerting();
|
navigator.mozLoop.stopAlerting();
|
||||||
var token = navigator.mozLoop.getLoopCharPref("loopToken");
|
var token = this._conversation.get("callToken");
|
||||||
this._client.deleteCallUrl(token, function(error) {
|
this._client.deleteCallUrl(token, function(error) {
|
||||||
// XXX The conversation window will be closed when this cb is triggered
|
// XXX The conversation window will be closed when this cb is triggered
|
||||||
// figure out if there is a better way to report the error to the user
|
// figure out if there is a better way to report the error to the user
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ loop.conversation = (function(OT, mozL10n) {
|
|||||||
*/
|
*/
|
||||||
declineAndBlock: function() {
|
declineAndBlock: function() {
|
||||||
navigator.mozLoop.stopAlerting();
|
navigator.mozLoop.stopAlerting();
|
||||||
var token = navigator.mozLoop.getLoopCharPref("loopToken");
|
var token = this._conversation.get("callToken");
|
||||||
this._client.deleteCallUrl(token, function(error) {
|
this._client.deleteCallUrl(token, function(error) {
|
||||||
// XXX The conversation window will be closed when this cb is triggered
|
// XXX The conversation window will be closed when this cb is triggered
|
||||||
// figure out if there is a better way to report the error to the user
|
// figure out if there is a better way to report the error to the user
|
||||||
|
|||||||
@@ -170,10 +170,6 @@ loop.panel = (function(_, mozL10n) {
|
|||||||
* Returns a random 5 character string used to identify
|
* Returns a random 5 character string used to identify
|
||||||
* the conversation.
|
* the conversation.
|
||||||
* XXX this will go away once the backend changes
|
* XXX this will go away once the backend changes
|
||||||
* @note:
|
|
||||||
* - When we get back a callUrl we use setLoopCharPref to store the token
|
|
||||||
* (the last fragment of the URL) so that it can be used to ignore&block
|
|
||||||
* the call. The preference is used by the conversation router.
|
|
||||||
*/
|
*/
|
||||||
conversationIdentifier: function() {
|
conversationIdentifier: function() {
|
||||||
return Math.random().toString(36).substring(5);
|
return Math.random().toString(36).substring(5);
|
||||||
@@ -199,7 +195,6 @@ loop.panel = (function(_, mozL10n) {
|
|||||||
var token = callUrlData.callToken ||
|
var token = callUrlData.callToken ||
|
||||||
callUrl.pathname.split('/').pop();
|
callUrl.pathname.split('/').pop();
|
||||||
|
|
||||||
navigator.mozLoop.setLoopCharPref('loopToken', token);
|
|
||||||
this.setState({pending: false, copied: false, callUrl: callUrl.href});
|
this.setState({pending: false, copied: false, callUrl: callUrl.href});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|||||||
@@ -170,10 +170,6 @@ loop.panel = (function(_, mozL10n) {
|
|||||||
* Returns a random 5 character string used to identify
|
* Returns a random 5 character string used to identify
|
||||||
* the conversation.
|
* the conversation.
|
||||||
* XXX this will go away once the backend changes
|
* XXX this will go away once the backend changes
|
||||||
* @note:
|
|
||||||
* - When we get back a callUrl we use setLoopCharPref to store the token
|
|
||||||
* (the last fragment of the URL) so that it can be used to ignore&block
|
|
||||||
* the call. The preference is used by the conversation router.
|
|
||||||
*/
|
*/
|
||||||
conversationIdentifier: function() {
|
conversationIdentifier: function() {
|
||||||
return Math.random().toString(36).substring(5);
|
return Math.random().toString(36).substring(5);
|
||||||
@@ -199,7 +195,6 @@ loop.panel = (function(_, mozL10n) {
|
|||||||
var token = callUrlData.callToken ||
|
var token = callUrlData.callToken ||
|
||||||
callUrl.pathname.split('/').pop();
|
callUrl.pathname.split('/').pop();
|
||||||
|
|
||||||
navigator.mozLoop.setLoopCharPref('loopToken', token);
|
|
||||||
this.setState({pending: false, copied: false, callUrl: callUrl.href});
|
this.setState({pending: false, copied: false, callUrl: callUrl.href});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|||||||
@@ -32,8 +32,10 @@ loop.shared.models = (function() {
|
|||||||
// requires.
|
// requires.
|
||||||
callType: undefined, // The type of incoming call selected by
|
callType: undefined, // The type of incoming call selected by
|
||||||
// other peer ("audio" or "audio-video")
|
// other peer ("audio" or "audio-video")
|
||||||
selectedCallType: undefined // The selected type for the call that was
|
selectedCallType: undefined, // The selected type for the call that was
|
||||||
// initiated ("audio" or "audio-video")
|
// initiated ("audio" or "audio-video")
|
||||||
|
callToken: undefined // Incoming call token.
|
||||||
|
// Used for blocking a call url
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,7 +170,8 @@ loop.shared.models = (function() {
|
|||||||
callId: sessionData.callId,
|
callId: sessionData.callId,
|
||||||
progressURL: sessionData.progressURL,
|
progressURL: sessionData.progressURL,
|
||||||
websocketToken: sessionData.websocketToken.toString(16),
|
websocketToken: sessionData.websocketToken.toString(16),
|
||||||
callType: sessionData.callType || "audio-video"
|
callType: sessionData.callType || "audio-video",
|
||||||
|
callToken: sessionData.callToken
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ describe("loop.conversation", function() {
|
|||||||
pendingCallTimeout: 1000,
|
pendingCallTimeout: 1000,
|
||||||
});
|
});
|
||||||
sandbox.stub(client, "requestCallsInfo");
|
sandbox.stub(client, "requestCallsInfo");
|
||||||
|
sandbox.spy(conversation, "setIncomingSessionData");
|
||||||
sandbox.stub(conversation, "setOutgoingSessionData");
|
sandbox.stub(conversation, "setOutgoingSessionData");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -201,7 +202,6 @@ describe("loop.conversation", function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
sandbox.stub(router, "_setupWebSocketAndCallView");
|
sandbox.stub(router, "_setupWebSocketAndCallView");
|
||||||
sandbox.stub(conversation, "setIncomingSessionData");
|
|
||||||
|
|
||||||
client.requestCallsInfo.callsArgWith(1, null, [fakeSessionData]);
|
client.requestCallsInfo.callsArgWith(1, null, [fakeSessionData]);
|
||||||
});
|
});
|
||||||
@@ -436,10 +436,23 @@ describe("loop.conversation", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should call delete call", function() {
|
it("should call delete call", function() {
|
||||||
var deleteCallUrl = sandbox.stub(loop.Client.prototype, "deleteCallUrl");
|
sandbox.stub(conversation, "get").withArgs("callToken")
|
||||||
|
.returns("fakeToken");
|
||||||
|
var deleteCallUrl = sandbox.stub(loop.Client.prototype,
|
||||||
|
"deleteCallUrl");
|
||||||
router.declineAndBlock();
|
router.declineAndBlock();
|
||||||
|
|
||||||
sinon.assert.calledOnce(deleteCallUrl);
|
sinon.assert.calledOnce(deleteCallUrl);
|
||||||
|
sinon.assert.calledWithExactly(deleteCallUrl, "fakeToken",
|
||||||
|
sinon.match.func);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should get callToken from conversation model", function() {
|
||||||
|
sandbox.stub(conversation, "get");
|
||||||
|
router.declineAndBlock();
|
||||||
|
|
||||||
|
sinon.assert.calledOnce(conversation.get);
|
||||||
|
sinon.assert.calledWithExactly(conversation.get, "callToken");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should trigger error handling in case of error", function() {
|
it("should trigger error handling in case of error", function() {
|
||||||
|
|||||||
@@ -352,12 +352,6 @@ describe("loop.panel", function() {
|
|||||||
sinon.assert.calledWithExactly(notifier.errorL10n,
|
sinon.assert.calledWithExactly(notifier.errorL10n,
|
||||||
"unable_retrieve_url");
|
"unable_retrieve_url");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set 'loopToken' with the callUrl token", function() {
|
|
||||||
sinon.assert.calledOnce(navigator.mozLoop.setLoopCharPref);
|
|
||||||
sinon.assert.calledWithExactly(navigator.mozLoop.setLoopCharPref,
|
|
||||||
"loopToken", "fakeToken");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ describe("loop.shared.models", function() {
|
|||||||
sessionToken: "sessionToken",
|
sessionToken: "sessionToken",
|
||||||
apiKey: "apiKey",
|
apiKey: "apiKey",
|
||||||
callType: "callType",
|
callType: "callType",
|
||||||
websocketToken: 123
|
websocketToken: 123,
|
||||||
|
callToken: "callToken"
|
||||||
};
|
};
|
||||||
fakeSession = _.extend({
|
fakeSession = _.extend({
|
||||||
connect: function () {},
|
connect: function () {},
|
||||||
@@ -159,6 +160,7 @@ describe("loop.shared.models", function() {
|
|||||||
expect(conversation.get("sessionToken")).eql("sessionToken");
|
expect(conversation.get("sessionToken")).eql("sessionToken");
|
||||||
expect(conversation.get("apiKey")).eql("apiKey");
|
expect(conversation.get("apiKey")).eql("apiKey");
|
||||||
expect(conversation.get("callType")).eql("callType");
|
expect(conversation.get("callType")).eql("callType");
|
||||||
|
expect(conversation.get("callToken")).eql("callToken");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user