From 5b830f0b6a78e327a9fdca24ab0fe5acd68e3e51 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Tue, 21 Aug 2018 11:07:48 +0100 Subject: [PATCH] Add fetchRoomEvent to base-apis.js --- src/base-apis.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/base-apis.js b/src/base-apis.js index a85ed9bc6..73527ec44 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -417,6 +417,25 @@ MatrixBaseApis.prototype.roomState = function(roomId, callback) { return this._http.authedRequest(callback, "GET", path); }; +/** + * Get an event in a room by its event id. + * @param {string} roomId + * @param {string} eventId + * @param {module:client.callback} callback Optional. + * + * @return {Promise} Resolves to an object containing the event. + * @return {module:http-api.MatrixError} Rejects: with an error response. + */ +MatrixBaseApis.prototype.fetchRoomEvent = function(roomId, eventId, callback) { + const path = utils.encodeUri( + "/rooms/$roomId/event/$eventId", { + $roomId: roomId, + $eventId: eventId, + }, + ); + return this._http.authedRequest(callback, "GET", path); +}; + /** * @param {string} roomId * @param {string} includeMembership the membership type to include in the response