From c292312115ea580553f46977e3b8570afcfea6cb Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 24 Aug 2016 14:54:44 +0100 Subject: [PATCH] Send bot options with leading underscore on the state key This is in order to get around the synapse rule which states that if the state key is a user ID, then only that user can send the event. We want to set the event for another user (the bot), hence we can't send just the plain user ID. --- src/ScalarMessaging.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index 3e370b546f..cc552ba898 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -179,12 +179,12 @@ function setBotOptions(event, roomId, userId) { sendError(event, "You need to be logged in."); return; } - client.sendStateEvent(roomId, "m.room.bot.options", event.data.content, userId).done(() => { + client.sendStateEvent(roomId, "m.room.bot.options", event.data.content, "_" + userId).done(() => { sendResponse(event, { success: true, }); }, (err) => { - sendError(event, "Failed to send request.", err); + sendError(event, err.message ? err.message : "Failed to send request.", err); }); } @@ -195,7 +195,7 @@ function getMembershipState(event, roomId, userId) { function botOptions(event, roomId, userId) { console.log(`bot_options of ${userId} in room ${roomId} requested.`); - returnStateEvent(event, roomId, "m.room.bot.options", userId); + returnStateEvent(event, roomId, "m.room.bot.options", "_" + userId); }