Bug 1102170 - Share a room url by email when Loop direct call fails. r=Standard8

This commit is contained in:
Nicolas Perriault
2014-12-10 22:51:53 +01:00
parent 7bc0d31266
commit 916993ead5
7 changed files with 120 additions and 54 deletions

View File

@@ -76,10 +76,12 @@ loop.shared.actions = (function() {
}),
/**
* Fetch a new call url from the server, intended to be sent over email when
* Fetch a new room url from the server, intended to be sent over email when
* a contact can't be reached.
*/
FetchEmailLink: Action.define("fetchEmailLink", {
FetchRoomEmailLink: Action.define("fetchRoomEmailLink", {
roomOwner: String,
roomName: String
}),
/**

View File

@@ -210,7 +210,7 @@ loop.store = loop.store || {};
"retryCall",
"mediaConnected",
"setMute",
"fetchEmailLink"
"fetchRoomEmailLink"
]);
this.setStoreState({
@@ -323,18 +323,21 @@ loop.store = loop.store || {};
},
/**
* Fetches a new call URL intended to be sent over email when a contact
* Fetches a new room URL intended to be sent over email when a contact
* can't be reached.
*/
fetchEmailLink: function() {
// XXX This is an empty string as a conversation identifier. Bug 1015938 implements
// a user-set string.
this.client.requestCallUrl("", function(err, callUrlData) {
fetchRoomEmailLink: function(actionData) {
this.mozLoop.rooms.create({
roomName: actionData.roomName,
roomOwner: actionData.roomOwner,
maxSize: loop.store.MAX_ROOM_CREATION_SIZE,
expiresIn: loop.store.DEFAULT_EXPIRES_IN
}, function(err, createdRoomData) {
if (err) {
this.trigger("error:emailLink");
return;
}
this.setStoreState({"emailLink": callUrlData.callUrl});
this.setStoreState({"emailLink": createdRoomData.roomUrl});
}.bind(this));
},

View File

@@ -16,6 +16,20 @@ loop.store = loop.store || {};
*/
var sharedActions = loop.shared.actions;
/**
* Maximum size given to createRoom; only 2 is supported (and is
* always passed) because that's what the user-experience is currently
* designed and tested to handle.
* @type {Number}
*/
var MAX_ROOM_CREATION_SIZE = loop.store.MAX_ROOM_CREATION_SIZE = 2;
/**
* The number of hours for which the room will exist - default 8 weeks
* @type {Number}
*/
var DEFAULT_EXPIRES_IN = loop.store.DEFAULT_EXPIRES_IN = 24 * 7 * 8;
/**
* Room validation schema. See validate.js.
* @type {Object}
@@ -61,13 +75,13 @@ loop.store = loop.store || {};
* designed and tested to handle.
* @type {Number}
*/
maxRoomCreationSize: 2,
maxRoomCreationSize: MAX_ROOM_CREATION_SIZE,
/**
* The number of hours for which the room will exist - default 8 weeks
* @type {Number}
*/
defaultExpiresIn: 24 * 7 * 8,
defaultExpiresIn: DEFAULT_EXPIRES_IN,
/**
* Registered actions.