From baca20b22579725ba4869aaca33c1054d388de0e Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 20 Aug 2018 11:14:45 +0100 Subject: [PATCH 1/5] Add support for /rooms/$roomId/event/$eventId --- src/client.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/client.js b/src/client.js index b9ad51bcb..c33d02a7a 100644 --- a/src/client.js +++ b/src/client.js @@ -2071,6 +2071,28 @@ MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) { return promise; }; +/** + * Get an event in a room by its event id. + * + * This blindly calls the /rooms/$roomId/event/$eventId endpoint. + * + * @param {string} roomId The ID of the room to look in + * @param {string} eventId The ID of the event to look for + * + * @return {Promise} Resolves to an object containing the event. + */ +MatrixClient.prototype.fetchRoomEvent = function(roomId, eventId) { + const path = utils.encodeUri( + "/rooms/$roomId/event/$eventId", { + $roomId: roomId, + $eventId: eventId, + }, + ); + return this._http.authedRequest( + callback, "GET", path, + ); +} + /** * Makes a request to /messages with the appropriate lazy loading filter set. * XXX: if we do get rid of scrollback (as it's not used at the moment), From 79ca68300cb5f2276cc3d351aaa9cd6db8bc015d Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 20 Aug 2018 12:47:26 +0100 Subject: [PATCH 2/5] Add callback --- src/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index c33d02a7a..8f8884b2c 100644 --- a/src/client.js +++ b/src/client.js @@ -2081,7 +2081,7 @@ MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) { * * @return {Promise} Resolves to an object containing the event. */ -MatrixClient.prototype.fetchRoomEvent = function(roomId, eventId) { +MatrixClient.prototype.fetchRoomEvent = function(roomId, eventId, callback) { const path = utils.encodeUri( "/rooms/$roomId/event/$eventId", { $roomId: roomId, From df7dc04a1d66718c9bcbd5745ff1ca21613c4b95 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 20 Aug 2018 14:16:47 +0100 Subject: [PATCH 3/5] Happy linter, happy developer --- src/client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 8f8884b2c..6ef6e9dfd 100644 --- a/src/client.js +++ b/src/client.js @@ -2078,6 +2078,7 @@ MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) { * * @param {string} roomId The ID of the room to look in * @param {string} eventId The ID of the event to look for + * @param {module:client.callback} callback Optional. * * @return {Promise} Resolves to an object containing the event. */ @@ -2091,7 +2092,7 @@ MatrixClient.prototype.fetchRoomEvent = function(roomId, eventId, callback) { return this._http.authedRequest( callback, "GET", path, ); -} +}; /** * Makes a request to /messages with the appropriate lazy loading filter set. From 3d24c8768f748671947858f2d5769b3489923d18 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Tue, 21 Aug 2018 11:07:37 +0100 Subject: [PATCH 4/5] Drop fetchRoomEvent from client.js --- src/client.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/client.js b/src/client.js index 6ef6e9dfd..b9ad51bcb 100644 --- a/src/client.js +++ b/src/client.js @@ -2071,29 +2071,6 @@ MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) { return promise; }; -/** - * Get an event in a room by its event id. - * - * This blindly calls the /rooms/$roomId/event/$eventId endpoint. - * - * @param {string} roomId The ID of the room to look in - * @param {string} eventId The ID of the event to look for - * @param {module:client.callback} callback Optional. - * - * @return {Promise} Resolves to an object containing the event. - */ -MatrixClient.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, - ); -}; - /** * Makes a request to /messages with the appropriate lazy loading filter set. * XXX: if we do get rid of scrollback (as it's not used at the moment), From 5b830f0b6a78e327a9fdca24ab0fe5acd68e3e51 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Tue, 21 Aug 2018 11:07:48 +0100 Subject: [PATCH 5/5] 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