// SPDX-FileCopyrightText: 2019-Present Christian Kußowski // SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat // // SPDX-License-Identifier: AGPL-3.0-or-later import 'package:matrix/matrix.dart'; import 'package:tatchat/config/app_config.dart'; /// State event type that marks the room category (canal/mural) on a room /// level. Unlike the personal tags (per-account data), this marker is shared /// by all room members which makes the categorization consistent across /// different accounts. const String roomTypeStateEvent = 'tatuchat.room_type'; extension RoomTypeExtension on Room { String? get roomType => getState(roomTypeStateEvent)?.content.tryGet('type'); bool get isCanal => tags.keys.contains(AppConfig.canalTag) || roomType == 'canal'; bool get isMural => tags.keys.contains(AppConfig.muralTag) || roomType == 'mural'; /// Whether the account left (or was banned from) this room. Such rooms must /// not be shown in the chat list, even if a stale local copy with an old /// "join" membership reappears after a restart. bool get isLeftOrBanned => {Membership.leave, Membership.ban}.contains(membership); Future setRoomType(String type) => client.setRoomStateWithKey(id, roomTypeStateEvent, '', {'type': type}); }