raiden-ts
Version:
Raiden Light Client Typescript/Javascript SDK
25 lines • 956 B
JavaScript
import { Method } from 'matrix-js-sdk';
import { encodeUri } from 'matrix-js-sdk/lib/utils';
/**
* Return server name without schema or path
*
* @param server - any URL
* @returns server URL with domain and port (if present), without schema, paths or query params
*/
export function getServerName(server) {
const match = /^(?:\w*:?\/\/)?([^/#?&]+)/.exec(server);
return match && match[1];
}
/**
* MatrixClient doesn't expose this API, but it does exist, so we create it here
*
* @param matrix - an already setup and started MatrixClient
* @param userId - to fetch status/presence from
* @returns Promise to object containing status data
*/
export function getUserPresence(matrix, userId) {
const path = encodeUri('/presence/$userId/status', { $userId: userId });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return matrix.http.authedRequest(undefined, Method.Get, path);
}
//# sourceMappingURL=matrix.js.map