Don't bing for sent messages. Handle cases where the member is unknown rather than erroring out.

pull/10/head
Kegan Dougal 2014-09-16 16:23:20 +01:00
parent d7b206cc93
commit 95e171e19a
2 changed files with 9 additions and 4 deletions

View File

@ -177,7 +177,7 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
$rootScope.events.rooms[event.room_id].messages.push(event);
}
if (window.Notification) {
if (window.Notification && event.user_id != matrixService.config().user_id) {
var shouldBing = $rootScope.containsBingWord(event.content.body);
// TODO: Binging every message when idle doesn't make much sense. Can we use this more sensibly?
@ -195,12 +195,17 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
if (shouldBing) {
console.log("Displaying notification for "+JSON.stringify(event));
var member = $rootScope.events.rooms[event.room_id].members[event.user_id];
var displayname = undefined;
if (member) {
displayname = member.displayname;
}
var notification = new window.Notification(
($rootScope.events.rooms[event.room_id].members[event.user_id].displayname || event.user_id) +
(displayname || event.user_id) +
" (" + (matrixService.getRoomIdToAliasMapping(event.room_id) || event.room_id) + ")", // FIXME: don't leak room_ids here
{
"body": event.content.body,
"icon": $rootScope.events.rooms[event.room_id].members[event.user_id].avatar_url
"icon": member ? member.avatar_url : undefined
});
$timeout(function() {
notification.close();

View File

@ -105,7 +105,7 @@
<span ng-show='msg.content.msgtype === "m.text"'
class="message"
ng-class="containsBingWord(msg.content.body) ? msg.echo_msg_state + ' messageBing' : msg.echo_msg_state"
ng-class="containsBingWord(msg.content.body) && msg.user_id != state.user_id ? msg.echo_msg_state + ' messageBing' : msg.echo_msg_state"
ng-bind-html="((msg.content.msgtype === 'm.text') ? msg.content.body : '') | linky:'_blank'"/>
<span ng-show='msg.type === "m.call.invite" && msg.user_id == state.user_id'>Outgoing Call</span>