inbox count cache etc.

This commit is contained in:
xiaomlove
2023-02-08 13:33:25 +08:00
parent e9c48e89b1
commit cf4a9207d8
14 changed files with 41 additions and 20 deletions
@@ -57,6 +57,7 @@ class BonusLogResource extends Resource
->label(__('bonus-log.fields.old_total_value'))
,
Tables\Columns\TextColumn::make('value')
->formatStateUsing(fn ($record) => $record->old_total_value > $record->new_total_value ? "-" . $record->value : "+" . $record->value)
->label(__('bonus-log.fields.value'))
,
Tables\Columns\TextColumn::make('new_total_value')
@@ -46,7 +46,7 @@ class UserMetaResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id'),
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('uid')
->searchable()
->label(__('label.username'))
@@ -63,6 +63,7 @@ class UserMetaResource extends Resource
->formatStateUsing(fn ($state) => format_datetime($state))
,
])
->defaultSort('id', 'desc')
->filters([
Tables\Filters\Filter::make('uid')
->form([
+4
View File
@@ -34,6 +34,8 @@ class BonusLogs extends NexusModel
const BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD = 17;
const BUSINESS_TYPE_GIFT_MEDAL = 18;
const BUSINESS_TYPE_ROLE_WORK_SALARY = 1000;
public static array $businessTypes = [
self::BUSINESS_TYPE_CANCEL_HIT_AND_RUN => ['text' => 'Cancel H&R'],
self::BUSINESS_TYPE_BUY_MEDAL => ['text' => 'Buy medal'],
@@ -53,6 +55,8 @@ class BonusLogs extends NexusModel
self::BUSINESS_TYPE_BUY_RAINBOW_ID => ['text' => 'Buy rainbow ID'],
self::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => ['text' => 'Buy change username card'],
self::BUSINESS_TYPE_GIFT_MEDAL => ['text' => 'Gift medal to someone'],
self::BUSINESS_TYPE_ROLE_WORK_SALARY => ['text' => 'Role work salary'],
];
public function getBusinessTypeTextAttribute()
+1 -2
View File
@@ -28,8 +28,7 @@ class Message extends NexusModel
public static function add(array $data): bool
{
NexusDB::cache_del('user_'.$data["receiver"].'_inbox_count');
NexusDB::cache_del('user_'.$data["receiver"].'_unread_message_count');
clear_inbox_count_cache($data["receiver"]);
return self::query()->insert($data);
}
+1 -1
View File
@@ -259,7 +259,7 @@ class ClaimRepository extends BaseRepository
}
//Send message
Message::query()->insert($message);
Message::add($message);
});
do_log("[DONE], cost time: " . (time() - $now->timestamp) . " seconds");
return true;
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-02-06');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-02-08');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
+2 -2
View File
@@ -5776,7 +5776,7 @@ function list_require_search_box_id()
return $maps[nexus()->getScript()] ?? [];
}
function can_access_torrent($torrent)
function can_access_torrent($torrent, $uid)
{
global $specialcatmode;
if (get_setting('main.spsct') != 'yes') {
@@ -5797,7 +5797,7 @@ function can_access_torrent($torrent)
if ($searchBoxId != $specialcatmode) {
return true;
}
if (get_user_class() >= get_setting('authority.view_special_torrent')) {
if (user_can('view_special_torrent', false, $uid)) {
return true;
}
return false;
+10
View File
@@ -1053,6 +1053,16 @@ function clear_icon_cache()
\Nexus\Database\NexusDB::cache_del("category_icon_content");
}
function clear_inbox_count_cache($uid)
{
do_log("clear_inbox_count_cache");
foreach (\Illuminate\Support\Arr::wrap($uid) as $id) {
\Nexus\Database\NexusDB::cache_del('user_'.$id.'_inbox_count');
\Nexus\Database\NexusDB::cache_del('user_'.$id.'_unread_message_count');
}
}
function user_can($permission, $fail = false, $uid = 0): bool
{
$log = "permission: $permission, fail: $fail, user: $uid";
+1 -1
View File
@@ -33,7 +33,7 @@ if (!$row) {
stderr($lang_details['std_error'], $lang_details['std_no_torrent_id']);
} elseif (
($row['banned'] == 'yes' && !user_can('seebanned') && $row['owner'] != $CURUSER['id'])
|| (!can_access_torrent($row) && $row['owner'] != $CURUSER['id'])
|| (!can_access_torrent($row, $CURUSER['id']) && $row['owner'] != $CURUSER['id'])
) {
permissiondenied();
} else {
+1 -1
View File
@@ -110,7 +110,7 @@ if (filesize($fn) == 0) {
$approvalNotAllowed = $row['approval_status'] != \App\Models\Torrent::APPROVAL_STATUS_ALLOW && get_setting('torrent.approval_status_none_visible') == 'no';
$allowOwnerDownload = $row['owner'] == $CURUSER['id'];
$canSeedBanned = user_can('seebanned');
$canAccessTorrent = can_access_torrent($row);
$canAccessTorrent = can_access_torrent($row, $CURUSER['id']);
if ((($row['banned'] == 'yes' || ($approvalNotAllowed && !$allowOwnerDownload)) && !$canSeedBanned) || !$canAccessTorrent) {
do_log("[DENY_DOWNLOAD], user: {$CURUSER['id']}, approvalNotAllowed: $approvalNotAllowed, allowOwnerDownload: $allowOwnerDownload, canSeedBanned: $canSeedBanned, canAccessTorrent: $canAccessTorrent", 'error');
denyDownload();
+11 -11
View File
@@ -968,7 +968,7 @@ else stdhead($lang_torrents['head_special']);
print("<table width=\"97%\" class=\"main\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td class=\"embedded\">");
displayHotAndClassic();
$searchBoxRightTdStyle = 'padding: 1px;padding-left: 10px;white-space: nowrap';
if ($allsec != 1 || $enablespecial != 'yes'){ //do not print searchbox if showing bookmarked torrents from all sections;
?>
<form method="get" name="searchbox" action="?">
@@ -1085,56 +1085,56 @@ if ($allsec != 1 || $enablespecial != 'yes'){ //do not print searchbox if showin
</tr>
<?php }?>
<tr>
<td class="bottom" style="padding: 1px;padding-left: 10px">
<td class="bottom" style="<?php echo $searchBoxRightTdStyle ?>">
<font class="medium"><?php echo $lang_torrents['size_range'] ?></font>
</td>
</tr>
<tr>
<td class="bottom" style="padding: 1px;padding-left: 10px">
<td class="bottom" style="<?php echo $searchBoxRightTdStyle ?>">
<input type="number" min="1" name="size_begin" style="width: <?php echo $filterInputWidth?>px" value="<?php echo htmlspecialchars($_GET['size_begin'] ?? '') ?>"/> ~ <input type="number" min="1" name="size_end" style="width: <?php echo $filterInputWidth?>px" value="<?php echo htmlspecialchars($_GET['size_end'] ?? '') ?>"/>
</td>
</tr>
<tr>
<td class="bottom" style="padding: 1px;padding-left: 10px">
<td class="bottom" style="<?php echo $searchBoxRightTdStyle ?>">
<font class="medium"><?php echo $lang_torrents['seeders_range'] ?></font>
</td>
</tr>
<tr>
<td class="bottom" style="padding: 1px;padding-left: 10px">
<td class="bottom" style="<?php echo $searchBoxRightTdStyle ?>">
<input type="number" min="1" name="seeders_begin" style="width: <?php echo $filterInputWidth?>px" value="<?php echo htmlspecialchars($_GET['seeders_begin'] ?? '') ?>"/> ~ <input type="number" min="1" name="seeders_end" style="width: <?php echo $filterInputWidth?>px" value="<?php echo htmlspecialchars($_GET['seeders_end'] ?? '') ?>"/>
</td>
</tr>
<tr>
<td class="bottom" style="padding: 1px;padding-left: 10px">
<td class="bottom" style="<?php echo $searchBoxRightTdStyle ?>">
<font class="medium"><?php echo $lang_torrents['leechers_range'] ?></font>
</td>
</tr>
<tr>
<td class="bottom" style="padding: 1px;padding-left: 10px">
<td class="bottom" style="<?php echo $searchBoxRightTdStyle ?>">
<input type="number" min="1" name="leechers_begin" style="width: <?php echo $filterInputWidth?>px" value="<?php echo htmlspecialchars($_GET['leechers_begin'] ?? '') ?>"/> ~ <input type="number" min="1" name="leechers_end" style="width: <?php echo $filterInputWidth?>px" value="<?php echo htmlspecialchars($_GET['leechers_end'] ?? '') ?>"/>
</td>
</tr>
<tr>
<td class="bottom" style="padding: 1px;padding-left: 10px">
<td class="bottom" style="<?php echo $searchBoxRightTdStyle ?>">
<font class="medium"><?php echo $lang_torrents['times_completed_range'] ?></font>
</td>
</tr>
<tr>
<td class="bottom" style="padding: 1px;padding-left: 10px">
<td class="bottom" style="<?php echo $searchBoxRightTdStyle ?>">
<input type="number" min="1" name="times_completed_begin" style="width: <?php echo $filterInputWidth?>px" value="<?php echo htmlspecialchars($_GET['times_completed_begin'] ?? '') ?>"/> ~ <input type="number" min="1" name="times_completed_end" style="width: <?php echo $filterInputWidth?>px" value="<?php echo htmlspecialchars($_GET['times_completed_end'] ?? '') ?>"/>
</td>
</tr>
<tr>
<td class="bottom" style="padding: 1px;padding-left: 10px">
<td class="bottom" style="<?php echo $searchBoxRightTdStyle ?>">
<font class="medium"><?php echo $lang_torrents['added_range'] ?></font>
</td>
</tr>
<tr>
<td class="bottom" style="padding: 1px;padding-left: 10px">
<td class="bottom" style="<?php echo $searchBoxRightTdStyle ?>">
<?php echo sprintf(
'%s ~ %s',
datetimepicker_input('added_begin', htmlspecialchars($_GET['added_begin'] ?? ''), '', ['require_files' => true, 'format' => 'Y-m-d', 'style' => 'width: '.$filterInputWidth.'px']),
+2
View File
@@ -20,6 +20,8 @@ return [
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_RAINBOW_ID => 'Buy rainbow ID',
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => 'Buy change username card',
\App\Models\BonusLogs::BUSINESS_TYPE_GIFT_MEDAL => 'Gift medal',
\App\Models\BonusLogs::BUSINESS_TYPE_ROLE_WORK_SALARY => 'Role work salary',
],
'fields' => [
'business_type' => 'Business type',
+2
View File
@@ -20,6 +20,8 @@ return [
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_RAINBOW_ID => '购买彩虹 ID',
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => '购买改名卡',
\App\Models\BonusLogs::BUSINESS_TYPE_GIFT_MEDAL => '赠送勋章',
\App\Models\BonusLogs::BUSINESS_TYPE_ROLE_WORK_SALARY => '工作组工资',
],
'fields' => [
'business_type' => '业务类型',
+2
View File
@@ -20,6 +20,8 @@ return [
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_RAINBOW_ID => '購買彩虹 ID',
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => '購買改名卡',
\App\Models\BonusLogs::BUSINESS_TYPE_GIFT_MEDAL => '贈送勛章',
\App\Models\BonusLogs::BUSINESS_TYPE_ROLE_WORK_SALARY => '工作組工資',
],
'fields' => [
'business_type' => '業務類型',