From a402e0c5e6e432a175b48279c972bc9ae7e944bc Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 16 Sep 2014 15:15:19 +0100 Subject: [PATCH] Added bing detection logic. Persist the display name of the user in localstorage for use when binging. --- .../matrix/event-handler-service.js | 37 ++++++++++++++++++- webclient/home/home-controller.js | 4 ++ webclient/room/room-controller.js | 4 +- webclient/settings/settings.html | 6 +-- 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 8783b9b1e0..16d5763ed2 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -140,8 +140,41 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { } if (window.Notification) { - // Show notification when the window is hidden, or the user is idle - if (document.hidden || matrixService.presence.unavailable === mPresence.getState()) { + var bingWords = matrixService.config().bingWords; + var content = event.content.body; + var shouldBing = false; + + // case-insensitive name check for user_id OR display_name if they exist + var myUserId = matrixService.config().user_id; + if (myUserId) { + myUserId = myUserId.toLocaleLowerCase(); + } + var myDisplayName = matrixService.config().display_name; + if (myDisplayName) { + myDisplayName = myDisplayName.toLocaleLowerCase(); + } + 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; iDesktop notifications
- Notifications are enabled. + Notifications are enabled. You will be alerted when a message contains your user ID or display name.
-

Words to alert on:

- Additional words to alert on: +
  • {{word}}