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

@@ -15,7 +15,7 @@ class Torrent extends NexusModel
'size', 'added', 'type', 'numfiles', 'owner', 'nfo', 'sp_state', 'promotion_time_type',
'promotion_until', 'anonymous', 'url', 'pos_state', 'cache_stamp', 'picktype', 'picktime',
'last_reseed', 'pt_gen', 'technical_info', 'leechers', 'seeders', 'cover', 'last_action',
'times_completed', 'approval_status'
'times_completed', 'approval_status', 'banned', 'visible',
];
private static $globalPromotionState;
@@ -132,19 +132,19 @@ class Torrent extends NexusModel
const BONUS_REWARD_VALUES = [50, 100, 200, 500, 1000];
const APPROVAL_STATUS_NONE = 0;
const APPROVAL_STATUS_YES = 1;
const APPROVAL_STATUS_NO = 2;
const APPROVAL_STATUS_ALLOW = 1;
const APPROVAL_STATUS_DENY = 2;
public static array $approvalStatus = [
self::APPROVAL_STATUS_NONE => [
'text' => 'None',
'icon' => '<svg t="1655184824967" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="34118" width="16" height="16"><path d="M450.267 772.245l0 92.511 92.511 0 0-92.511L450.267 772.245zM689.448 452.28c13.538-24.367 20.311-50.991 20.311-79.875 0-49.938-19.261-92.516-57.765-127.713-38.517-35.197-90.114-52.8-154.797-52.8-61.077 0-110.191 16.4-147.342 49.188-37.16 32.798-59.497 80.032-67.014 141.703l83.486 9.927c7.218-46.025 22.41-79.875 45.576-101.533 23.166-21.665 52.047-32.494 86.647-32.494 35.802 0 66.038 11.957 90.711 35.874 24.667 23.92 37.01 51.675 37.01 83.266 0 17.451-4.222 33.55-12.642 48.284-8.425 14.747-26.698 34.526-54.83 59.346s-47.607 43.701-58.442 56.637c-14.741 17.754-25.424 35.354-32.037 52.797-9.028 23.172-13.537 50.701-13.537 82.584 0 5.418 0.146 13.539 0.45 24.374l78.069 0c0.599-32.495 2.855-55.966 6.772-70.4 3.903-14.44 9.926-27.229 18.047-38.363 8.127-11.123 25.425-28.43 51.901-51.895C649.43 506.288 675.908 476.656 689.448 452.28L689.448 452.28z" p-id="34119" fill="#e78d0f"></path></svg>',
],
self::APPROVAL_STATUS_YES => [
self::APPROVAL_STATUS_ALLOW => [
'text' => 'Allow',
'icon' => '<svg t="1655145688503" class="icon" viewBox="0 0 1413 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="16225" width="16" height="16"><path d="M1381.807797 107.47394L1274.675044 0.438669 465.281736 809.880718l-322.665524-322.714266L35.434718 594.152982l430.041982 430.041982 107.084012-107.035271-0.243705-0.292446z" fill="#1afa29" p-id="16226"></path></svg>',
],
self::APPROVAL_STATUS_NO => [
self::APPROVAL_STATUS_DENY => [
'text' => 'Deny',
'icon' => '<svg t="1655184952662" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="35029" width="16" height="16"><path d="M220.8 812.8l22.4 22.4 272-272 272 272 48-44.8-275.2-272 275.2-272-48-48-272 275.2-272-275.2-22.4 25.6-22.4 22.4 272 272-272 272z" fill="#d81e06" p-id="35030"></path></svg>',
],
@@ -401,4 +401,9 @@ class Torrent extends NexusModel
{
return $this->hasMany(Reward::class, 'torrentid');
}
public function operationLogs(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(TorrentOperationLog::class, 'torrent_id');
}
}

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");
}
}