feat(upload): pending lifecycle for upload-on-select images

Mark front-end uploads (comment/ticket/report) as pending, return the
attachment id, discard own pending uploads on remove via
DELETE /upload/pending/{id}, claim referenced URLs on successful submit,
and purge unclaimed uploads older than 24h with an hourly cron.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Fable 5 committed 2026-10-27 21:54:48 +08:00
1 parent a308f96837
commit ac3ed9c956
9 files changed
+247 -2

No files matched your search

+3
View File
@@ -612,9 +612,12 @@ class UserController extends ControllerBase {
wp_delete_attachment((int) $attachment_id, true);
return $this->error(__('上传失败', 'aksrt'), 500);
}
// 选图即上传:提交成功前处于待认领状态,× 移除或超时未提交会被清理。
\AKSRT\Attachment\PendingUploads::mark((int) $attachment_id);
return $this->success([
'message' => __('图片上传成功', 'aksrt'),
'data' => [
'id' => (int) $attachment_id,
'url' => $url,
],
]);
@@ -450,6 +450,8 @@ trait UserControllerReportOperations {
);
if ($report_id > 0) {
// 举证图片以 URL 拼入举报内容,提交成功即认领。
\AKSRT\Attachment\PendingUploads::claim_text($reason, $reporter_id);
return $this->success([
'message' => __('举报已提交,我们会尽快处理', 'aksrt'),
'data' => ['report_id' => $report_id],