approval change to single action

This commit is contained in:
xiaomlove
2022-06-15 15:43:33 +08:00
parent 4fbb279ed3
commit a8ca0ba831
14 changed files with 277 additions and 109 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Models;
use Nexus\Database\NexusDB;
class TorrentOperationLog extends NexusModel
{
protected $table = 'torrent_operation_logs';
@@ -10,12 +12,14 @@ class TorrentOperationLog extends NexusModel
protected $fillable = ['uid', 'torrent_id', 'action_type', 'comment'];
const ACTION_TYPE_BAN = 'ban';
const ACTION_TYPE_CANCEL_BAN = 'cancel_ban';
const ACTION_TYPE_APPROVAL_NONE = 'approval_none';
const ACTION_TYPE_APPROVAL_ALLOW = 'approval_allow';
const ACTION_TYPE_APPROVAL_DENY = 'approval_deny';
public static array $actionTypes = [
self::ACTION_TYPE_BAN => ['text' => 'Ban'],
self::ACTION_TYPE_CANCEL_BAN => ['text' => 'Cancel ban'],
self::ACTION_TYPE_APPROVAL_NONE => ['text' => 'Approval none'],
self::ACTION_TYPE_APPROVAL_ALLOW => ['text' => 'Approval allow'],
self::ACTION_TYPE_APPROVAL_DENY => ['text' => 'Approval deny'],
];
public function user()
@@ -32,7 +36,7 @@ class TorrentOperationLog extends NexusModel
public static function add(array $params)
{
$log = self::query()->create($params);
if (!in_array($params['action_type'], [self::ACTION_TYPE_CANCEL_BAN, self::ACTION_TYPE_BAN])) {
if (!in_array($params['action_type'], [self::ACTION_TYPE_APPROVAL_ALLOW, self::ACTION_TYPE_APPROVAL_DENY])) {
do_log("actionType: {$params['action_type']}, do not notify");
return $log;
}
@@ -60,5 +64,6 @@ class TorrentOperationLog extends NexusModel
'added' => now(),
];
Message::query()->insert($message);
NexusDB::cache_del("user_{$receiver->id}_inbox_count");
}
}