You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-04 05:02:41 +03:00
Merge pull request #1027 from matrix-org/travis/synapse_admin
Add Synapse admin functions for deactivating a user
This commit is contained in:
@@ -3948,6 +3948,55 @@ MatrixClient.prototype.isFallbackICEServerAllowed = function() {
|
|||||||
return this._fallbackICEServerAllowed;
|
return this._fallbackICEServerAllowed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Synapse-specific APIs
|
||||||
|
// =====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if the current user is an administrator of the Synapse homeserver.
|
||||||
|
* Returns false if untrue or the homeserver does not appear to be a Synapse
|
||||||
|
* homeserver. <strong>This function is implementation specific and may change
|
||||||
|
* as a result.</strong>
|
||||||
|
* @return {boolean} true if the user appears to be a Synapse administrator.
|
||||||
|
*/
|
||||||
|
MatrixClient.prototype.isSynapseAdministrator = function() {
|
||||||
|
return this.whoisSynapseUser(this.getUserId())
|
||||||
|
.then(() => true)
|
||||||
|
.catch(() => false);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a whois lookup on a user using Synapse's administrator API.
|
||||||
|
* <strong>This function is implementation specific and may change as a
|
||||||
|
* result.</strong>
|
||||||
|
* @param {string} userId the User ID to look up.
|
||||||
|
* @return {object} the whois response - see Synapse docs for information.
|
||||||
|
*/
|
||||||
|
MatrixClient.prototype.whoisSynapseUser = function(userId) {
|
||||||
|
const path = utils.encodeUri(
|
||||||
|
"/_synapse/admin/v1/whois/$userId",
|
||||||
|
{ $userId: userId },
|
||||||
|
);
|
||||||
|
return this._http.authedRequest(
|
||||||
|
undefined, 'GET', path, undefined, undefined, {prefix: ''},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deactivates a user using Synapse's administrator API. <strong>This
|
||||||
|
* function is implementation specific and may change as a result.</strong>
|
||||||
|
* @param {string} userId the User ID to deactivate.
|
||||||
|
* @return {object} the deactivate response - see Synapse docs for information.
|
||||||
|
*/
|
||||||
|
MatrixClient.prototype.deactivateSynapseUser = function(userId) {
|
||||||
|
const path = utils.encodeUri(
|
||||||
|
"/_synapse/admin/v1/deactivate/$userId",
|
||||||
|
{ $userId: userId },
|
||||||
|
);
|
||||||
|
return this._http.authedRequest(
|
||||||
|
undefined, 'POST', path, undefined, undefined, {prefix: ''},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Higher level APIs
|
// Higher level APIs
|
||||||
// =================
|
// =================
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user