chore: send error to sentry on report message (#2302)
This commit is contained in:
parent
be5ea2b927
commit
d935f6a501
5 changed files with 97 additions and 57 deletions
|
|
@ -45,7 +45,6 @@ import 'package:fluffychat/pangea/events/event_wrappers/pangea_message_event.dar
|
|||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/representation_content_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/tokens_event_content_model.dart';
|
||||
import 'package:fluffychat/pangea/events/utils/report_message.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/instructions/instructions_enum.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/widgets/p_language_dialog.dart';
|
||||
|
|
@ -1119,9 +1118,6 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
|
||||
void reportEventAction() async {
|
||||
final event = selectedEvents.single;
|
||||
// #Pangea
|
||||
clearSelectedEvents();
|
||||
// Pangea#
|
||||
final score = await showModalActionPopup<int>(
|
||||
context: context,
|
||||
title: L10n.of(context).reportMessage,
|
||||
|
|
@ -1138,10 +1134,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
),
|
||||
AdaptiveModalAction(
|
||||
value: 0,
|
||||
// #Pangea
|
||||
// label: L10n.of(context).inoffensive,
|
||||
label: L10n.of(context).slightlyOffensive,
|
||||
// Pangea#
|
||||
label: L10n.of(context).inoffensive,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
@ -1152,50 +1145,18 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
hintText: L10n.of(context).reason,
|
||||
// #Pangea
|
||||
autoSubmit: true,
|
||||
// Pangea#
|
||||
);
|
||||
if (reason == null || reason.isEmpty) return;
|
||||
// #Pangea
|
||||
try {
|
||||
await reportMessage(
|
||||
context,
|
||||
roomId,
|
||||
reason,
|
||||
event.senderId,
|
||||
event.content['body'].toString(),
|
||||
);
|
||||
} catch (err) {
|
||||
ErrorHandler.logError(
|
||||
e: err,
|
||||
s: StackTrace.current,
|
||||
data: {
|
||||
'roomId': roomId,
|
||||
'reason': reason,
|
||||
'senderId': event.senderId,
|
||||
'content': event.content['body'].toString(),
|
||||
},
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
L10n.of(context).oopsSomethingWentWrong,
|
||||
final result = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.reportEvent(
|
||||
event.roomId!,
|
||||
event.eventId,
|
||||
reason: reason,
|
||||
score: score,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
// final result = await showFutureLoadingDialog(
|
||||
// context: context,
|
||||
// future: () => Matrix.of(context).client.reportEvent(
|
||||
// event.roomId!,
|
||||
// event.eventId,
|
||||
// reason: reason,
|
||||
// score: score,
|
||||
// ),
|
||||
// );
|
||||
// if (result.error != null) return;
|
||||
// Pangea#
|
||||
);
|
||||
if (result.error != null) return;
|
||||
setState(() {
|
||||
showEmojiPicker = false;
|
||||
selectedEvents.clear();
|
||||
|
|
|
|||
|
|
@ -3,8 +3,13 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_modal_action_popup.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
||||
Future<Room> getReportsDM(User teacher, Room space) async {
|
||||
|
|
@ -18,7 +23,72 @@ Future<Room> getReportsDM(User teacher, Room space) async {
|
|||
return space.client.getRoomById(roomId)!;
|
||||
}
|
||||
|
||||
Future<void> reportMessage(
|
||||
void reportEvent(
|
||||
Event event,
|
||||
ChatController controller,
|
||||
BuildContext context,
|
||||
) async {
|
||||
final score = await showModalActionPopup<int>(
|
||||
context: context,
|
||||
title: L10n.of(context).reportMessage,
|
||||
message: "Why do you want to report this message?",
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
actions: [
|
||||
AdaptiveModalAction(
|
||||
value: 1,
|
||||
label: L10n.of(context).offensive,
|
||||
),
|
||||
AdaptiveModalAction(
|
||||
value: 2,
|
||||
label: "Translation problem",
|
||||
),
|
||||
AdaptiveModalAction(
|
||||
value: 3,
|
||||
label: "Other",
|
||||
),
|
||||
],
|
||||
);
|
||||
if (score == null) return;
|
||||
|
||||
final reason = await showTextInputDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).whyDoYouWantToReportThis,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
hintText: L10n.of(context).reason,
|
||||
autoSubmit: true,
|
||||
);
|
||||
if (reason == null || reason.isEmpty) return;
|
||||
|
||||
if (score == 1) {
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async => reportOffensiveMessage(
|
||||
context,
|
||||
event.room.id,
|
||||
reason,
|
||||
event.senderId,
|
||||
event.content['body'].toString(),
|
||||
),
|
||||
);
|
||||
controller.clearSelectedEvents();
|
||||
return;
|
||||
}
|
||||
|
||||
ErrorHandler.logError(
|
||||
e: "User reported message",
|
||||
data: {
|
||||
"content": event.content['body'],
|
||||
"eventID": event.eventId,
|
||||
"roomID": event.room.id,
|
||||
"userID": event.senderId,
|
||||
"reason": reason,
|
||||
},
|
||||
);
|
||||
controller.clearSelectedEvents();
|
||||
}
|
||||
|
||||
Future<void> reportOffensiveMessage(
|
||||
BuildContext context,
|
||||
String roomId,
|
||||
String reason,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
|
|
@ -25,10 +31,6 @@ import 'package:fluffychat/pangea/toolbar/reading_assistance_input_row/morph_sel
|
|||
import 'package:fluffychat/pangea/toolbar/widgets/message_selection_positioner.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/reading_assistance_content.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
/// Controls data at the top level of the toolbar (mainly token / toolbar mode selection)
|
||||
class MessageSelectionOverlay extends StatefulWidget {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:matrix/matrix.dart';
|
|||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pangea/events/extensions/pangea_event_extension.dart';
|
||||
import 'package:fluffychat/pangea/events/utils/report_message.dart';
|
||||
|
||||
class OverlayHeader extends StatelessWidget {
|
||||
final ChatController controller;
|
||||
|
|
@ -80,7 +81,11 @@ class OverlayHeader extends StatelessWidget {
|
|||
IconButton(
|
||||
icon: const Icon(Icons.shield_outlined),
|
||||
tooltip: L10n.of(context).reportMessage,
|
||||
onPressed: controller.reportEventAction,
|
||||
onPressed: () => reportEvent(
|
||||
controller.selectedEvents.first,
|
||||
controller,
|
||||
context,
|
||||
),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
if (controller.selectedEvents.length == 1)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/morphs/get_grammar_copy.dart';
|
||||
import 'package:fluffychat/pangea/morphs/morph_features_enum.dart';
|
||||
|
|
@ -7,8 +11,6 @@ import 'package:fluffychat/pangea/toolbar/enums/message_mode_enum.dart';
|
|||
import 'package:fluffychat/pangea/toolbar/reading_assistance_input_row/morph_selection.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/practice_activity/word_zoom_activity_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
class MorphologicalListItem extends StatelessWidget {
|
||||
final MorphFeaturesEnum morphFeature;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue