From 597a71fa9de3c83959fb7f48bf923cc21b688827 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Tue, 5 Dec 2017 11:59:02 +0000 Subject: [PATCH] Add messaging endpoint for room encryption status. --- src/ScalarMessaging.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index 7698829647..7bde607451 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -366,6 +366,22 @@ function getWidgets(event, roomId) { sendResponse(event, widgetStateEvents); } +function getRoomEncState(event, roomId) { + const client = MatrixClientPeg.get(); + if (!client) { + sendError(event, _t('You need to be logged in.')); + return; + } + const room = client.getRoom(roomId); + if (!room) { + sendError(event, _t('This room is not recognised.')); + return; + } + const roomIsEncrypted = MatrixClientPeg.get().isRoomEncrypted(roomId); + + sendResponse(event, roomIsEncrypted); +} + function setPlumbingState(event, roomId, status) { if (typeof status !== 'string') { throw new Error('Plumbing state status should be a string'); @@ -593,6 +609,9 @@ const onMessage = function(event) { } else if (event.data.action === "get_widgets") { getWidgets(event, roomId); return; + } else if (event.data.action === "get_room_enc_state") { + getRoomEncState(event, roomId); + return; } else if (event.data.action === "can_send_event") { canSendEvent(event, roomId); return;