/** * Utility class for common operations performed by bridges (represented * as appservices). * * The storage utilities are not intended for bridges which allow 1:many * relationships with the remote network. * * Bridges are generally expected to create their own classes which extend * the IRemoteRoomInfo and IRemoteUserInfo interfaces and serialize to JSON * cleanly. The serialized version of these classes is persisted in various * account data locations for future lookups. * @category Application services */ export class MatrixBridge { /** * Gets information about a remote user. * @param {Intent} userIntent The Matrix user intent to get information on. * @returns {Promise} Resolves to the remote user information. */ public async getRemoteUserInfo(userIntent: Intent): Promise { await userIntent.ensureRegistered(); return >userIntent.underlyingClient.getAccountData(REMOTE_USER_INFO_ACCOUNT_DATA_EVENT_TYPE); } /** * Gets information about a remote room. * @param {string} matrixRoomId The Matrix room ID to get information on. * @returns {Promise} Resolves to the remote room information. */ public async getRemoteRoomInfo(matrixRoomId: string): Promise { const bridgeBot = this.appservice.botIntent; await bridgeBot.ensureRegistered(); // We do not need to ensure the user is joined to the room because we can associate // room account data with any arbitrary room. return >bridgeBot.underlyingClient.getRoomAccountData(REMOTE_ROOM_INFO_ACCOUNT_DATA_EVENT_TYPE, matrixRoomId); } }