From f4667f86afe249be69ba5f2bbfe70a5a02f5b2f7 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 15 Oct 2014 09:32:02 +0100 Subject: Add support for org.matrix.custom.text.html This format will remain undocumented as it is not yet suitable for introduction into the specification. --- webclient/components/matrix/event-handler-service.js | 1 + webclient/room/room.html | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'webclient') diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index e990d42d05..495c24ef59 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -460,6 +460,7 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { handleRoomAliases(event, isLiveEvent); break; case "m.room.message": + case "org.matrix.custom.text.html": handleMessage(event, isLiveEvent); break; case "m.room.member": diff --git a/webclient/room/room.html b/webclient/room/room.html index b99413cbbf..30277ab9fb 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -121,7 +121,8 @@ + ng-bind-html="(msg.content.msgtype === 'm.text' && msg.type === 'm.room.message') ? (msg.content.body | linky:'_blank') : + (msg.content.msgtype === 'm.text' && msg.type === 'org.matrix.custom.text.html') ? msg.content.body : '' "/> Outgoing Call{{ isWebRTCSupported ? '' : ' (But your browser does not support VoIP)' }} Incoming Call{{ isWebRTCSupported ? '' : ' (But your browser does not support VoIP)' }} -- cgit 1.5.1 From 07890b43ca739667b6974466739933ec2f2404e9 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 15 Oct 2014 13:57:19 +0100 Subject: Remove org.matrix.custom.text.html event type and replace it with 'format' and 'formatted_body' keys on m.text messages --- webclient/components/matrix/event-handler-service.js | 1 - webclient/room/room.html | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'webclient') diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 495c24ef59..e990d42d05 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -460,7 +460,6 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { handleRoomAliases(event, isLiveEvent); break; case "m.room.message": - case "org.matrix.custom.text.html": handleMessage(event, isLiveEvent); break; case "m.room.member": diff --git a/webclient/room/room.html b/webclient/room/room.html index 30277ab9fb..479b4c9a05 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -121,8 +121,8 @@ + ng-bind-html="(msg.content.msgtype === 'm.text' && msg.type === 'm.room.message' && msg.content.format === 'org.matrix.custom.html') ? msg.content.formatted_body : + (msg.content.msgtype === 'm.text' && msg.type === 'm.room.message') ? (msg.content.body | linky:'_blank') : '' "/> Outgoing Call{{ isWebRTCSupported ? '' : ' (But your browser does not support VoIP)' }} Incoming Call{{ isWebRTCSupported ? '' : ' (But your browser does not support VoIP)' }} -- cgit 1.5.1 From da19fd0d1aa526a1136af4389feb8f862952329d Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 15 Oct 2014 14:42:14 +0100 Subject: Add unsanitizedLinky filter to fix links in formatted messages. This filter is identical to ngSanitize's linky but instead of sanitizing text which isn't linkified in the addText function, it doesn't. --- webclient/app-filter.js | 59 ++++++++++++++++++++++++++++++++++++++++++++---- webclient/room/room.html | 3 ++- 2 files changed, 57 insertions(+), 5 deletions(-) (limited to 'webclient') diff --git a/webclient/app-filter.js b/webclient/app-filter.js index fc16492ef3..654783cb60 100644 --- a/webclient/app-filter.js +++ b/webclient/app-filter.js @@ -1,12 +1,12 @@ /* Copyright 2014 OpenMarket Ltd - + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -80,4 +80,55 @@ angular.module('matrixWebClient') return function(text) { return $sce.trustAsHtml(text); }; -}]); \ No newline at end of file +}]) +// Exactly the same as ngSanitize's linky but instead of pushing sanitized +// text in the addText function, we just push the raw text. This is ONLY SAFE +// IF THIS IS USED IN CONJUNCTION WITH NG-BIND-HTML which sweeps with $sanitize +// already. +.filter('unsanitizedLinky', ['$sanitize', function($sanitize) { + var LINKY_URL_REGEXP = + /((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"]/, + MAILTO_REGEXP = /^mailto:/; + + return function(text, target) { + if (!text) return text; + var match; + var raw = text; + var html = []; + var url; + var i; + while ((match = raw.match(LINKY_URL_REGEXP))) { + // We can not end in these as they are sometimes found at the end of the sentence + url = match[0]; + // if we did not match ftp/http/mailto then assume mailto + if (match[2] == match[3]) url = 'mailto:' + url; + i = match.index; + addText(raw.substr(0, i)); + addLink(url, match[0].replace(MAILTO_REGEXP, '')); + raw = raw.substring(i + match[0].length); + } + addText(raw); + return $sanitize(html.join('')); + + function addText(text) { + if (!text) { + return; + } + html.push(text); + } + + function addLink(url, text) { + html.push(''); + addText(text); + html.push(''); + } + }; +}]); diff --git a/webclient/room/room.html b/webclient/room/room.html index 479b4c9a05..79a60585a5 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -121,7 +121,8 @@ Outgoing Call{{ isWebRTCSupported ? '' : ' (But your browser does not support VoIP)' }} -- cgit 1.5.1 From 79bd6e77b8901b47539996c72d22b75d69585383 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 15 Oct 2014 14:45:38 +0100 Subject: Remove warning since the end result is still $sanitize'd --- webclient/app-filter.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'webclient') diff --git a/webclient/app-filter.js b/webclient/app-filter.js index 654783cb60..39ea1d637d 100644 --- a/webclient/app-filter.js +++ b/webclient/app-filter.js @@ -82,9 +82,7 @@ angular.module('matrixWebClient') }; }]) // Exactly the same as ngSanitize's linky but instead of pushing sanitized -// text in the addText function, we just push the raw text. This is ONLY SAFE -// IF THIS IS USED IN CONJUNCTION WITH NG-BIND-HTML which sweeps with $sanitize -// already. +// text in the addText function, we just push the raw text. .filter('unsanitizedLinky', ['$sanitize', function($sanitize) { var LINKY_URL_REGEXP = /((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"]/, -- cgit 1.5.1 From 514e0fd4b675cbb2ed36687095daa047730c60d8 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Fri, 17 Oct 2014 23:11:55 +0100 Subject: fix webclient to know about right timestamps --- webclient/room/room-controller.js | 4 ++-- webclient/room/room.html | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'webclient') diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index d8c62c231e..a1d2e87039 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -603,9 +603,9 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) var echoMessage = { content: { body: (cmd === "/me" ? args : input), - hsob_ts: new Date().getTime(), // fake a timestamp msgtype: (cmd === "/me" ? "m.emote" : "m.text"), }, + origin_server_ts: new Date().getTime(), // fake a timestamp room_id: $scope.room_id, type: "m.room.message", user_id: $scope.state.user_id, @@ -640,7 +640,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) if (echoMessage) { // Mark the message as unsent for the rest of the page life - echoMessage.content.hsob_ts = "Unsent"; + echoMessage.origin_server_ts = "Unsent"; echoMessage.echo_msg_state = "messageUnSent"; } }); diff --git a/webclient/room/room.html b/webclient/room/room.html index 79a60585a5..a3f8aee7ab 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -68,7 +68,6 @@ ng-hide="state.permission_denied" ng-style="{ 'visibility': state.messages_visibility }" keep-scroll> - @@ -76,7 +75,7 @@
{{ msg.user_id | mUserDisplayName: room_id }}
- {{ (msg.content.hsob_ts || msg.ts) | date:'MMM d HH:mm' }} + {{ (msg.origin_server_ts) | date:'MMM d HH:mm' }}
-- cgit 1.5.1 From 1342bcedaf1ddf0f45009e7f771f51ee0c32ca6f Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Fri, 24 Oct 2014 16:14:47 +0100 Subject: switch from the deprecated msg.content.prev to msg.prev_content.membership, and fix the bug where kicks of unjoined users aren't displayed sensibly in the history --- webclient/components/matrix/event-handler-service.js | 2 +- webclient/recents/recents.html | 8 ++++---- webclient/room/room.html | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'webclient') diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 492ec08bca..112b3ad96c 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -256,7 +256,7 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { // could be a membership change, display name change, etc. // Find out which one. var memberChanges = undefined; - if (event.content.prev !== event.content.membership) { + if (event.prev_content && (event.prev_content.membership !== event.content.membership)) { memberChanges = "membership"; } else if (event.prev_content && (event.prev_content.displayname !== event.content.displayname)) { diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index fe6a2f6368..a52b215c7e 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -42,12 +42,12 @@ {{lastMsg.state_key | mUserDisplayName: room.room_id }} left - + {{ lastMsg.user_id | mUserDisplayName: room.room_id }} - {{ {"join": "kicked", "ban": "unbanned"}[lastMsg.content.prev] }} + {{ {"invite": "kicked", "join": "kicked", "ban": "unbanned"}[lastMsg.prev_content.membership] }} {{ lastMsg.state_key | mUserDisplayName: room.room_id }} - + : {{ lastMsg.content.reason }} @@ -55,7 +55,7 @@ {{ lastMsg.user_id | mUserDisplayName: room.room_id }} {{ {"invite": "invited", "ban": "banned"}[lastMsg.content.membership] }} {{ lastMsg.state_key | mUserDisplayName: room.room_id }} - + : {{ lastMsg.content.reason }} diff --git a/webclient/room/room.html b/webclient/room/room.html index a3f8aee7ab..ce2c581903 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -91,11 +91,11 @@ {{ members[msg.state_key].displayname || msg.state_key }} left - + {{ members[msg.user_id].displayname || msg.user_id }} - {{ {"join": "kicked", "ban": "unbanned"}[msg.content.prev] }} + {{ {"invite": "kicked", "join": "kicked", "ban": "unbanned"}[msg.prev_content.membership] }} {{ members[msg.state_key].displayname || msg.state_key }} - + : {{ msg.content.reason }} @@ -105,7 +105,7 @@ {{ members[msg.user_id].displayname || msg.user_id }} {{ {"invite": "invited", "ban": "banned"}[msg.content.membership] }} {{ members[msg.state_key].displayname || msg.state_key }} - + : {{ msg.content.reason }} -- cgit 1.5.1
-- cgit 1.5.1 From e9abbe89f3fd465089b2840d954d93fba933a44a Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Fri, 17 Oct 2014 23:53:24 +0100 Subject: more timestamp fixes --- webclient/components/matrix/event-handler-service.js | 4 ++-- webclient/recents/recents-filter.js | 4 ++-- webclient/recents/recents.html | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'webclient') diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index e990d42d05..492ec08bca 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -148,10 +148,10 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { // ts is later. var latestData = true; if (!isLiveEvent) { - var eventTs = event.ts; + var eventTs = event.origin_server_ts; var storedEvent = $rootScope.events.rooms[event.room_id][event.type]; if (storedEvent) { - if (storedEvent.ts > eventTs) { + if (storedEvent.origin_server_ts > eventTs) { // ignore it, we have a newer one already. latestData = false; } diff --git a/webclient/recents/recents-filter.js b/webclient/recents/recents-filter.js index 468a746b18..ef8d9897f7 100644 --- a/webclient/recents/recents-filter.js +++ b/webclient/recents/recents-filter.js @@ -59,9 +59,9 @@ angular.module('RecentsController') return 1; } else { - return lastMsgRoomB.ts - lastMsgRoomA.ts; + return lastMsgRoomB.origin_server_ts - lastMsgRoomA.origin_server_ts; } }); return filtered; }; -}]); \ No newline at end of file +}]); diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index 9cbdcd357a..fe6a2f6368 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -18,7 +18,7 @@ Declaring it in this way ensures the data-binding --> {{ lastMsg = eventHandlerService.getLastMessage(room.room_id, true);"" }} - {{ (lastMsg.ts) | date:'MMM d HH:mm' }} + {{ (lastMsg.origin_server_ts) | date:'MMM d HH:mm' }} close