mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-02 17:29:34 +01:00
feat: Implement reporting of events
This commit is contained in:
parent
3f08890ce9
commit
d553685dea
@ -1332,6 +1332,54 @@
|
|||||||
"username": {}
|
"username": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"howOffensiveIsThisContent": "How offensive is this content?",
|
||||||
|
"@howOffensiveIsThisContent": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"extremeOffensive": "Extreme offensive",
|
||||||
|
"@extremeOffensive": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"offensive": "Offensive",
|
||||||
|
"@offensive": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"inoffensive": "Inoffensive",
|
||||||
|
"@inoffensive": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"whyDoYouWantToReportThis": "Why do you want to report this?",
|
||||||
|
"@whyDoYouWantToReportThis": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"reason": "Reason",
|
||||||
|
"@reason": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"contentHasBeenReported": "The content has been reported to the server admins",
|
||||||
|
"@contentHasBeenReported": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"redactMessage": "Redact message",
|
||||||
|
"@redactMessage": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"reportMessage": "Report message",
|
||||||
|
"@reportMessage": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
|
||||||
"searchForAChat": "Search for a chat",
|
"searchForAChat": "Search for a chat",
|
||||||
"@searchForAChat": {
|
"@searchForAChat": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
@ -305,6 +305,47 @@ class _ChatState extends State<Chat> {
|
|||||||
setState(() => selectedEvents.clear());
|
setState(() => selectedEvents.clear());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reportEventAction(BuildContext context) async {
|
||||||
|
final event = selectedEvents.single;
|
||||||
|
final score = await showConfirmationDialog<int>(
|
||||||
|
context: context,
|
||||||
|
title: L10n.of(context).howOffensiveIsThisContent,
|
||||||
|
actions: [
|
||||||
|
AlertDialogAction(
|
||||||
|
key: 100,
|
||||||
|
label: L10n.of(context).extremeOffensive,
|
||||||
|
),
|
||||||
|
AlertDialogAction(
|
||||||
|
key: 50,
|
||||||
|
label: L10n.of(context).offensive,
|
||||||
|
),
|
||||||
|
AlertDialogAction(
|
||||||
|
key: 0,
|
||||||
|
label: L10n.of(context).inoffensive,
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
if (score == null) return;
|
||||||
|
final reason = await showTextInputDialog(
|
||||||
|
context: context,
|
||||||
|
title: L10n.of(context).whyDoYouWantToReportThis,
|
||||||
|
textFields: [DialogTextField(hintText: L10n.of(context).reason)]);
|
||||||
|
if (reason == null || reason.single.isEmpty) return;
|
||||||
|
final result = await showFutureLoadingDialog(
|
||||||
|
context: context,
|
||||||
|
future: () => Matrix.of(context).client.reportEvent(
|
||||||
|
event.roomId,
|
||||||
|
event.eventId,
|
||||||
|
reason.single,
|
||||||
|
score,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (result.error != null) return;
|
||||||
|
setState(() => selectedEvents.clear());
|
||||||
|
await FlushbarHelper.createSuccess(
|
||||||
|
message: L10n.of(context).contentHasBeenReported)
|
||||||
|
.show(context);
|
||||||
|
}
|
||||||
|
|
||||||
void redactEventsAction(BuildContext context) async {
|
void redactEventsAction(BuildContext context) async {
|
||||||
var confirmed = await showOkCancelAlertDialog(
|
var confirmed = await showOkCancelAlertDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@ -567,14 +608,42 @@ class _ChatState extends State<Chat> {
|
|||||||
inputFocus.requestFocus();
|
inputFocus.requestFocus();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
IconButton(
|
PopupMenuButton(
|
||||||
icon: Icon(Icons.content_copy_outlined),
|
onSelected: (selected) {
|
||||||
onPressed: () => copyEventsAction(context),
|
switch (selected) {
|
||||||
|
case 'copy':
|
||||||
|
copyEventsAction(context);
|
||||||
|
break;
|
||||||
|
case 'redact':
|
||||||
|
redactEventsAction(context);
|
||||||
|
break;
|
||||||
|
case 'report':
|
||||||
|
reportEventAction(context);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
itemBuilder: (_) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(L10n.of(context).copy),
|
||||||
|
value: 'copy',
|
||||||
),
|
),
|
||||||
if (canRedactSelectedEvents)
|
if (canRedactSelectedEvents)
|
||||||
IconButton(
|
PopupMenuItem(
|
||||||
icon: Icon(Icons.delete_outlined),
|
child: Text(
|
||||||
onPressed: () => redactEventsAction(context),
|
L10n.of(context).redactMessage,
|
||||||
|
style: TextStyle(color: Colors.orange),
|
||||||
|
),
|
||||||
|
value: 'redact',
|
||||||
|
),
|
||||||
|
if (selectedEvents.length == 1)
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(
|
||||||
|
L10n.of(context).reportMessage,
|
||||||
|
style: TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
value: 'report',
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
: <Widget>[
|
: <Widget>[
|
||||||
|
Loading…
Reference in New Issue
Block a user