plugin sticky promotion do not change torrent original field

This commit is contained in:
xiaomlove
2022-06-10 01:25:13 +08:00
parent d95979b579
commit 35f78b4b77
7 changed files with 35 additions and 14 deletions

View File

@@ -39,7 +39,7 @@ use JeroenG\Explorer\Infrastructure\Scout\ElasticEngine;
use League\Flysystem\StorageAttributes;
use Nexus\Database\NexusDB;
use Nexus\Imdb\Imdb;
use NexusPlugin\PostLike\PostLike;
use NexusPlugin\PostLike\PostLikeRepository;
use NexusPlugin\StickyPromotion\Models\StickyPromotion;
use NexusPlugin\StickyPromotion\Models\StickyPromotionParticipator;
use Rhilip\Bencode\Bencode;
@@ -77,8 +77,9 @@ class Test extends Command
*/
public function handle()
{
$r = StickyPromotionParticipator::query()->first();
dd($r->created_at);
$torrent = Torrent::query()->first();
$torrent->name = Carbon::now()->toDateTimeString();
$torrent->update(['seeders' => 100]);
}

View File

@@ -16,12 +16,14 @@ class BonusLogs extends NexusModel
const BUSINESS_TYPE_BUY_MEDAL = 2;
const BUSINESS_TYPE_BUY_ATTENDANCE_CARD = 3;
const BUSINESS_TYPE_STICKY_PROMOTION = 4;
const BUSINESS_TYPE_POST_REWARD = 5;
public static array $businessTypes = [
self::BUSINESS_TYPE_CANCEL_HIT_AND_RUN => ['text' => 'Cancel H&R'],
self::BUSINESS_TYPE_BUY_MEDAL => ['text' => 'Buy medal'],
self::BUSINESS_TYPE_BUY_ATTENDANCE_CARD => ['text' => 'Buy attendance card'],
self::BUSINESS_TYPE_STICKY_PROMOTION => ['text' => 'Buy torrent sticky promotion'],
self::BUSINESS_TYPE_POST_REWARD => ['text' => 'Reward post'],
];
public static function getBonusForCancelHitAndRun()

View File

@@ -14,7 +14,8 @@ class Torrent extends NexusModel
'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec',
'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_reseed', 'pt_gen', 'technical_info', 'leechers', 'seeders', 'cover', 'last_action',
'times_completed'
];
private static $globalPromotionState;
@@ -157,10 +158,15 @@ class Torrent extends NexusModel
}
$spState = $this->sp_state;
$global = self::getGlobalPromotionState();
$log = sprintf('torrent: %s sp_state: %s, global sp state: %s', $this->id, $spState, $global);
$log = sprintf('torrent: %s original sp_state: %s, original global_sp_state: %s', $this->id, $spState, $global);
if ($this->__sticky_promotion) {
//Cover original sp_state
$spState = $this->__sticky_promotion['promotion_type'];
$log .= "[SP_STATE_CHANGE] to __sticky_promotion: $spState]";
}
if ($this->__ignore_global_sp_state) {
$log .= "[IGNORE_GLOBAL_SP_STATE]";
$global = self::PROMOTION_NORMAL;
$log .= "[IGNORE_GLOBAL_SP_STATE], reset to: $global";
}
if ($global != self::PROMOTION_NORMAL) {
$spState = $global;

View File

@@ -17,11 +17,11 @@ require $rootpath . 'include/eloquent.php';
ini_set('date.timezone', nexus_config('nexus.timezone'));
$Cache = new class_cache_redis(); //Load the caching class
$Cache->setLanguageFolderArray(get_langfolder_list());
require $rootpath . 'include/config.php';
$script = nexus()->getScript();
if (!in_array($script, ['announce'])) {
if (!in_array($script, ['announce', 'scrape'])) {
require $rootpath . get_langfile_path("functions.php");
}
require $rootpath . 'include/config.php';
if (!isRunningInConsole() && !in_array($script, ['announce', 'scrape', 'torrentrss', 'download'])) {
checkGuestVisit();
}

View File

@@ -6,6 +6,8 @@ class Hook
{
private static array $callbacks = [];
private bool $isDoingAction = false;
public function addFilter($name, $function, $priority, $argc)
{
$id = $this->buildUniqueId($function);
@@ -43,12 +45,18 @@ class Hook
reset(self::$callbacks[$name]);
do_log("name: $name, argc: " . (func_num_args() - 1));
do {
foreach ((array)current(self::$callbacks[$name]) as $callback) {
foreach ((array)current(self::$callbacks[$name]) as $id => $callback) {
$args[1] = $value;
// do_log("name: $name, id: $id, before, params: " . json_encode(array_slice($args, 1, $callback['argc'])));
$value = call_user_func_array($callback['function'], array_slice($args, 1, $callback['argc']));
if ($this->isDoingAction) {
$value = $args[1];
}
// do_log("name: $name, id: $id, after, value: " . var_export($value, true));
}
}
while (next(self::$callbacks[$name]) !== false);
$this->isDoingAction = false;
return $value;
}
@@ -59,6 +67,7 @@ class Hook
public function doAction($name, ...$args)
{
$this->isDoingAction = true;
$this->applyFilter(...func_get_args());
}

View File

@@ -36,6 +36,8 @@ class Plugin
$className = str_replace('ServiceProvider', 'Repository', $provider);
if (class_exists($className)) {
call_user_func([new $className, 'boot']);
} else {
do_log("Plugin: $className not exists.", "error");
}
}
}

View File

@@ -703,18 +703,19 @@ if ($action == "viewtopic")
print("<table class=\"main\" width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n");
$body = "<div id=\"pid".$postid."body\">".format_comment($arr["body"]);
$body = "<div id=\"pid".$postid."body\">";
$bodyContent = format_comment($arr["body"]);
if ($highlight){
$body = highlight($highlight,$body);
$bodyContent = highlight($highlight,$body);
}
if (is_valid_id($arr['editedby']))
{
$lastedittime = gettime($arr['editdate'],true,false);
$body .= "<br /><p><font class=\"small\">".$lang_forums['text_last_edited_by'].get_username($arr['editedby']).$lang_forums['text_last_edit_at'].$lastedittime."</font></p>\n";
$bodyContent .= "<br /><p><font class=\"small\">".$lang_forums['text_last_edited_by'].get_username($arr['editedby']).$lang_forums['text_last_edit_at'].$lastedittime."</font></p>\n";
}
$body .= "</div>";
$bodyContent = apply_filter('post_body', $bodyContent, $arr, $allPosts);
$body .= $bodyContent . "</div>";
if ($signature)
$body .= "<p style='vertical-align:bottom'><br />____________________<br />" . format_comment($signature,false,false,false,true,500,true,false, 1,200) . "</p>";