Abuse report

This commit is contained in:
LittleSheep 2024-12-08 01:01:20 +08:00
parent d4aaf61091
commit efddaf50f2
4 changed files with 118 additions and 6 deletions

View File

@ -390,7 +390,11 @@
"openInAlbum": "Open in album",
"postAbuseReport": "Report Post",
"postAbuseReportDescription": "Report posts that violate our user agreement and community guidelines to help us improve the content on Solar Network. Please describe how this post violates the relevant rules. Do not include any sensitive information. We will process your report within 24 hours.",
"postAbuseReportReason": "Reason",
"postAbuseReportSubmitted": "Report submitted, thank you for your contribution.",
"abuseReport": "Abuse Report",
"abuseReportDescription": "Report any resources that violate our user agreement and community guidelines to help us improve the content on Solar Network. Please describe the location of the resource (provide resource ID as best as possible) and how this violates the relevant rules. Do not include any sensitive information. We will process your report within 24 hours.",
"abuseReportActionDescription": "Report abuse usage behavior.",
"abuseReportResource": "Resource Location / ID",
"abuseReportReason": "Reason",
"abuseReportSubmitted": "Report submitted, thank you for your contribution.",
"submit": "Submit"
}

View File

@ -390,7 +390,11 @@
"openInAlbum": "在相册中打开",
"postAbuseReport": "检举帖子",
"postAbuseReportDescription": "检举不符合我们用户协议以及社区准则的帖子,来帮助我们更好的维护 Solar Network 上的内容。请在下面描述该帖子如何违反我么的相关规定。请勿填写任何敏感信息。我们将会在 24 小时内处理您的检举。",
"postAbuseReportReason": "检举原因",
"postAbuseReportSubmitted": "检举已提交,感谢你的贡献。",
"abuseReport": "检举",
"abuseReportDescription": "检举不符合我们用户协议以及社区准则的任何资源,来帮助我们更好的维护 Solar Network 上的内容。请在下面描述资源的位置(提供资源 ID 为佳)以及如何违反我么的相关规定。请勿填写任何敏感信息。我们将会在 24 小时内处理您的检举。",
"abuseReportActionDescription": "检举不合规行为。",
"abuseReportResource": "资源位置 / ID",
"abuseReportReason": "检举原因",
"abuseReportSubmitted": "检举已提交,感谢你的贡献。",
"submit": "提交"
}

View File

@ -5,6 +5,7 @@ import 'package:go_router/go_router.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/providers/userinfo.dart';
import 'package:surface/widgets/account/account_image.dart';
import 'package:surface/widgets/app_bar_leading.dart';
@ -104,6 +105,23 @@ class _AuthorizedAccountScreen extends StatelessWidget {
GoRouter.of(context).pushNamed('accountPublishers');
},
),
ListTile(
title: Text('abuseReport').tr(),
subtitle: Text('abuseReportActionDescription').tr(),
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
leading: const Icon(Symbols.flag),
trailing: const Icon(Symbols.chevron_right),
onTap: () {
showDialog(
context: context,
builder: (context) => _AbuseReportDialog(),
).then((value) {
if (value == true && context.mounted) {
context.showSnackbar('abuseReportSubmitted'.tr());
}
});
},
),
ListTile(
title: Text('accountLogout').tr(),
subtitle: Text('accountLogoutSubtitle').tr(),
@ -183,3 +201,89 @@ class _UnauthorizedAccountScreen extends StatelessWidget {
);
}
}
class _AbuseReportDialog extends StatefulWidget {
const _AbuseReportDialog({super.key});
@override
State<_AbuseReportDialog> createState() => _AbuseReportDialogState();
}
class _AbuseReportDialogState extends State<_AbuseReportDialog> {
bool _isBusy = false;
final _resourceController = TextEditingController();
final _reasonController = TextEditingController();
@override
dispose() {
_resourceController.dispose();
_reasonController.dispose();
super.dispose();
}
Future<void> _performAction() async {
setState(() => _isBusy = true);
try {
final sn = context.read<SnNetworkProvider>();
await sn.client.request(
'/cgi/id/reports/abuse',
data: {
'resource': _resourceController.text,
'reason': _reasonController.text,
},
);
if (!mounted) return;
Navigator.pop(context, true);
} catch (err) {
if (!mounted) return;
context.showErrorDialog(err);
} finally {
setState(() => _isBusy = false);
}
}
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text('abuseReport'.tr()),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('abuseReportDescription'.tr()),
const Gap(12),
TextField(
controller: _resourceController,
maxLength: null,
decoration: InputDecoration(
border: const UnderlineInputBorder(),
labelText: 'abuseReportResource'.tr(),
),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),
const Gap(4),
TextField(
controller: _reasonController,
maxLength: null,
decoration: InputDecoration(
border: const UnderlineInputBorder(),
labelText: 'abuseReportReason'.tr(),
),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),
],
),
actions: [
TextButton(
onPressed: _isBusy ? null : () => Navigator.pop(context),
child: Text('dialogDismiss').tr(),
),
TextButton(
onPressed: _isBusy ? null : _performAction,
child: Text('submit').tr(),
),
],
);
}
}

View File

@ -577,7 +577,7 @@ class _PostContentHeader extends StatelessWidget {
),
).then((value) {
if (value == true && context.mounted) {
context.showSnackbar('postAbuseReportSubmitted'.tr());
context.showSnackbar('abuseReportSubmitted'.tr());
}
});
},
@ -793,7 +793,7 @@ class _PostAbuseReportDialogState extends State<_PostAbuseReportDialog> {
maxLength: null,
decoration: InputDecoration(
border: const UnderlineInputBorder(),
labelText: 'postAbuseReportReason'.tr(),
labelText: 'abuseReportReason'.tr(),
),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),