You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Merge pull request #967 from matrix-org/bwindels/edit-history
Relations endpoint support
This commit is contained in:
@@ -438,6 +438,35 @@ MatrixBaseApis.prototype.createRoom = function(options, callback) {
|
|||||||
callback, "POST", "/createRoom", undefined, options,
|
callback, "POST", "/createRoom", undefined, options,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Fetches relations for a given event
|
||||||
|
* @param {string} roomId the room of the event
|
||||||
|
* @param {string} eventId the id of the event
|
||||||
|
* @param {string} relationType the rel_type of the relations requested
|
||||||
|
* @param {string} eventType the event type of the relations requested
|
||||||
|
* @param {Object} opts options with optional values for the request.
|
||||||
|
* @param {Object} opts.from the pagination token returned from a previous request as `next_batch` to return following relations.
|
||||||
|
* @return {Object} the response, with chunk and next_batch.
|
||||||
|
*/
|
||||||
|
MatrixBaseApis.prototype.fetchRelations =
|
||||||
|
async function(roomId, eventId, relationType, eventType, opts) {
|
||||||
|
const queryParams = {};
|
||||||
|
if (opts.from) {
|
||||||
|
queryParams.from = opts.from;
|
||||||
|
}
|
||||||
|
const queryString = utils.encodeParams(queryParams);
|
||||||
|
const path = utils.encodeUri(
|
||||||
|
"/rooms/$roomId/relations/$eventId/$relationType/$eventType?" + queryString, {
|
||||||
|
$roomId: roomId,
|
||||||
|
$eventId: eventId,
|
||||||
|
$relationType: relationType,
|
||||||
|
$eventType: eventType,
|
||||||
|
});
|
||||||
|
const response = await this._http.authedRequestWithPrefix(
|
||||||
|
undefined, "GET", path, null, null, httpApi.PREFIX_UNSTABLE,
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} roomId
|
* @param {string} roomId
|
||||||
|
|||||||
@@ -3979,6 +3979,30 @@ MatrixClient.prototype.getCanResetTimelineCallback = function() {
|
|||||||
return this._canResetTimelineCallback;
|
return this._canResetTimelineCallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns relations for a given event
|
||||||
|
* @param {string} roomId the room of the event
|
||||||
|
* @param {string} eventId the id of the event
|
||||||
|
* @param {string} relationType the rel_type of the relations requested
|
||||||
|
* @param {string} eventType the event type of the relations requested
|
||||||
|
* @param {Object} opts options with optional values for the request.
|
||||||
|
* @param {Object} opts.from the pagination token returned from a previous request as `nextBatch` to return following relations.
|
||||||
|
* @return {Object} an object with `events` as `MatrixEvent[]` and optionally `nextBatch` if more relations are available.
|
||||||
|
*/
|
||||||
|
MatrixClient.prototype.relations =
|
||||||
|
async function(roomId, eventId, relationType, eventType, opts = {}) {
|
||||||
|
const result = await this.fetchRelations(
|
||||||
|
roomId,
|
||||||
|
eventId,
|
||||||
|
relationType,
|
||||||
|
eventType,
|
||||||
|
opts);
|
||||||
|
return {
|
||||||
|
events: result.chunk.map(this.getEventMapper()),
|
||||||
|
nextBatch: result.next_batch,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
function setupCallEventHandler(client) {
|
function setupCallEventHandler(client) {
|
||||||
const candidatesByCall = {
|
const candidatesByCall = {
|
||||||
// callId: [Candidate]
|
// callId: [Candidate]
|
||||||
|
|||||||
Reference in New Issue
Block a user