summary refs log tree commit diff
path: root/webclient/components
diff options
context:
space:
mode:
authorEmmanuel ROHEE <erohee@amdocs.com>2014-09-05 17:30:50 +0200
committerEmmanuel ROHEE <erohee@amdocs.com>2014-09-05 17:30:50 +0200
commit3be615677407a4224202a3ae107762b1f3bc97ac (patch)
tree8f175e43edbee68065535b44862f3eb6b5abb05e /webclient/components
parentAdded sanity checks in commands (diff)
downloadsynapse-3be615677407a4224202a3ae107762b1f3bc97ac.tar.xz
Created kick & unban methods in matrixService. Made some factorisation.
Diffstat (limited to 'webclient/components')
-rw-r--r--webclient/components/matrix/matrix-service.js32
1 files changed, 21 insertions, 11 deletions
diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js
index 18a4841298..8a0223979c 100644
--- a/webclient/components/matrix/matrix-service.js
+++ b/webclient/components/matrix/matrix-service.js
@@ -168,23 +168,20 @@ angular.module('matrixService', [])
         },
 
         // Change the membership of an another user
-        setMembership: function(room_id, user_id, membershipValue) {
-            return this.setMembershipObject(room_id, user_id, {
-                membership : membershipValue
-            });
-        },
-           
-        // Change the membership of an another user
-        setMembershipObject: function(room_id, user_id, membershipObject) {
+        setMembership: function(room_id, user_id, membershipValue, reason) {
+            
             // The REST path spec
             var path = "/rooms/$room_id/state/m.room.member/$user_id";
             path = path.replace("$room_id", encodeURIComponent(room_id));
             path = path.replace("$user_id", user_id);
 
-            return doRequest("PUT", path, undefined, membershipObject);
+            return doRequest("PUT", path, undefined, {
+                membership : membershipValue,
+                reason: reason
+            });
         },
            
-        // Bans a user from from a room
+        // Bans a user from a room
         ban: function(room_id, user_id, reason) {
             var path = "/rooms/$room_id/ban";
             path = path.replace("$room_id", encodeURIComponent(room_id));
@@ -194,7 +191,20 @@ angular.module('matrixService', [])
                 reason: reason
             });
         },
-
+        
+        // Unbans a user in a room
+        unban: function(room_id, user_id) {
+            // FIXME: To update when there will be homeserver API for unban 
+            // For now, do an unban by resetting the user membership to "leave"
+            return this.setMembership(room_id, user_id, "leave");
+        },
+        
+        // Kicks a user from a room
+        kick: function(room_id, user_id, reason) {
+            // Set the user membership to "leave" to kick him
+            return this.setMembership(room_id, user_id, "leave", reason);
+        },
+        
         // Retrieves the room ID corresponding to a room alias
         resolveRoomAlias:function(room_alias) {
             var path = "/_matrix/client/api/v1/directory/room/$room_alias";