UNPKG

raiden-ts

Version:

Raiden Light Client Typescript/Javascript SDK

30 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getUserPresence = exports.getServerName = void 0; const matrix_js_sdk_1 = require("matrix-js-sdk"); const utils_1 = require("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 */ function getServerName(server) { const match = /^(?:\w*:?\/\/)?([^/#?&]+)/.exec(server); return match && match[1]; } exports.getServerName = getServerName; /** * 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 */ function getUserPresence(matrix, userId) { const path = (0, utils_1.encodeUri)('/presence/$userId/status', { $userId: userId }); // eslint-disable-next-line @typescript-eslint/no-explicit-any return matrix.http.authedRequest(undefined, matrix_js_sdk_1.Method.Get, path); } exports.getUserPresence = getUserPresence; //# sourceMappingURL=matrix.js.map