summary refs log tree commit diff
path: root/webclient
diff options
context:
space:
mode:
authorEmmanuel ROHEE <erohee@amdocs.com>2014-09-03 11:17:58 +0200
committerEmmanuel ROHEE <erohee@amdocs.com>2014-09-03 11:17:58 +0200
commit56427b8057db532ca0887e14e71cb0071dcc6903 (patch)
treeba7da309049659eb32957762898dd3b2568554e2 /webclient
parentMade IRC style command easier to handle specifically for possible arguments (diff)
downloadsynapse-56427b8057db532ca0887e14e71cb0071dcc6903.tar.xz
Added /ban command
Diffstat (limited to 'webclient')
-rw-r--r--webclient/components/matrix/matrix-service.js14
-rw-r--r--webclient/room/room-controller.js16
2 files changed, 29 insertions, 1 deletions
diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js
index 2ae55bea9f..869c1f731d 100644
--- a/webclient/components/matrix/matrix-service.js
+++ b/webclient/components/matrix/matrix-service.js
@@ -165,6 +165,17 @@ angular.module('matrixService', [])
             // TODO: Use PUT with transaction IDs
             return doRequest("POST", path, undefined, data);
         },
+           
+        // Bans a user from from a room
+        ban: function(room_id, user_id, reason) {
+            var path = "/rooms/$room_id/ban/";
+            path = path.replace("$room_id", encodeURIComponent(room_id));
+            
+            return doRequest("PUT", path, undefined, {
+                user_id: user_id,
+                reason: reason
+            });
+        },
 
         // Retrieves the room ID corresponding to a room alias
         resolveRoomAlias:function(room_alias) {
@@ -408,7 +419,8 @@ angular.module('matrixService', [])
                 state: presence
             });
         },
-
+        
+        
         /****** Permanent storage of user information ******/
         
         // Returns the current config
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js
index da2a9b0e77..fcd24c2749 100644
--- a/webclient/room/room-controller.js
+++ b/webclient/room/room-controller.js
@@ -269,6 +269,22 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
                         promise = matrixService.setDisplayName(args[1]);
                     }
                     break;
+                    
+                case "/ban":
+                    // Ban the user id from the room
+                    if (2 <= args.length) {
+
+                        // TODO: The user may have entered the display name
+                        // Need display name -> user_id resolution. Pb: how to manage user with same display names?
+                        var user_id = args[1];
+
+                        // Does the user provide a reason?
+                        if (3 <= args.length) {
+                            var reason = args.slice(2).join(' ');
+                        }
+                        promise = matrixService.ban($scope.room_id, user_id, reason);
+                    }
+                    break;
             }
         }
         else {