Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add method for new /aliases endpoint #1219

Merged
merged 4 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/base-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,21 @@ MatrixBaseApis.prototype.deleteAlias = function(alias, callback) {
);
};

/**
* @param {string} roomId
* @param {module:client.callback} callback Optional.
* @return {Promise} Resolves: an object with an `aliases` property, containing an array of local aliases
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.unstableGetLocalAliases =
function(roomId, callback) {
const path = utils.encodeUri("/rooms/$roomId/aliases",
{$roomId: roomId});
const prefix = PREFIX_UNSTABLE + "/org.matrix.msc2432";
return this._http.authedRequest(callback, "GET", path,
null, null, { prefix });
};

/**
* Get room info for the given alias.
* @param {string} alias The room alias to resolve.
Expand Down
13 changes: 13 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4797,6 +4797,19 @@ MatrixClient.prototype.doesServerSupportSeparateAddAndBind = async function() {
|| (unstableFeatures && unstableFeatures["m.separate_add_and_bind"]);
};

/**
* Query the server to see if it lists support for an unstable feature
* in the /versions response
* @param {string} feature the feature name
* @return {Promise<boolean>} true if the feature is supported
*/
MatrixClient.prototype.doesServerSupportUnstableFeature = async function(feature) {
const response = await this.getVersions();
if (!response) return false;
const unstableFeatures = response["unstable_features"];
return unstableFeatures && !!unstableFeatures[feature];
};

/**
* Get if lazy loading members is being used.
* @return {boolean} Whether or not members are lazy loaded by this client
Expand Down