From 14ed8febf6d2234143e3ff8b9d5eef36904dbd37 Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Mon, 5 Jan 2026 15:10:54 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20Disable=20ability=20to=20send=20video/?= =?UTF-8?q?files=20(slash=20anything=20else=20that=20the=20bot=20doesn?= =?UTF-8?q?=E2=80=99t=20know=20what=20to=20do=20with)=20in=20bot=20chats?= =?UTF-8?q?=20(#5065)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pangea/bot/utils/bot_room_extension.dart | 12 ++++ .../chat/widgets/pangea_chat_input_row.dart | 69 ++++++++++--------- .../utils/bot_client_extension.dart | 11 +-- .../extensions/pangea_room_extension.dart | 2 - .../room_information_extension.dart | 4 -- 5 files changed, 50 insertions(+), 48 deletions(-) diff --git a/lib/pangea/bot/utils/bot_room_extension.dart b/lib/pangea/bot/utils/bot_room_extension.dart index eef48a933..b658235ed 100644 --- a/lib/pangea/bot/utils/bot_room_extension.dart +++ b/lib/pangea/bot/utils/bot_room_extension.dart @@ -1,9 +1,21 @@ import 'package:matrix/matrix.dart'; +import 'package:fluffychat/pangea/bot/utils/bot_name.dart'; +import 'package:fluffychat/pangea/chat_settings/constants/bot_mode.dart'; import 'package:fluffychat/pangea/chat_settings/models/bot_options_model.dart'; import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart'; extension BotRoomExtension on Room { + bool get isBotDM { + if (isDirectChat && directChatMatrixID == BotName.byEnvironment) { + return true; + } + if (botOptions?.mode == BotMode.directChat) { + return true; + } + return false; + } + BotOptionsModel? get botOptions { if (isSpace) return null; final stateEvent = getState(PangeaEventTypes.botOptions); diff --git a/lib/pangea/chat/widgets/pangea_chat_input_row.dart b/lib/pangea/chat/widgets/pangea_chat_input_row.dart index b7a28b40f..fdff8a030 100644 --- a/lib/pangea/chat/widgets/pangea_chat_input_row.dart +++ b/lib/pangea/chat/widgets/pangea_chat_input_row.dart @@ -7,6 +7,7 @@ import 'package:fluffychat/config/themes.dart'; import 'package:fluffychat/l10n/l10n.dart'; import 'package:fluffychat/pages/chat/chat.dart'; import 'package:fluffychat/pages/chat/input_bar.dart'; +import 'package:fluffychat/pangea/bot/utils/bot_room_extension.dart'; import 'package:fluffychat/pangea/choreographer/choreo_constants.dart'; import 'package:fluffychat/pangea/choreographer/choreographer_send_button.dart'; import 'package:fluffychat/pangea/choreographer/choreographer_state_extension.dart'; @@ -57,6 +58,7 @@ class PangeaChatInputRow extends StatelessWidget { ValueListenableBuilder( valueListenable: controller.sendController, builder: (context, text, __) { + final isBotDM = controller.room.isBotDM; return AnimatedContainer( duration: FluffyThemes.animationDuration, curve: FluffyThemes.animationCurve, @@ -74,18 +76,19 @@ class PangeaChatInputRow extends StatelessWidget { onSelected: controller.onAddPopupMenuButtonSelected, itemBuilder: (BuildContext context) => >[ - PopupMenuItem( - value: 'file', - child: ListTile( - leading: const CircleAvatar( - backgroundColor: Colors.green, - foregroundColor: Colors.white, - child: Icon(Icons.attachment_outlined), + if (!isBotDM) + PopupMenuItem( + value: 'file', + child: ListTile( + leading: const CircleAvatar( + backgroundColor: Colors.green, + foregroundColor: Colors.white, + child: Icon(Icons.attachment_outlined), + ), + title: Text(L10n.of(context).sendFile), + contentPadding: const EdgeInsets.all(0), ), - title: Text(L10n.of(context).sendFile), - contentPadding: const EdgeInsets.all(0), ), - ), PopupMenuItem( value: 'image', child: ListTile( @@ -111,32 +114,34 @@ class PangeaChatInputRow extends StatelessWidget { contentPadding: const EdgeInsets.all(0), ), ), - if (PlatformInfos.isMobile) - PopupMenuItem( - value: 'camera-video', - child: ListTile( - leading: const CircleAvatar( - backgroundColor: Colors.red, - foregroundColor: Colors.white, - child: Icon(Icons.videocam_outlined), + if (!isBotDM) + if (PlatformInfos.isMobile) + PopupMenuItem( + value: 'camera-video', + child: ListTile( + leading: const CircleAvatar( + backgroundColor: Colors.red, + foregroundColor: Colors.white, + child: Icon(Icons.videocam_outlined), + ), + title: Text(L10n.of(context).openVideoCamera), + contentPadding: const EdgeInsets.all(0), ), - title: Text(L10n.of(context).openVideoCamera), - contentPadding: const EdgeInsets.all(0), ), - ), - if (PlatformInfos.isMobile) - PopupMenuItem( - value: 'location', - child: ListTile( - leading: const CircleAvatar( - backgroundColor: Colors.brown, - foregroundColor: Colors.white, - child: Icon(Icons.gps_fixed_outlined), + if (!isBotDM) + if (PlatformInfos.isMobile) + PopupMenuItem( + value: 'location', + child: ListTile( + leading: const CircleAvatar( + backgroundColor: Colors.brown, + foregroundColor: Colors.white, + child: Icon(Icons.gps_fixed_outlined), + ), + title: Text(L10n.of(context).shareLocation), + contentPadding: const EdgeInsets.all(0), ), - title: Text(L10n.of(context).shareLocation), - contentPadding: const EdgeInsets.all(0), ), - ), ], ), ); diff --git a/lib/pangea/chat_settings/utils/bot_client_extension.dart b/lib/pangea/chat_settings/utils/bot_client_extension.dart index e4094c827..266cdf8e1 100644 --- a/lib/pangea/chat_settings/utils/bot_client_extension.dart +++ b/lib/pangea/chat_settings/utils/bot_client_extension.dart @@ -10,16 +10,7 @@ import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart'; import 'package:fluffychat/widgets/matrix.dart'; extension BotClientExtension on Client { - bool get hasBotDM => rooms.any((room) { - if (room.isDirectChat && - room.directChatMatrixID == BotName.byEnvironment) { - return true; - } - if (room.botOptions?.mode == BotMode.directChat) { - return true; - } - return false; - }); + bool get hasBotDM => rooms.any((r) => r.isBotDM); Room? get botDM => rooms.firstWhereOrNull( (room) { diff --git a/lib/pangea/extensions/pangea_room_extension.dart b/lib/pangea/extensions/pangea_room_extension.dart index 7fe4e8e1e..85c869ba3 100644 --- a/lib/pangea/extensions/pangea_room_extension.dart +++ b/lib/pangea/extensions/pangea_room_extension.dart @@ -17,9 +17,7 @@ import 'package:fluffychat/pangea/activity_sessions/activity_room_extension.dart import 'package:fluffychat/pangea/analytics_misc/constructs_event.dart'; import 'package:fluffychat/pangea/analytics_misc/constructs_model.dart'; import 'package:fluffychat/pangea/bot/utils/bot_name.dart'; -import 'package:fluffychat/pangea/bot/utils/bot_room_extension.dart'; import 'package:fluffychat/pangea/chat/constants/default_power_level.dart'; -import 'package:fluffychat/pangea/chat_settings/constants/bot_mode.dart'; import 'package:fluffychat/pangea/chat_settings/constants/pangea_room_types.dart'; import 'package:fluffychat/pangea/choreographer/igc/igc_request_model.dart'; import 'package:fluffychat/pangea/common/constants/model_keys.dart'; diff --git a/lib/pangea/extensions/room_information_extension.dart b/lib/pangea/extensions/room_information_extension.dart index e0ba4f362..cb2fbbb86 100644 --- a/lib/pangea/extensions/room_information_extension.dart +++ b/lib/pangea/extensions/room_information_extension.dart @@ -15,10 +15,6 @@ extension RoomInformationRoomExtension on Room { ); } - Future get isBotDM async { - return botOptions?.mode == BotMode.directChat && await botIsInRoom; - } - String? get roomType => getState(EventTypes.RoomCreate)?.content.tryGet('type');