From 52f5623058b2cbd0d6ddf799746f24a8924b633b Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Thu, 16 Jun 2022 02:04:32 +0800 Subject: [PATCH] fix torrent update notify staff --- app/Repositories/TorrentRepository.php | 21 +++------------------ public/takeedit.php | 10 ++++++++++ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/Repositories/TorrentRepository.php b/app/Repositories/TorrentRepository.php index f10edc6a..54924e0d 100644 --- a/app/Repositories/TorrentRepository.php +++ b/app/Repositories/TorrentRepository.php @@ -477,7 +477,7 @@ class TorrentRepository extends BaseRepository //No change return $params; } - $torrentUpdate = $torrentOperationLog = $staffMsg = []; + $torrentUpdate = $torrentOperationLog = []; $torrentUpdate['approval_status'] = $params['approval_status']; if ($params['approval_status'] == Torrent::APPROVAL_STATUS_ALLOW) { $torrentUpdate['banned'] = 'no'; @@ -506,18 +506,8 @@ class TorrentRepository extends BaseRepository $torrentOperationLog['comment'] = $params['comment'] ?? ''; } - if ($torrent->banned == 'yes' && $torrent->owner == $user->id) { - $torrentUrl = sprintf('%s/details.php?id=%s', getSchemeAndHttpHost(), $torrent->id); - $staffMsg = [ - 'sender' => $user->id, - 'subject' => nexus_trans('torrent.owner_update_torrent_subject', ['detail_url' => $torrentUrl, 'torrent_name' => $_POST['name']]), - 'msg' => nexus_trans('torrent.owner_update_torrent_msg', ['detail_url' => $torrentUrl, 'torrent_name' => $_POST['name']]), - 'added' => now(), - ]; - } - - NexusDB::transaction(function () use ($torrent, $torrentOperationLog, $torrentUpdate, $staffMsg) { - $log = ""; + NexusDB::transaction(function () use ($torrent, $torrentOperationLog, $torrentUpdate) { + $log = "torrent: " . $torrent->id; if (!empty($torrentUpdate)) { $log .= "[UPDATE_TORRENT]: " . nexus_json_encode($torrentUpdate); $torrent->update($torrentUpdate); @@ -526,11 +516,6 @@ class TorrentRepository extends BaseRepository $log .= "[ADD_TORRENT_OPERATION_LOG]: " . nexus_json_encode($torrentOperationLog); TorrentOperationLog::add($torrentOperationLog); } - if (!empty($staffMsg)) { - $log .= "[INSERT_STAFF_MESSAGE]: " . nexus_json_encode($staffMsg); - StaffMessage::query()->insert($staffMsg); - NexusDB::cache_del('staff_new_message_count'); - } do_log($log); }); diff --git a/public/takeedit.php b/public/takeedit.php index e05b4f86..8a36e32a 100644 --- a/public/takeedit.php +++ b/public/takeedit.php @@ -251,6 +251,16 @@ else $searchRep = new \App\Repositories\SearchRepository(); $searchRep->updateTorrent($id); +if ($row['banned'] == 'yes' && $row['owner'] == $CURUSER['id']) { + $torrentUrl = sprintf('%s/details.php?id=%s', getSchemeAndHttpHost(), $row['id']); + \App\Models\StaffMessage::query()->insert([ + 'sender' => $CURUSER['id'], + 'subject' => nexus_trans('torrent.owner_update_torrent_subject', ['detail_url' => $torrentUrl, 'torrent_name' => $_POST['name']]), + 'msg' => nexus_trans('torrent.owner_update_torrent_msg', ['detail_url' => $torrentUrl, 'torrent_name' => $_POST['name']]), + 'added' => now(), + ]); +} + $returl = "details.php?id=$id&edited=1"; if (isset($_POST["returnto"])) $returl = $_POST["returnto"];