feat(followup-audio): separate uploader-only recording delete permission
This commit is contained in:
@@ -74,6 +74,19 @@ final class FollowupAudioAccess
|
||||
return $task;
|
||||
}
|
||||
|
||||
/** One fresh authorization rule for both delete capability and the locked delete transaction. */
|
||||
public static function deleteReason(array $task, int $actor): string
|
||||
{
|
||||
$info = self::actor($actor);
|
||||
if (!self::allowed($actor, $info, 'tcm.followupAudio/delete')) {
|
||||
return '缺少删除回访录音权限';
|
||||
}
|
||||
if ((int) $info['root'] !== 1 && (int) ($task['actor_id'] ?? 0) !== $actor) {
|
||||
return '仅上传者或超级管理员可删除录音';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function canDaily(int $actor, array $info): bool
|
||||
{
|
||||
$info = self::actor($actor);
|
||||
|
||||
@@ -273,9 +273,8 @@ final class FollowupAudioStore
|
||||
$task = self::lockTask($taskId);
|
||||
$info = FollowupAudioAccess::actor($actor);
|
||||
FollowupAudioAccess::task($taskId, $actor, $info);
|
||||
if ((int) $info['root'] !== 1 && (int) $task['actor_id'] !== $actor) {
|
||||
throw new DomainException('仅上传者或超级管理员可删除录音');
|
||||
}
|
||||
$permissionReason = FollowupAudioAccess::deleteReason($task, $actor);
|
||||
if ($permissionReason !== '') { throw new DomainException($permissionReason); }
|
||||
if ((int) $task['version'] !== $version) { throw new DomainException('FOLLOWUP_AUDIO_VERSION_CONFLICT'); }
|
||||
$reason = self::deleteBlockReason($task);
|
||||
if ($reason !== '') { throw new DomainException($reason); }
|
||||
|
||||
Reference in New Issue
Block a user