share user email through commands
This commit is contained in:
parent
941cd13193
commit
272cfea493
36
app.js
36
app.js
|
@ -14,7 +14,8 @@ require("jQuery-Impromptu");
|
||||||
require("autosize");
|
require("autosize");
|
||||||
|
|
||||||
var Commands = {
|
var Commands = {
|
||||||
CONNECTION_QUALITY: "connectionQuality"
|
CONNECTION_QUALITY: "connectionQuality",
|
||||||
|
EMAIL: "email"
|
||||||
};
|
};
|
||||||
|
|
||||||
function createConference(connection, room) {
|
function createConference(connection, room) {
|
||||||
|
@ -39,15 +40,10 @@ function createConference(connection, room) {
|
||||||
},
|
},
|
||||||
|
|
||||||
setNickname: function (nickname) {
|
setNickname: function (nickname) {
|
||||||
// FIXME check if room is available etc.
|
|
||||||
APP.settings.setDisplayName(nickname);
|
APP.settings.setDisplayName(nickname);
|
||||||
room.setDisplayName(nickname);
|
room.setDisplayName(nickname);
|
||||||
},
|
},
|
||||||
|
|
||||||
setEmail: function (email) {
|
|
||||||
// FIXME room.setEmail
|
|
||||||
},
|
|
||||||
|
|
||||||
setStartMuted: function (audio, video) {
|
setStartMuted: function (audio, video) {
|
||||||
// FIXME room.setStartMuted
|
// FIXME room.setStartMuted
|
||||||
},
|
},
|
||||||
|
@ -264,6 +260,29 @@ function initConference(connection, roomName) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// share email with other users
|
||||||
|
function sendEmail(email) {
|
||||||
|
room.sendCommand(Commands.EMAIL, {
|
||||||
|
value: email,
|
||||||
|
attributes: {
|
||||||
|
id: room.myUserId()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
|
||||||
|
APP.settings.setEmail(email);
|
||||||
|
APP.UI.setUserAvatar(room.myUserId(), data.value);
|
||||||
|
sendEmail(email);
|
||||||
|
});
|
||||||
|
var email = APP.settings.getEmail();
|
||||||
|
if (email) {
|
||||||
|
sendEmail(APP.settings.getEmail());
|
||||||
|
}
|
||||||
|
room.addCommandListener(Commands.EMAIL, function (data) {
|
||||||
|
APP.UI.setUserAvatar(data.attributes.id, data.value);
|
||||||
|
});
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
room.on(
|
room.on(
|
||||||
ConferenceEvents.CONFERENCE_JOINED,
|
ConferenceEvents.CONFERENCE_JOINED,
|
||||||
|
@ -318,11 +337,6 @@ function init() {
|
||||||
APP.settings.setLanguage(language);
|
APP.settings.setLanguage(language);
|
||||||
});
|
});
|
||||||
|
|
||||||
APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
|
|
||||||
APP.conference.setEmail(email);
|
|
||||||
APP.settings.setEmail(email);
|
|
||||||
});
|
|
||||||
|
|
||||||
APP.UI.addListener(
|
APP.UI.addListener(
|
||||||
UIEvents.START_MUTED_CHANGED,
|
UIEvents.START_MUTED_CHANGED,
|
||||||
function (startAudioMuted, startVideoMuted) {
|
function (startAudioMuted, startVideoMuted) {
|
||||||
|
|
|
@ -135,24 +135,23 @@ UI.changeDisplayName = function (id, displayName) {
|
||||||
VideoLayout.onDisplayNameChanged(id, displayName);
|
VideoLayout.onDisplayNameChanged(id, displayName);
|
||||||
};
|
};
|
||||||
|
|
||||||
UI.initConference = function (jid) {
|
UI.initConference = function (id) {
|
||||||
Toolbar.updateRoomUrl(window.location.href);
|
Toolbar.updateRoomUrl(window.location.href);
|
||||||
var meHTML = APP.translation.generateTranslationHTML("me");
|
var meHTML = APP.translation.generateTranslationHTML("me");
|
||||||
var localId = APP.conference.localId();
|
|
||||||
$("#localNick").html(localId + " (" + meHTML + ")");
|
|
||||||
|
|
||||||
var settings = Settings.getSettings();
|
var settings = Settings.getSettings();
|
||||||
|
|
||||||
|
$("#localNick").html(settings.email || settings.uid + " (" + meHTML + ")");
|
||||||
|
|
||||||
// Make sure we configure our avatar id, before creating avatar for us
|
// Make sure we configure our avatar id, before creating avatar for us
|
||||||
Avatar.setUserAvatar(jid, settings.email || settings.uid);
|
UI.setUserAvatar(id, settings.email || settings.uid);
|
||||||
|
|
||||||
// Add myself to the contact list.
|
// Add myself to the contact list.
|
||||||
ContactList.addContact(jid);
|
ContactList.addContact(id);
|
||||||
|
|
||||||
// Once we've joined the muc show the toolbar
|
// Once we've joined the muc show the toolbar
|
||||||
ToolbarToggler.showToolbar();
|
ToolbarToggler.showToolbar();
|
||||||
|
|
||||||
var displayName = config.displayJids ? localId : settings.displayName;
|
var displayName = config.displayJids ? id : settings.displayName;
|
||||||
|
|
||||||
if (displayName) {
|
if (displayName) {
|
||||||
UI.changeDisplayName('localVideoContainer', displayName);
|
UI.changeDisplayName('localVideoContainer', displayName);
|
||||||
|
@ -173,7 +172,7 @@ function registerListeners() {
|
||||||
});
|
});
|
||||||
|
|
||||||
UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
|
UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
|
||||||
Avatar.setUserAvatar(APP.xmpp.myJid(), email);
|
UI.setUserAvatar(APP.conference.localId(), email);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,16 +381,16 @@ function onDtmfSupportChanged(dtmfSupport) {
|
||||||
}
|
}
|
||||||
|
|
||||||
UI.addUser = function (jid, id, displayName) {
|
UI.addUser = function (jid, id, displayName) {
|
||||||
messageHandler.notify(displayName,'notify.somebody',
|
messageHandler.notify(
|
||||||
'connected',
|
displayName,'notify.somebody', 'connected', 'notify.connected'
|
||||||
'notify.connected');
|
);
|
||||||
|
|
||||||
if (!config.startAudioMuted ||
|
if (!config.startAudioMuted ||
|
||||||
config.startAudioMuted > APP.members.size())
|
config.startAudioMuted > APP.members.size())
|
||||||
UIUtil.playSoundNotification('userJoined');
|
UIUtil.playSoundNotification('userJoined');
|
||||||
|
|
||||||
// Configure avatar
|
// Configure avatar
|
||||||
Avatar.setUserAvatar(jid, id);
|
UI.setUserAvatar(jid, id);
|
||||||
|
|
||||||
// Add Peer's container
|
// Add Peer's container
|
||||||
VideoLayout.ensurePeerContainerExists(jid);
|
VideoLayout.ensurePeerContainerExists(jid);
|
||||||
|
@ -599,10 +598,16 @@ UI.dockToolbar = function (isDock) {
|
||||||
return ToolbarToggler.dockToolbar(isDock);
|
return ToolbarToggler.dockToolbar(isDock);
|
||||||
};
|
};
|
||||||
|
|
||||||
UI.userAvatarChanged = function (resourceJid, thumbUrl, contactListUrl) {
|
UI.setUserAvatar = function (id, email) {
|
||||||
VideoLayout.userAvatarChanged(resourceJid, thumbUrl);
|
// update avatar
|
||||||
ContactList.userAvatarChanged(resourceJid, contactListUrl);
|
Avatar.setUserAvatar(id, email);
|
||||||
if(resourceJid === APP.xmpp.myResource()) {
|
|
||||||
|
var thumbUrl = Avatar.getThumbUrl(id);
|
||||||
|
var contactListUrl = Avatar.getContactListUrl(id);
|
||||||
|
|
||||||
|
VideoLayout.changeUserAvatar(id, thumbUrl);
|
||||||
|
ContactList.changeUserAvatar(id, contactListUrl);
|
||||||
|
if (APP.conference.isLocalId(id)) {
|
||||||
SettingsMenu.changeAvatar(thumbUrl);
|
SettingsMenu.changeAvatar(thumbUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
/* global Strophe, APP, MD5 */
|
/* global MD5 */
|
||||||
var Settings = require("../../settings/Settings");
|
|
||||||
|
|
||||||
var users = {};
|
var users = {};
|
||||||
|
|
||||||
var Avatar = {
|
var Avatar = {
|
||||||
|
@ -8,57 +6,55 @@ var Avatar = {
|
||||||
/**
|
/**
|
||||||
* Sets the user's avatar in the settings menu(if local user), contact list
|
* Sets the user's avatar in the settings menu(if local user), contact list
|
||||||
* and thumbnail
|
* and thumbnail
|
||||||
* @param jid jid of the user
|
* @param id id of the user
|
||||||
* @param id email or userID to be used as a hash
|
* @param email email or nickname to be used as a hash
|
||||||
*/
|
*/
|
||||||
setUserAvatar: function (jid, id) {
|
setUserAvatar: function (id, email) {
|
||||||
if (id) {
|
if (email) {
|
||||||
if (users[jid] === id) {
|
if (users[id] === email) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
users[jid] = id;
|
users[id] = email;
|
||||||
}
|
}
|
||||||
var thumbUrl = this.getThumbUrl(jid);
|
var thumbUrl = this.getThumbUrl(id);
|
||||||
var contactListUrl = this.getContactListUrl(jid);
|
var contactListUrl = this.getContactListUrl(id);
|
||||||
var resourceJid = Strophe.getResourceFromJid(jid);
|
|
||||||
|
|
||||||
APP.UI.userAvatarChanged(resourceJid, thumbUrl, contactListUrl);
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Returns image URL for the avatar to be displayed on large video area
|
* Returns image URL for the avatar to be displayed on large video area
|
||||||
* where current active speaker is presented.
|
* where current active speaker is presented.
|
||||||
* @param jid full MUC jid of the user for whom we want to obtain avatar URL
|
* @param id id of the user for whom we want to obtain avatar URL
|
||||||
*/
|
*/
|
||||||
getActiveSpeakerUrl: function (jid) {
|
getActiveSpeakerUrl: function (id) {
|
||||||
return this.getGravatarUrl(jid, 100);
|
return this.getGravatarUrl(id, 100);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Returns image URL for the avatar to be displayed on small video thumbnail
|
* Returns image URL for the avatar to be displayed on small video thumbnail
|
||||||
* @param jid full MUC jid of the user for whom we want to obtain avatar URL
|
* @param id id of the user for whom we want to obtain avatar URL
|
||||||
*/
|
*/
|
||||||
getThumbUrl: function (jid) {
|
getThumbUrl: function (id) {
|
||||||
return this.getGravatarUrl(jid, 100);
|
return this.getGravatarUrl(id, 100);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Returns the URL for the avatar to be displayed as contactlist item
|
* Returns the URL for the avatar to be displayed as contactlist item
|
||||||
* @param jid full MUC jid of the user for whom we want to obtain avatar URL
|
* @param id id of the user for whom we want to obtain avatar URL
|
||||||
*/
|
*/
|
||||||
getContactListUrl: function (jid) {
|
getContactListUrl: function (id) {
|
||||||
return this.getGravatarUrl(jid, 30);
|
return this.getGravatarUrl(id, 30);
|
||||||
},
|
},
|
||||||
getGravatarUrl: function (jid, size) {
|
getGravatarUrl: function (id, size) {
|
||||||
if (!jid) {
|
if (!id) {
|
||||||
console.error("Get gravatar - jid is undefined");
|
console.error("Get gravatar - id is undefined");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var id = users[jid];
|
var email = users[id];
|
||||||
if (!id) {
|
if (!email) {
|
||||||
console.warn(
|
console.warn(
|
||||||
"No avatar stored yet for " + jid + " - using JID as ID");
|
"No avatar stored yet for " + id + " - using user id as ID"
|
||||||
id = jid;
|
);
|
||||||
|
email = id;
|
||||||
}
|
}
|
||||||
return 'https://www.gravatar.com/avatar/' +
|
return 'https://www.gravatar.com/avatar/' +
|
||||||
MD5.hexdigest(id.trim().toLowerCase()) +
|
MD5.hexdigest(email.trim().toLowerCase()) +
|
||||||
"?d=wavatar&size=" + (size || "30");
|
"?d=wavatar&size=" + (size || "30");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,9 +180,9 @@ var ContactList = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
userAvatarChanged: function (resourceJid, contactListUrl) {
|
changeUserAvatar: function (id, contactListUrl) {
|
||||||
// set the avatar in the contact list
|
// set the avatar in the contact list
|
||||||
var contact = $('#' + resourceJid + '>img');
|
var contact = $('#' + id + '>img');
|
||||||
if (contact && contact.length > 0) {
|
if (contact && contact.length > 0) {
|
||||||
contact.get(0).src = contactListUrl;
|
contact.get(0).src = contactListUrl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1001,14 +1001,16 @@ var VideoLayout = (function (my) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
my.userAvatarChanged = function(resourceJid, thumbUrl) {
|
my.changeUserAvatar = function(id, thumbUrl) {
|
||||||
var smallVideo = VideoLayout.getSmallVideo(resourceJid);
|
var smallVideo = VideoLayout.getSmallVideo(id);
|
||||||
if(smallVideo)
|
if (smallVideo) {
|
||||||
smallVideo.avatarChanged(thumbUrl);
|
smallVideo.avatarChanged(thumbUrl);
|
||||||
else
|
} else {
|
||||||
console.warn(
|
console.warn(
|
||||||
"Missed avatar update - no small video yet for " + resourceJid);
|
"Missed avatar update - no small video yet for " + id
|
||||||
LargeVideo.updateAvatar(resourceJid, thumbUrl);
|
);
|
||||||
|
}
|
||||||
|
LargeVideo.updateAvatar(id, thumbUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
my.createEtherpadIframe = function(src, onloadHandler)
|
my.createEtherpadIframe = function(src, onloadHandler)
|
||||||
|
|
|
@ -87,6 +87,10 @@ var Settings = {
|
||||||
return email;
|
return email;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getEmail: function () {
|
||||||
|
return email;
|
||||||
|
},
|
||||||
|
|
||||||
getSettings: function () {
|
getSettings: function () {
|
||||||
return {
|
return {
|
||||||
email: email,
|
email: email,
|
||||||
|
|
Loading…
Reference in New Issue