queryRoomInformation method

Future<Result<RoomInformation, MUCError>> queryRoomInformation(
  1. JID roomJID
)

Queries the information of a Multi-User Chat room.

Retrieves the information about the specified MUC room by performing a disco info query. Returns a Result with the RoomInformation on success or an appropriate MUCError on failure.

Implementation

Future<Result<RoomInformation, MUCError>> queryRoomInformation(
  JID roomJID,
) async {
  final result = await getAttributes()
      .getManagerById<DiscoManager>(discoManager)!
      .discoInfoQuery(roomJID);
  if (result.isType<StanzaError>()) {
    return Result(InvalidStanzaFormat());
  }
  try {
    final roomInformation = RoomInformation.fromDiscoInfo(
      discoInfo: result.get<DiscoInfo>(),
    );
    return Result(roomInformation);
  } catch (e) {
    logger.warning('Invalid disco information: $e');
    return Result(InvalidDiscoInfoResponse());
  }
}