From baf472f83f80ff9dc2294310435281e7a20c5e54 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 31 Oct 2014 10:02:56 +0000 Subject: [PATCH 1/7] SYWEB-63: Fix desktop notification message when notifying for an image. --- webclient/components/matrix/event-handler-service.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 6f251eec5..45ee9e756 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -258,6 +258,9 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { if (event.content.msgtype === "m.emote") { message = "* " + displayname + " " + message; } + else if (event.content.msgtype === "m.image") { + message = displayname + " sent an image."; + } var roomTitle = matrixService.getRoomIdToAliasMapping(event.room_id); var theRoom = $rootScope.events.rooms[event.room_id]; From 188de756be6afa82069bae0b6bbb87f93fba79a8 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 31 Oct 2014 10:06:28 +0000 Subject: [PATCH 2/7] SYWEB-45: Display the user_id of a user when hovering over their avatar next to their messages. --- webclient/room/room.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webclient/room/room.html b/webclient/room/room.html index fac7433a4..5265f42dd 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -133,7 +133,7 @@ - From ac2a17707037438015560265c1267f6665f5bbd2 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 31 Oct 2014 11:20:07 +0000 Subject: [PATCH 3/7] Add notification-service.js to handle binging/notifications. Shift logic to this service. --- webclient/app.js | 1 + .../matrix/event-handler-service.js | 76 ++-------------- .../components/matrix/notification-service.js | 86 +++++++++++++++++++ webclient/index.html | 1 + webclient/room/room-controller.js | 14 ++- 5 files changed, 108 insertions(+), 70 deletions(-) create mode 100644 webclient/components/matrix/notification-service.js diff --git a/webclient/app.js b/webclient/app.js index 8d9b662ee..c091f8c6c 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -30,6 +30,7 @@ var matrixWebClient = angular.module('matrixWebClient', [ 'MatrixCall', 'eventStreamService', 'eventHandlerService', + 'notificationService', 'infinite-scroll', 'ui.bootstrap', 'monospaced.elastic' diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 45ee9e756..bcf805fc7 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -27,8 +27,8 @@ Typically, this service will store events or broadcast them to any listeners if typically all the $on method would do is update its own $scope. */ angular.module('eventHandlerService', []) -.factory('eventHandlerService', ['matrixService', '$rootScope', '$q', '$timeout', 'mPresence', -function(matrixService, $rootScope, $q, $timeout, mPresence) { +.factory('eventHandlerService', ['matrixService', '$rootScope', '$q', '$timeout', 'mPresence', 'notificationService', +function(matrixService, $rootScope, $q, $timeout, mPresence, notificationService) { var ROOM_CREATE_EVENT = "ROOM_CREATE_EVENT"; var MSG_EVENT = "MSG_EVENT"; var MEMBER_EVENT = "MEMBER_EVENT"; @@ -45,71 +45,6 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { var eventMap = {}; $rootScope.presence = {}; - - // TODO: This is attached to the rootScope so .html can just go containsBingWord - // for determining classes so it is easy to highlight bing messages. It seems a - // bit strange to put the impl in this service though, but I can't think of a better - // file to put it in. - $rootScope.containsBingWord = function(content) { - if (!content || $.type(content) != "string") { - return false; - } - var bingWords = matrixService.config().bingWords; - var shouldBing = false; - - // case-insensitive name check for user_id OR display_name if they exist - var userRegex = ""; - var myUserId = matrixService.config().user_id; - if (myUserId) { - var localpart = getLocalPartFromUserId(myUserId); - if (localpart) { - localpart = localpart.toLocaleLowerCase(); - userRegex += "\\b" + localpart + "\\b"; - } - } - var myDisplayName = matrixService.config().display_name; - if (myDisplayName) { - myDisplayName = myDisplayName.toLocaleLowerCase(); - if (userRegex.length > 0) { - userRegex += "|"; - } - userRegex += "\\b" + myDisplayName + "\\b"; - } - - var r = new RegExp(userRegex, 'i'); - if (content.search(r) >= 0) { - shouldBing = true; - } - - if ( (myDisplayName && content.toLocaleLowerCase().indexOf(myDisplayName) != -1) || - (myUserId && content.toLocaleLowerCase().indexOf(myUserId) != -1) ) { - shouldBing = true; - } - - // bing word list check - if (bingWords && !shouldBing) { - for (var i=0; i