From 6d4617960d0223c13f8145b31df86e1f1f8d43ec Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 29 Oct 2014 15:31:50 +0000 Subject: [PATCH] SYWEB-98: Add redactEvent matrix API call. --- webclient/components/matrix/matrix-service.js | 8 +++++++ webclient/room/room-controller.js | 22 ++++++++++++++++++- webclient/room/room.html | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index a4f0568bc..1840cf46c 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -438,6 +438,14 @@ angular.module('matrixService', []) return this.sendMessage(room_id, msg_id, content); }, + redactEvent: function(room_id, event_id) { + var path = "/rooms/$room_id/redact/$event_id"; + path = path.replace("$room_id", room_id); + path = path.replace("$event_id", event_id); + var content = {}; + return doRequest("POST", path, undefined, content); + }, + // get a snapshot of the members in a room. getMemberList: function(room_id) { // Like the cmd client, escape room ids diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index c4014b2fe..841b5cccd 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -995,6 +995,26 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) controller: 'EventInfoController', scope: $scope }); + + modalInstance.result.then(function(action) { + if (action === "redact") { + var eventId = $scope.event_selected.event_id; + console.log("Redacting event ID " + eventId); + matrixService.redactEvent( + $scope.event_selected.room_id, + eventId + ).then(function(response) { + console.log("Redaction = " + JSON.stringify(response)); + }, function(error) { + console.error("Failed to redact event: "+JSON.stringify(error)); + if (error.data.error) { + $scope.feedback = error.data.error; + } + }); + } + }, function() { + // any dismiss code + }); }; }]) @@ -1004,6 +1024,6 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) console.log("User level = "+$scope.pow($scope.room_id, $scope.state.user_id)+ " Redact level = "+$scope.events.rooms[$scope.room_id]["m.room.ops_levels"].content.redact_level); console.log("Redact event >> " + JSON.stringify($scope.event_selected)); - $modalInstance.dismiss(); + $modalInstance.close("redact"); }; }); diff --git a/webclient/room/room.html b/webclient/room/room.html index 5293a579d..85ae0eeca 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -6,7 +6,7 @@