feat: allow editing community post content

This commit is contained in:
hajimi
2026-08-02 20:11:15 +08:00
parent 115a859dd3
commit 71f3b1c6d7
7 changed files with 125 additions and 2 deletions
@@ -50,6 +50,27 @@ class CommunityPostLogic extends BaseLogic
}
}
public static function editContent(array $params): bool
{
$post = CommunityPost::findOrEmpty($params['id']);
if ($post->isEmpty()) {
self::setError('帖子不存在');
return false;
}
try {
$post->content = (string) $params['content'];
$post->save();
if ((int) $post->status === 1) {
KbSyncService::enqueue('post', 'post', (int) $post->id, 'upsert', 30);
}
return true;
} catch (\Exception $e) {
self::setError($e->getMessage());
return false;
}
}
public static function setTop(array $params): bool
{
try {