增加Hook: IsekaiAIReviewResult

master
落雨楓 3 years ago
parent e0be90e676
commit 6e2dbea245

@ -24,15 +24,15 @@ class AIReviewJob extends Job {
$robotUser = User::newFromId($wgAIReviewRobotUID); $robotUser = User::newFromId($wgAIReviewRobotUID);
$modid = $this->params['mod_id']; $mod_id = $this->params['mod_id'];
$modUser = $dbr->selectField('moderation', 'mod_user', ['mod_id' => $modid], __METHOD__); $modUser = $dbr->selectField('moderation', 'mod_user', ['mod_id' => $mod_id], __METHOD__);
$services = MediaWikiServices::getInstance(); $services = MediaWikiServices::getInstance();
$entryFactory = $services->getService('Moderation.EntryFactory'); $entryFactory = $services->getService('Moderation.EntryFactory');
$consequenceManager = $services->getService('Moderation.ConsequenceManager'); $consequenceManager = $services->getService('Moderation.ConsequenceManager');
/** @var ModerationViewableEntry $contentEntry */ /** @var ModerationViewableEntry $contentEntry */
$contentEntry = $entryFactory->findViewableEntry($modid); $contentEntry = $entryFactory->findViewableEntry($mod_id);
$title = $contentEntry->getTitle(); $title = $contentEntry->getTitle();
$context = RequestContext::getMain(); $context = RequestContext::getMain();
@ -50,7 +50,9 @@ class AIReviewJob extends Job {
'isekai-aireview', 'isekai-aireview',
'Reject revision on: ' . $title->getText() . ', reason: ' . Utils::getReadableReason($result['reason']) 'Reject revision on: ' . $title->getText() . ', reason: ' . Utils::getReadableReason($result['reason'])
); );
Utils::addAIReviewLog('reject', $robotUser, $modUser, $title, $modid, $result['reason']); Utils::addAIReviewLog('reject', $robotUser, $modUser, $title, $mod_id, $result['reason']);
$services->getHookContainer()->run("IsekaiAIReviewResult",
[ false, $title, $mod_id, $modUser, $result['reason'] ]);
return true; return true;
} }
} }
@ -60,9 +62,11 @@ class AIReviewJob extends Job {
'isekai-aireview', 'isekai-aireview',
'Approve revision on: ' . $title->getText() 'Approve revision on: ' . $title->getText()
); );
Utils::addAIReviewLog('approve', $robotUser, $modUser, $title, $modid); $approveEntry = $entryFactory->findApprovableEntry($mod_id);
$approveEntry = $entryFactory->findApprovableEntry($modid);
$approveEntry->approve($robotUser); $approveEntry->approve($robotUser);
Utils::addAIReviewLog('approve', $robotUser, $modUser, $title, $mod_id);
$services->getHookContainer()->run("IsekaiAIReviewResult",
[ true, $title, $mod_id, $modUser, '' ]);
return true; return true;
} }
} }

@ -5,9 +5,10 @@ use JobQueueGroup;
use Title; use Title;
class Hooks { class Hooks {
public static function onModerationPending($fields, $modid){ public static function onModerationPending($fields, $mod_id){
//加入审核队列 //加入审核队列
$job = new AIReviewJob(Title::newFromText($fields['mod_title']), ['mod_id' => $modid]); $title = Title::newFromText($fields['mod_title']);
$job = new AIReviewJob($title, ['mod_id' => $mod_id]);
JobQueueGroup::singleton()->push($job); JobQueueGroup::singleton()->push($job);
} }
} }
Loading…
Cancel
Save