From 89cabba3e0decc55e551364ff7acc0649fa8a160 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Tue, 19 Aug 2014 14:48:05 +0100 Subject: [PATCH 1/4] Don't delete OFFLINE users from the presence cache, so we can report on their offline mtime --- synapse/handlers/presence.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 7e725d102..a2152c99c 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -231,9 +231,6 @@ class PresenceHandler(BaseHandler): # we don't have to do this all the time self.changed_presencelike_data(target_user, state) - if not now_online: - del self._user_cachemap[target_user] - def changed_presencelike_data(self, user, state): statuscache = self._get_or_make_usercache(user) From c5d601d5cd45dfc995bc5e66952adbaf3536a0ae Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Tue, 19 Aug 2014 16:24:49 +0200 Subject: [PATCH 2/4] Cleaned dead code --- webclient/components/matrix/matrix-service.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index b67beb007..2463b5120 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -68,9 +68,7 @@ angular.module('matrixService', []) params: params, data: data, headers: headers - }) - - return deferred.promise; + }); }; From 4f773de6baeeee0d0a3d4aa3606dec0d45698ce5 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Tue, 19 Aug 2014 16:37:31 +0200 Subject: [PATCH 3/4] BF: The enter key in the image URL box called sendImage() with no argument --- 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 36bd95c1b..8cae7ee51 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -76,7 +76,7 @@ - + From b796d4b9d04981418082f4e71b98e7af1eb211ee Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 19 Aug 2014 16:39:30 +0100 Subject: [PATCH 4/4] Added registration/login jsfiddle, formatted so it can be loaded directly from jsfiddle. Requires jQuery 1.8.3 --- docs/client-server/howto.rst | 3 +- jsfiddles/register_login/demo.css | 7 +++ jsfiddles/register_login/demo.html | 20 +++++++++ jsfiddles/register_login/demo.js | 69 ++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 jsfiddles/register_login/demo.css create mode 100644 jsfiddles/register_login/demo.html create mode 100644 jsfiddles/register_login/demo.js diff --git a/docs/client-server/howto.rst b/docs/client-server/howto.rst index de096ab60..57a2d2424 100644 --- a/docs/client-server/howto.rst +++ b/docs/client-server/howto.rst @@ -2,7 +2,8 @@ TODO(kegan): Tweak joinalias API keys/path? Event stream historical > live needs a token (currently doesn't). im/sync responses include outdated event formats (room membership change messages). Room config (specifically: message history, public rooms). /register seems super simplistic compared to /login, maybe it -would be better if /register used the same technique as /login? +would be better if /register used the same technique as /login? /register should +be "user" not "user_id". How to use the client-server API diff --git a/jsfiddles/register_login/demo.css b/jsfiddles/register_login/demo.css new file mode 100644 index 000000000..11781c250 --- /dev/null +++ b/jsfiddles/register_login/demo.css @@ -0,0 +1,7 @@ +.loggedin { + visibility: hidden; +} + +p { + font-family: monospace; +} diff --git a/jsfiddles/register_login/demo.html b/jsfiddles/register_login/demo.html new file mode 100644 index 000000000..9cdb16130 --- /dev/null +++ b/jsfiddles/register_login/demo.html @@ -0,0 +1,20 @@ +
+

This registration/login demo requires a home server to be running on http://localhost:8080

+
+
+ + + +
+
+ + + +
+
+

+ + +

+
+ diff --git a/jsfiddles/register_login/demo.js b/jsfiddles/register_login/demo.js new file mode 100644 index 000000000..1644f76ac --- /dev/null +++ b/jsfiddles/register_login/demo.js @@ -0,0 +1,69 @@ +var accountInfo = {}; + +var showLoggedIn = function(data) { + accountInfo = data; + $(".loggedin").css({visibility: "visible"}); + $("#welcomeText").text("Welcome " + accountInfo.user_id+". Your access token is: " + + accountInfo.access_token); +}; + +$('.register').live('click', function() { + var user = $("#user").val(); + var password = $("#password").val(); + $.ajax({ + url: "http://localhost:8080/matrix/client/api/v1/register", + type: "POST", + contentType: "application/json; charset=utf-8", + data: JSON.stringify({ user_id: user, password: password }), + dataType: "json", + success: function(data) { + showLoggedIn(data); + }, + error: function(err) { + alert(JSON.stringify($.parseJSON(err.responseText))); + } + }); +}); + +var login = function(user, password) { + $.ajax({ + url: "http://localhost:8080/matrix/client/api/v1/login", + type: "POST", + contentType: "application/json; charset=utf-8", + data: JSON.stringify({ user: user, password: password, type: "m.login.password" }), + dataType: "json", + success: function(data) { + showLoggedIn(data); + }, + error: function(err) { + alert(JSON.stringify($.parseJSON(err.responseText))); + } + }); +}; + +$('.login').live('click', function() { + var user = $("#userLogin").val(); + var password = $("#passwordLogin").val(); + $.getJSON("http://localhost:8080/matrix/client/api/v1/login", function(data) { + if (data.type !== "m.login.password") { + alert("I don't know how to login with this type: " + data.type); + return; + } + login(user, password); + }); +}); + +$('.logout').live('click', function() { + accountInfo = {}; + $("#imSyncText").text(""); + $(".loggedin").css({visibility: "hidden"}); +}); + +$('.testToken').live('click', function() { + var url = "http://localhost:8080/matrix/client/api/v1/im/sync?access_token=" + accountInfo.access_token + "&from=END&to=START&limit=1"; + $.getJSON(url, function(data) { + $("#imSyncText").text(JSON.stringify(data, undefined, 2)); + }).fail(function(err) { + $("#imSyncText").text(JSON.stringify($.parseJSON(err.responseText))); + }); +});