fix: harden school imports and add optional feedback diagnostics

This commit is contained in:
Codex
2026-10-15 10:37:32 +08:00
parent 674df1ceb3
commit 7299f4d8b6
25 changed files with 722 additions and 42 deletions
@@ -102,6 +102,7 @@ class FeedbackSubmission {
this.contact,
this.school,
this.attachments = const [],
this.diagnosticLog,
});
factory FeedbackSubmission.problem({
@@ -110,18 +111,26 @@ class FeedbackSubmission {
String? contact,
List<FeedbackAttachment> attachments = const [],
FeedbackLimits limits = FeedbackLimits.defaults,
Uint8List? diagnosticLog,
}) {
final text = message.trim();
if (text.isEmpty) throw const FeedbackException('请填写问题或建议');
if (text.length > 5000) throw const FeedbackException('问题或建议不能超过 5000 个字符');
_validateContact(contact);
validateAttachments(attachments, limits);
if (diagnosticLog != null &&
(diagnosticLog.isEmpty || diagnosticLog.length > 256 * 1024)) {
throw const FeedbackException('日志附件不能超过256 KB');
}
return FeedbackSubmission._(
id: id,
kind: FeedbackKind.problem,
message: text,
contact: _optional(contact),
attachments: List.unmodifiable(attachments),
diagnosticLog: diagnosticLog == null
? null
: Uint8List.fromList(diagnosticLog).asUnmodifiableView(),
);
}
@@ -151,6 +160,7 @@ class FeedbackSubmission {
final String? contact;
final String? school;
final List<FeedbackAttachment> attachments;
final Uint8List? diagnosticLog;
static String newId() {
final random = Random.secure();