diff --git a/src/base-apis.js b/src/base-apis.js index 2d1c95d2c..d8b51dcdd 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -439,6 +439,17 @@ MatrixBaseApis.prototype.createRoom = function(options, callback) { ); }; +MatrixBaseApis.prototype.fetchRelations = + async function(roomId, eventId, relationType, eventType) { + // valid options include: room_alias_name, visibility, invite + const response = await this._http.authedRequestWithPrefix( + undefined, + "GET", `/rooms/${roomId}/relations/${eventId}/${relationType}/${eventType}`, + null, null, httpApi.PREFIX_UNSTABLE, + ); + return response.chunk; +}; + /** * @param {string} roomId * @param {module:client.callback} callback Optional. diff --git a/src/client.js b/src/client.js index 920055012..c6113bea7 100644 --- a/src/client.js +++ b/src/client.js @@ -3965,6 +3965,12 @@ MatrixClient.prototype.getCanResetTimelineCallback = function() { return this._canResetTimelineCallback; }; +MatrixClient.prototype.relations = +async function(roomId, eventId, relationType, eventType) { + const events = await this.fetchRelations(roomId, eventId, relationType, eventType); + return events.map(this.getEventMapper()); +}; + function setupCallEventHandler(client) { const candidatesByCall = { // callId: [Candidate]