Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
edc54ea
Add support for public shares to file rooms
danxuliu Jul 18, 2018
8de6a11
Add integration tests for files shared by link
danxuliu Aug 14, 2019
3d89459
Add integration tests for self-joined users in files shared by link
danxuliu Aug 14, 2019
b10313c
Add self-joined users and guests to the candidate mentions in file rooms
danxuliu Aug 14, 2019
6bb86a4
Add integration tests for mentions in a file shared by link
danxuliu Aug 14, 2019
ca62f9d
Fix avatar container height during calls
danxuliu Sep 16, 2019
1ba0f4f
Add support for Talk sidebar in public share pages
danxuliu Aug 15, 2019
255ac5d
Add basic acceptance tests for the Talk sidebar in the public share page
danxuliu Aug 16, 2019
83b5469
Add acceptance tests for Talk sidebar in public share page to Drone
danxuliu Aug 16, 2019
aaa8b84
Add acceptance tests for registered users in the public share page
danxuliu Aug 16, 2019
cd17e48
Add acceptance tests for mentioning users in the Files app
danxuliu Aug 16, 2019
c03ab40
Add acceptance tests for mentions in the public share page
danxuliu Aug 16, 2019
7f731bd
Add acceptance tests for chats in a file shared by link
danxuliu Aug 16, 2019
b4a2907
Add acceptance tests for chats in a file shared by link with a password
danxuliu Aug 16, 2019
41a1556
Correctly check if the share has a password and if it was entered cor…
nickvergessen Aug 16, 2019
b77d4b2
Add integration tests for getting the room for link share with password
danxuliu Aug 17, 2019
7fdcb46
Do not add system message for self joined users to file rooms
danxuliu Aug 19, 2019
6f8ac51
Add integration tests for the "user_added" system message
danxuliu Aug 19, 2019
129a3c1
Add wrapper around "OC.getCurrentUser()" to be able to override the user
danxuliu Sep 25, 2019
c1e6687
Override the current user when getting the room for a public share page
danxuliu Sep 25, 2019
891a73f
Fix guest avatars in public share page
danxuliu Sep 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add wrapper around "OC.getCurrentUser()" to be able to override the user
"OC.getCurrentUser()" gets its returned value from the "data-user" and
"data-user-displayname" attributes of the "head" element of the page,
which in some cases may not be the correct ones for Talk (for example,
in the public share page, as it uses the incognito mode which hides the
current user).

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Sep 26, 2019
commit 129a3c13798a469ba9eaba62a48444c1fd727e19
8 changes: 4 additions & 4 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
* @param {string} token
*/
_setRoomActive: function(token) {
if (OC.getCurrentUser().uid) {
if (OCA.Talk.getCurrentUser().uid) {
this._rooms.forEach(function(room) {
room.set('active', room.get('token') === token);
});
Expand All @@ -363,7 +363,7 @@
self.stopListening(self.activeRoom, 'change:participantFlags');
self.stopListening(self.activeRoom, 'change:lobbyState');

if (OC.getCurrentUser().uid) {
if (OCA.Talk.getCurrentUser().uid) {
roomChannel.trigger('active', token);

self._rooms.forEach(function(room) {
Expand Down Expand Up @@ -501,7 +501,7 @@
this._sidebarView = new OCA.SpreedMe.Views.SidebarView();
$('#content').append(this._sidebarView.$el);

if (OC.getCurrentUser().uid) {
if (OCA.Talk.getCurrentUser().uid) {
this._rooms = new OCA.SpreedMe.Models.RoomCollection();
this.listenTo(roomChannel, 'active', this._setRoomActive);
} else {
Expand Down Expand Up @@ -722,7 +722,7 @@
this.signaling.disconnect();
}.bind(this));

if (OC.getCurrentUser().uid) {
if (OCA.Talk.getCurrentUser().uid) {
this._showRoomList();
this.signaling.setRoomCollection(this._rooms)
.then(function(data) {
Expand Down
65 changes: 65 additions & 0 deletions js/currentuser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* global OC, OCA */

/**
*
* @copyright Copyright (c) 2019, Daniel Calviño Sánchez ([email protected])
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

(function(OC, OCA) {

'use strict';

OCA.Talk = OCA.Talk || {};

/**
* Current user as seen by Talk.
*
* This may differ from the current user returned by OC.getCurrentUser().
*/
var currentUser = undefined;

/**
* Returns the current user set in Talk or, if none, the current user as
* returned by OC.getCurrentUser().
*/
function getCurrentUser() {
if (currentUser) {
return currentUser;
}

return OC.getCurrentUser();
}

/**
* Sets the current user returned by getCurrentUser().
*
* @param string uid
* @param string displayName
*/
function setCurrentUser(uid, displayName) {
currentUser = {
uid: uid,
displayName: displayName
};
}

OCA.Talk.getCurrentUser = getCurrentUser;
OCA.Talk.setCurrentUser = setCurrentUser;

})(OC, OCA);
2 changes: 1 addition & 1 deletion js/embedded.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},

initialize: function() {
if (!OC.getCurrentUser().uid) {
if (!OCA.Talk.getCurrentUser().uid) {
this.initGuestName();
}

Expand Down
1 change: 1 addition & 0 deletions js/merged-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"webrtc.js",
"signaling.js",
"connection.js",
"currentuser.js",
"embedded.js",
"filesplugin.js"
]
1 change: 1 addition & 0 deletions js/merged-guest.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"webrtc.js",
"signaling.js",
"connection.js",
"currentuser.js",
"app.js",
"init.js"
]
1 change: 1 addition & 0 deletions js/merged-public-share.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"webrtc.js",
"signaling.js",
"connection.js",
"currentuser.js",
"embedded.js",
"publicshare.js"
]
1 change: 1 addition & 0 deletions js/merged-share-auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"webrtc.js",
"signaling.js",
"connection.js",
"currentuser.js",
"embedded.js",
"publicshareauth.js"
]
1 change: 1 addition & 0 deletions js/merged.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"webrtc.js",
"signaling.js",
"connection.js",
"currentuser.js",
"app.js",
"init.js"
]
4 changes: 2 additions & 2 deletions js/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@

OCA.Talk.Signaling.Base.prototype.syncRooms = function() {
var defer = $.Deferred();
if (this.roomCollection && OC.getCurrentUser().uid) {
if (this.roomCollection && OCA.Talk.getCurrentUser().uid) {
this.roomCollection.fetch({
success: function(roomCollection) {
defer.resolve(roomCollection);
Expand Down Expand Up @@ -956,7 +956,7 @@
} else {
// Already reconnected with a new session.
this._forceReconnect = false;
var user = OC.getCurrentUser();
var user = OCA.Talk.getCurrentUser();
var url = OC.linkToOCS('apps/spreed/api/v1/signaling', 2) + 'backend';
msg = {
"type": "hello",
Expand Down
28 changes: 14 additions & 14 deletions js/views/chatview.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@
}

return this._addCommentTemplate(_.extend({
isGuest: !OC.getCurrentUser().uid,
actorId: OC.getCurrentUser().uid || 'guest/' + this.model.get('hashedSessionId'),
actorDisplayName: OC.getCurrentUser().displayName || '',
isGuest: !OCA.Talk.getCurrentUser().uid,
actorId: OCA.Talk.getCurrentUser().uid || 'guest/' + this.model.get('hashedSessionId'),
actorDisplayName: OCA.Talk.getCurrentUser().displayName || '',
newMessagePlaceholder: newMessagePlaceholder,
submitText: submitText,
shareText: t('spreed', 'Share'),
isReadOnly: isReadOnly,
canShare: !isReadOnly && OC.getCurrentUser().uid,
canShare: !isReadOnly && OCA.Talk.getCurrentUser().uid,
}, params));
},

Expand All @@ -224,7 +224,7 @@

params = _.extend({
// TODO isUserAuthor is not properly set for guests
isUserAuthor: OC.getCurrentUser().uid === params.actorId,
isUserAuthor: OCA.Talk.getCurrentUser().uid === params.actorId,
isGuest: params.actorType === 'guests',
}, params);

Expand Down Expand Up @@ -256,8 +256,8 @@
this._virtualList = new OCA.SpreedMe.Views.VirtualList(this.$container);

var avatarSize = 32;
if (OC.getCurrentUser().uid) {
this.$el.find('.avatar').avatar(OC.getCurrentUser().uid, avatarSize, undefined, false, undefined, OC.getCurrentUser().displayName);
if (OCA.Talk.getCurrentUser().uid) {
this.$el.find('.avatar').avatar(OCA.Talk.getCurrentUser().uid, avatarSize, undefined, false, undefined, OCA.Talk.getCurrentUser().displayName);
} else {
var displayName = this.getOption('guestNameModel').get('nick');
var customName = displayName !== t('spreed', 'Guest') ? displayName : '';
Expand Down Expand Up @@ -500,7 +500,7 @@
formattedMessage = formattedMessage.replace(/\n/g, '<br/>');
formattedMessage = OCA.SpreedMe.Views.RichObjectStringParser.parseMessage(
formattedMessage, commentModel.get('messageParameters'), {
userId: OC.getCurrentUser().uid,
userId: OCA.Talk.getCurrentUser().uid,
sessionHash: this.model.get('hashedSessionId'),
});

Expand Down Expand Up @@ -807,10 +807,10 @@
setAvatar($(this), inlineAvatarSize);
});

if (OC.getCurrentUser().uid &&
if (OCA.Talk.getCurrentUser().uid &&
model &&
model.get('actorType') === 'users' &&
model.get('actorId') !== OC.getCurrentUser().uid) {
model.get('actorId') !== OCA.Talk.getCurrentUser().uid) {
$el.find('.authorRow .avatar, .authorRow .author').contactsMenu(
model.get('actorId'), 0, $el.find('.authorRow'));
}
Expand All @@ -827,7 +827,7 @@
});

// Contacts menu is not shown in public view.
if (!OC.getCurrentUser().uid) {
if (!OCA.Talk.getCurrentUser().uid) {
return;
}

Expand All @@ -836,7 +836,7 @@
var $avatar = $this.find('.avatar');

var user = $avatar.data('user-id');
if (user !== OC.getCurrentUser().uid) {
if (user !== OCA.Talk.getCurrentUser().uid) {
$this.contactsMenu(user, 0, $this);
}
});
Expand Down Expand Up @@ -884,7 +884,7 @@
img.width = previewSize;
img.height = previewSize;

if (OC.getCurrentUser().uid) {
if (OCA.Talk.getCurrentUser().uid) {
img.onerror = handlePreviewLoadError;
img.src = previewUrl;
} else {
Expand Down Expand Up @@ -1018,7 +1018,7 @@
message: message
};

if (!OC.getCurrentUser().uid) {
if (!OCA.Talk.getCurrentUser().uid) {
var guestNick = OCA.SpreedMe.app._localStorageModel.get('nick');
if (guestNick) {
data.actorDisplayName = guestNick;
Expand Down
4 changes: 2 additions & 2 deletions js/views/emptycontentview.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
var messageAdditional = '';
var url = '';

var isGuest = (OC.getCurrentUser().uid === null);
var isGuest = (OCA.Talk.getCurrentUser().uid === null);

var participants = this._activeRoom.get('participants');
var numberOfParticipants = Object.keys(participants).length;
Expand All @@ -230,7 +230,7 @@
participantName = '';

_.each(participants, function(data, userId) {
if (OC.getCurrentUser().uid !== userId) {
if (OCA.Talk.getCurrentUser().uid !== userId) {
participantId = userId;
participantName = data.name;
}
Expand Down
2 changes: 1 addition & 1 deletion js/views/localvideoview.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
return;
}

var userId = OC.getCurrentUser().uid;
var userId = OCA.Talk.getCurrentUser().uid;
var guestName = localStorage.getItem("nick");
this.setAvatar(userId, guestName);

Expand Down
10 changes: 5 additions & 5 deletions js/views/participantlistview.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
templateContext: function() {
var isSelf = false,
isModerator = false;
if (OC.getCurrentUser().uid) {
isSelf = this.model.get('userId') === OC.getCurrentUser().uid;
if (OCA.Talk.getCurrentUser().uid) {
isSelf = this.model.get('userId') === OCA.Talk.getCurrentUser().uid;
isModerator = this.room.get('participantType') === OCA.SpreedMe.app.OWNER ||
this.room.get('participantType') === OCA.SpreedMe.app.MODERATOR;
} else {
Expand All @@ -102,7 +102,7 @@
}

var isGuestOrGuestModerator = this.model.get('participantType') === OCA.SpreedMe.app.GUEST || this.model.get('participantType') === OCA.SpreedMe.app.GUEST_MODERATOR;
var hasContactsMenu = OC.getCurrentUser().uid && !isSelf && !isGuestOrGuestModerator;
var hasContactsMenu = OCA.Talk.getCurrentUser().uid && !isSelf && !isGuestOrGuestModerator;

return {
canModerate: canModerate,
Expand Down Expand Up @@ -139,8 +139,8 @@
}
});

if (OC.getCurrentUser().uid && model.get('userId') &&
model.get('userId') !== OC.getCurrentUser().uid) {
if (OCA.Talk.getCurrentUser().uid && model.get('userId') &&
model.get('userId') !== OCA.Talk.getCurrentUser().uid) {
this.$el.find('.participant-entry .avatar').contactsMenu(
model.get('userId'), 0, this.$el.find('.participant-entry'));

Expand Down
6 changes: 3 additions & 3 deletions js/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ var spreedPeerConnectionTable = [];
detectSpeakingEvents: true,
connection: signaling,
enableDataChannels: true,
nick: OC.getCurrentUser().displayName
nick: OCA.Talk.getCurrentUser().displayName
});
if (signaling.hasFeature('mcu')) {
// Force "Plan-B" semantics if the MCU is used, which doesn't support
Expand Down Expand Up @@ -536,7 +536,7 @@ var spreedPeerConnectionTable = [];
} else {
OCA.SpreedMe.webrtc.emit('audioOn');
}
if (!OC.getCurrentUser()['uid']) {
if (!OCA.Talk.getCurrentUser()['uid']) {
var currentGuestNick = localStorage.getItem("nick");
sendDataChannelToAll('status', 'nickChanged', currentGuestNick);
}
Expand Down Expand Up @@ -624,7 +624,7 @@ var spreedPeerConnectionTable = [];
OCA.SpreedMe.videos.stopSendingNick(peer);
peer.nickInterval = setInterval(function() {
var payload;
var user = OC.getCurrentUser();
var user = OCA.Talk.getCurrentUser();
if (!user.uid) {
payload = localStorage.getItem("nick");
} else {
Expand Down