summary refs log tree commit diff
path: root/webclient/home/home-controller.js
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2014-09-23 13:36:58 +0100
committerMatthew Hodgson <matthew@matrix.org>2014-09-23 13:36:58 +0100
commit4847045259a631a2f1e03fd9751df301e6589560 (patch)
tree9cd1cdc0139983b5b6365e464170e67234fec68a /webclient/home/home-controller.js
parentfix NPE (diff)
downloadsynapse-4847045259a631a2f1e03fd9751df301e6589560.tar.xz
send messages to users from the home page (SYWEB-19)
Diffstat (limited to 'webclient/home/home-controller.js')
-rw-r--r--webclient/home/home-controller.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/webclient/home/home-controller.js b/webclient/home/home-controller.js
index e35219bebb..a535d439d3 100644
--- a/webclient/home/home-controller.js
+++ b/webclient/home/home-controller.js
@@ -42,6 +42,10 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen
         displayName: "",
         avatarUrl: ""
     };
+    
+    $scope.newChat = {
+        user: ""
+    };
 
     var refresh = function() {
         
@@ -112,6 +116,32 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen
             }
         );
     };
+    
+    // FIXME: factor this out between user-controller and home-controller etc.
+    $scope.messageUser = function() {    
+        
+        // FIXME: create a new room every time, for now
+        
+        matrixService.create(null, 'private').then(
+            function(response) { 
+                // This room has been created. Refresh the rooms list
+                var room_id = response.data.room_id;
+                console.log("Created room with id: "+ room_id);
+                
+                matrixService.invite(room_id, $scope.newChat.user).then(
+                    function() {
+                        $scope.feedback = "Invite sent successfully";
+                        $scope.$parent.goToPage("/room/" + room_id);
+                    },
+                    function(reason) {
+                        $scope.feedback = "Failure: " + JSON.stringify(reason);
+                    });
+            },
+            function(error) {
+                $scope.feedback = "Failure: " + JSON.stringify(error.data);
+            });                
+    };
+    
  
     $scope.onInit = function() {
         // Load profile data