From 82cf76a8f963ee242e90b401b31d9da88fd493eb Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Thu, 4 Sep 2014 09:08:34 +0200 Subject: [PATCH 01/62] Report ban/unban messages to recents lists --- webclient/recents/recents.html | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index 9978e08b1..4db9e2ae9 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -16,15 +16,26 @@ -
- {{ room.inviter }} invited you -
-
-
- {{ room.lastMsg.user_id }} - {{ {"join": "joined", "leave": "left", "invite": "invited", "ban": "banned"}[msg.content.membership] }} - {{ (msg.content.membership === "invite" || msg.content.membership === "ban") ? (msg.state_key || '') : '' }} +
+ + {{ room.lastMsg.state_key }} joined + + + + {{room.lastMsg.state_key }} left + + + {{ room.lastMsg.user_id }} + {{ {"join": "kicked", "ban": "unbanned"}[room.lastMsg.content.prev] }} + {{ room.lastMsg.state_key }} + + + + {{ room.lastMsg.user_id }} + {{ {"invite": "invited", "ban": "banned"}[room.lastMsg.content.membership] }} + {{ room.lastMsg.state_key }} +
From b1b57a3f2883c3072d6a4bc91922adea7c47f269 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Thu, 4 Sep 2014 11:03:49 +0200 Subject: [PATCH 02/62] BF: Do not filter incoming member events. Before, only invitations to the current user were showned in the recents. --- webclient/recents/recents-controller.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js index 3209f2cbd..4cf501b4e 100644 --- a/webclient/recents/recents-controller.js +++ b/webclient/recents/recents-controller.js @@ -28,13 +28,8 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService']) var listenToEventStream = function() { // Refresh the list on matrix invitation and message event $scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) { - var config = matrixService.config(); - if (isLive && event.state_key === config.user_id && event.content.membership === "invite") { - console.log("Invited to room " + event.room_id); - // FIXME push membership to top level key to match /im/sync - event.membership = event.content.membership; - - $scope.rooms[event.room_id] = event; + if (isLive) { + $scope.rooms[event.room_id].lastMsg = event; } }); $scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) { From eb7d7ce354d23e6b53fbb22d07fa7b65e2adc42e Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 4 Sep 2014 11:38:26 +0100 Subject: [PATCH 03/62] Re-apply fixes to the link-email screen to make it work again (in a somewhat temporary way until home servers sign associations). Unhide the linked emails box. --- webclient/settings/settings-controller.js | 75 +++++++++++++++-------- webclient/settings/settings.html | 6 +- 2 files changed, 54 insertions(+), 27 deletions(-) diff --git a/webclient/settings/settings-controller.js b/webclient/settings/settings-controller.js index 7a26367a1..8c877a24e 100644 --- a/webclient/settings/settings-controller.js +++ b/webclient/settings/settings-controller.js @@ -19,6 +19,17 @@ limitations under the License. angular.module('SettingsController', ['matrixService', 'mFileUpload', 'mFileInput']) .controller('SettingsController', ['$scope', 'matrixService', 'mFileUpload', function($scope, matrixService, mFileUpload) { + // XXX: duplicated from register + var generateClientSecret = function() { + var ret = ""; + var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + + for (var i = 0; i < 32; i++) { + ret += chars.charAt(Math.floor(Math.random() * chars.length)); + } + + return ret; + }; $scope.config = matrixService.config(); $scope.profile = { @@ -106,16 +117,22 @@ angular.module('SettingsController', ['matrixService', 'mFileUpload', 'mFileInpu $scope.linkedEmails = { linkNewEmail: "", // the email entry box emailBeingAuthed: undefined, // to populate verification text - authTokenId: undefined, // the token id from the IS + authSid: undefined, // the token id from the IS emailCode: "", // the code entry box linkedEmailList: matrixService.config().emailList // linked email list }; $scope.linkEmail = function(email) { - matrixService.linkEmail(email).then( + if (email != $scope.linkedEmails.emailBeingAuthed) { + $scope.linkedEmails.emailBeingAuthed = email; + $scope.clientSecret = generateClientSecret(); + $scope.sendAttempt = 0; + } + $scope.sendAttempt++; + matrixService.linkEmail(email, $scope.clientSecret, $scope.sendAttempt).then( function(response) { if (response.data.success === true) { - $scope.linkedEmails.authTokenId = response.data.tokenId; + $scope.linkedEmails.authSid = response.data.sid; $scope.emailFeedback = "You have been sent an email."; $scope.linkedEmails.emailBeingAuthed = email; } @@ -129,34 +146,44 @@ angular.module('SettingsController', ['matrixService', 'mFileUpload', 'mFileInpu ); }; - $scope.submitEmailCode = function(code) { - var tokenId = $scope.linkedEmails.authTokenId; + $scope.submitEmailCode = function() { + var tokenId = $scope.linkedEmails.authSid; if (tokenId === undefined) { $scope.emailFeedback = "You have not requested a code with this email."; return; } - matrixService.authEmail(matrixService.config().user_id, tokenId, code).then( + matrixService.authEmail($scope.clientSecret, $scope.linkedEmails.authSid, $scope.linkedEmails.emailCode).then( function(response) { - if ("success" in response.data && response.data.success === false) { + if ("errcode" in response.data) { $scope.emailFeedback = "Failed to authenticate email."; return; } - var config = matrixService.config(); - var emailList = {}; - if ("emailList" in config) { - emailList = config.emailList; - } - emailList[response.address] = response; - // save the new email list - config.emailList = emailList; - matrixService.setConfig(config); - matrixService.saveConfig(); - // invalidate the email being authed and update UI. - $scope.linkedEmails.emailBeingAuthed = undefined; - $scope.emailFeedback = ""; - $scope.linkedEmails.linkedEmailList = emailList; - $scope.linkedEmails.linkNewEmail = ""; - $scope.linkedEmails.emailCode = ""; + matrixService.bindEmail(matrixService.config().user_id, tokenId, $scope.clientSecret).then( + function(response) { + if ('errcode' in response.data) { + $scope.emailFeedback = "Failed to link email."; + return; + } + var config = matrixService.config(); + var emailList = {}; + if ("emailList" in config) { + emailList = config.emailList; + } + emailList[$scope.linkedEmails.emailBeingAuthed] = response; + // save the new email list + config.emailList = emailList; + matrixService.setConfig(config); + matrixService.saveConfig(); + // invalidate the email being authed and update UI. + $scope.linkedEmails.emailBeingAuthed = undefined; + $scope.emailFeedback = ""; + $scope.linkedEmails.linkedEmailList = emailList; + $scope.linkedEmails.linkNewEmail = ""; + $scope.linkedEmails.emailCode = ""; + }, function(reason) { + $scope.emailFeedback = "Failed to link email: " + reason; + } + ); }, function(reason) { $scope.emailFeedback = "Failed to auth email: " + reason; @@ -182,4 +209,4 @@ angular.module('SettingsController', ['matrixService', 'mFileUpload', 'mFileInpu $scope.settings.notifications = permission; }); }; -}]); \ No newline at end of file +}]); diff --git a/webclient/settings/settings.html b/webclient/settings/settings.html index b7fd5dfb5..0af137d0a 100644 --- a/webclient/settings/settings.html +++ b/webclient/settings/settings.html @@ -23,14 +23,14 @@

-

Linked emails

-