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");
|
||||
|
||||
var Commands = {
|
||||
CONNECTION_QUALITY: "connectionQuality"
|
||||
CONNECTION_QUALITY: "connectionQuality",
|
||||
EMAIL: "email"
|
||||
};
|
||||
|
||||
function createConference(connection, room) {
|
||||
|
@ -39,15 +40,10 @@ function createConference(connection, room) {
|
|||
},
|
||||
|
||||
setNickname: function (nickname) {
|
||||
// FIXME check if room is available etc.
|
||||
APP.settings.setDisplayName(nickname);
|
||||
room.setDisplayName(nickname);
|
||||
},
|
||||
|
||||
setEmail: function (email) {
|
||||
// FIXME room.setEmail
|
||||
},
|
||||
|
||||
setStartMuted: function (audio, video) {
|
||||
// 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) {
|
||||
room.on(
|
||||
ConferenceEvents.CONFERENCE_JOINED,
|
||||
|
@ -318,11 +337,6 @@ function init() {
|
|||
APP.settings.setLanguage(language);
|
||||
});
|
||||
|
||||
APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
|
||||
APP.conference.setEmail(email);
|
||||
APP.settings.setEmail(email);
|
||||
});
|
||||
|
||||
APP.UI.addListener(
|
||||
UIEvents.START_MUTED_CHANGED,
|
||||
function (startAudioMuted, startVideoMuted) {
|
||||
|
|
|
@ -135,24 +135,23 @@ UI.changeDisplayName = function (id, displayName) {
|
|||
VideoLayout.onDisplayNameChanged(id, displayName);
|
||||
};
|
||||
|
||||
UI.initConference = function (jid) {
|
||||
UI.initConference = function (id) {
|
||||
Toolbar.updateRoomUrl(window.location.href);
|
||||
var meHTML = APP.translation.generateTranslationHTML("me");
|
||||
var localId = APP.conference.localId();
|
||||
$("#localNick").html(localId + " (" + meHTML + ")");
|
||||
|
||||
var settings = Settings.getSettings();
|
||||
|
||||
$("#localNick").html(settings.email || settings.uid + " (" + meHTML + ")");
|
||||
|
||||
// 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.
|
||||
ContactList.addContact(jid);
|
||||
ContactList.addContact(id);
|
||||
|
||||
// Once we've joined the muc show the toolbar
|
||||
ToolbarToggler.showToolbar();
|
||||
|
||||
var displayName = config.displayJids ? localId : settings.displayName;
|
||||
var displayName = config.displayJids ? id : settings.displayName;
|
||||
|
||||
if (displayName) {
|
||||
UI.changeDisplayName('localVideoContainer', displayName);
|
||||
|
@ -173,7 +172,7 @@ function registerListeners() {
|
|||
});
|
||||
|
||||
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) {
|
||||
messageHandler.notify(displayName,'notify.somebody',
|
||||
'connected',
|
||||
'notify.connected');
|
||||
messageHandler.notify(
|
||||
displayName,'notify.somebody', 'connected', 'notify.connected'
|
||||
);
|
||||
|
||||
if (!config.startAudioMuted ||
|
||||
config.startAudioMuted > APP.members.size())
|
||||
UIUtil.playSoundNotification('userJoined');
|
||||
|
||||
// Configure avatar
|
||||
Avatar.setUserAvatar(jid, id);
|
||||
UI.setUserAvatar(jid, id);
|
||||
|
||||
// Add Peer's container
|
||||
VideoLayout.ensurePeerContainerExists(jid);
|
||||
|
@ -599,10 +598,16 @@ UI.dockToolbar = function (isDock) {
|
|||
return ToolbarToggler.dockToolbar(isDock);
|
||||
};
|
||||
|
||||
UI.userAvatarChanged = function (resourceJid, thumbUrl, contactListUrl) {
|
||||
VideoLayout.userAvatarChanged(resourceJid, thumbUrl);
|
||||
ContactList.userAvatarChanged(resourceJid, contactListUrl);
|
||||
if(resourceJid === APP.xmpp.myResource()) {
|
||||
UI.setUserAvatar = function (id, email) {
|
||||
// update avatar
|
||||
Avatar.setUserAvatar(id, email);
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
/* global Strophe, APP, MD5 */
|
||||
var Settings = require("../../settings/Settings");
|
||||
|
||||
/* global MD5 */
|
||||
var users = {};
|
||||
|
||||
var Avatar = {
|
||||
|
@ -8,57 +6,55 @@ var Avatar = {
|
|||
/**
|
||||
* Sets the user's avatar in the settings menu(if local user), contact list
|
||||
* and thumbnail
|
||||
* @param jid jid of the user
|
||||
* @param id email or userID to be used as a hash
|
||||
* @param id id of the user
|
||||
* @param email email or nickname to be used as a hash
|
||||
*/
|
||||
setUserAvatar: function (jid, id) {
|
||||
if (id) {
|
||||
if (users[jid] === id) {
|
||||
setUserAvatar: function (id, email) {
|
||||
if (email) {
|
||||
if (users[id] === email) {
|
||||
return;
|
||||
}
|
||||
users[jid] = id;
|
||||
users[id] = email;
|
||||
}
|
||||
var thumbUrl = this.getThumbUrl(jid);
|
||||
var contactListUrl = this.getContactListUrl(jid);
|
||||
var resourceJid = Strophe.getResourceFromJid(jid);
|
||||
|
||||
APP.UI.userAvatarChanged(resourceJid, thumbUrl, contactListUrl);
|
||||
var thumbUrl = this.getThumbUrl(id);
|
||||
var contactListUrl = this.getContactListUrl(id);
|
||||
},
|
||||
/**
|
||||
* Returns image URL for the avatar to be displayed on large video area
|
||||
* 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) {
|
||||
return this.getGravatarUrl(jid, 100);
|
||||
getActiveSpeakerUrl: function (id) {
|
||||
return this.getGravatarUrl(id, 100);
|
||||
},
|
||||
/**
|
||||
* 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) {
|
||||
return this.getGravatarUrl(jid, 100);
|
||||
getThumbUrl: function (id) {
|
||||
return this.getGravatarUrl(id, 100);
|
||||
},
|
||||
/**
|
||||
* 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) {
|
||||
return this.getGravatarUrl(jid, 30);
|
||||
getContactListUrl: function (id) {
|
||||
return this.getGravatarUrl(id, 30);
|
||||
},
|
||||
getGravatarUrl: function (jid, size) {
|
||||
if (!jid) {
|
||||
console.error("Get gravatar - jid is undefined");
|
||||
getGravatarUrl: function (id, size) {
|
||||
if (!id) {
|
||||
console.error("Get gravatar - id is undefined");
|
||||
return null;
|
||||
}
|
||||
var id = users[jid];
|
||||
if (!id) {
|
||||
var email = users[id];
|
||||
if (!email) {
|
||||
console.warn(
|
||||
"No avatar stored yet for " + jid + " - using JID as ID");
|
||||
id = jid;
|
||||
"No avatar stored yet for " + id + " - using user id as ID"
|
||||
);
|
||||
email = id;
|
||||
}
|
||||
return 'https://www.gravatar.com/avatar/' +
|
||||
MD5.hexdigest(id.trim().toLowerCase()) +
|
||||
MD5.hexdigest(email.trim().toLowerCase()) +
|
||||
"?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
|
||||
var contact = $('#' + resourceJid + '>img');
|
||||
var contact = $('#' + id + '>img');
|
||||
if (contact && contact.length > 0) {
|
||||
contact.get(0).src = contactListUrl;
|
||||
}
|
||||
|
|
|
@ -1001,14 +1001,16 @@ var VideoLayout = (function (my) {
|
|||
}
|
||||
};
|
||||
|
||||
my.userAvatarChanged = function(resourceJid, thumbUrl) {
|
||||
var smallVideo = VideoLayout.getSmallVideo(resourceJid);
|
||||
if(smallVideo)
|
||||
my.changeUserAvatar = function(id, thumbUrl) {
|
||||
var smallVideo = VideoLayout.getSmallVideo(id);
|
||||
if (smallVideo) {
|
||||
smallVideo.avatarChanged(thumbUrl);
|
||||
else
|
||||
} else {
|
||||
console.warn(
|
||||
"Missed avatar update - no small video yet for " + resourceJid);
|
||||
LargeVideo.updateAvatar(resourceJid, thumbUrl);
|
||||
"Missed avatar update - no small video yet for " + id
|
||||
);
|
||||
}
|
||||
LargeVideo.updateAvatar(id, thumbUrl);
|
||||
};
|
||||
|
||||
my.createEtherpadIframe = function(src, onloadHandler)
|
||||
|
|
|
@ -87,6 +87,10 @@ var Settings = {
|
|||
return email;
|
||||
},
|
||||
|
||||
getEmail: function () {
|
||||
return email;
|
||||
},
|
||||
|
||||
getSettings: function () {
|
||||
return {
|
||||
email: email,
|
||||
|
|
Loading…
Reference in New Issue