summary refs log tree commit diff
path: root/webclient/components
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-08-26 15:06:24 +0100
committerKegan Dougal <kegan@matrix.org>2014-08-26 15:06:24 +0100
commitb07bc9bdbdcf70755c1075e204e36e8ebd44e57d (patch)
treed7943508bd16f2c4e2d81590ad1edcc1ff1d4d5c /webclient/components
parentMerge branch 'client_server_url_rename' into develop (diff)
parentMerge branch 'develop' of github.com:matrix-org/synapse into client_server_ur... (diff)
downloadsynapse-b07bc9bdbdcf70755c1075e204e36e8ebd44e57d.tar.xz
Merge branch 'client_server_url_rename' into develop
Diffstat (limited to 'webclient/components')
-rw-r--r--webclient/components/matrix/matrix-service.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js
index b5b1815cf9..d376724e40 100644
--- a/webclient/components/matrix/matrix-service.js
+++ b/webclient/components/matrix/matrix-service.js
@@ -115,7 +115,7 @@ angular.module('matrixService', [])
 
         // Joins a room
         join: function(room_id) {
-            return this.membershipChange(room_id, config.user_id, "join");
+            return this.membershipChange(room_id, undefined, "join");
         },
 
         joinAlias: function(room_alias) {
@@ -134,18 +134,22 @@ angular.module('matrixService', [])
 
         // Leaves a room
         leave: function(room_id) {
-            return this.membershipChange(room_id, config.user_id, "leave");
+            return this.membershipChange(room_id, undefined, "leave");
         },
 
         membershipChange: function(room_id, user_id, membershipValue) {
             // The REST path spec
-            var path = "/rooms/$room_id/state/m.room.member/$user_id";
+            var path = "/rooms/$room_id/$membership";
             path = path.replace("$room_id", encodeURIComponent(room_id));
-            path = path.replace("$user_id", encodeURIComponent(user_id));
+            path = path.replace("$membership", encodeURIComponent(membershipValue));
 
-            return doRequest("PUT", path, undefined, {
-                 membership: membershipValue
-            });
+            var data = {};
+            if (user_id !== undefined) {
+                data = { user_id: user_id };
+            }
+
+            // TODO: Use PUT with transaction IDs
+            return doRequest("POST", path, undefined, data);
         },
 
         // Retrieves the room ID corresponding to a room alias