Update column references to be compatible with Trace 2024-02-05

This commit is contained in:
Alex Thomassen 2024-02-10 17:22:40 +00:00
parent cb8925463f
commit 845cb82a95
Signed by: Alex
GPG Key ID: 10BD786B5F6FF5DE

View File

@ -18,12 +18,12 @@ class ModeratorAction extends Model
/**
* Return a human-readable version of the action
*
* @param bool $asHtml If true then the returned string will be outputted as raw HTML. Defaults to false.
* @return string
*/
public function formatted($asHtml = false) : string
{
$cmd = $this->action;
$discriminator = $this->discriminator;
/**
* Only bans, unbans will be implicitly handled by default format.
@ -46,12 +46,14 @@ public function formatted($asHtml = false) : string
return sprintf('/%s %s %s %s', $cmd, $this->targetName($asHtml), $message, $this->message_id);
}
/**
* Timeouts
*/
if ($cmd === 'slow') {
$duration = $this->duration;
return sprintf('/%s %s', $cmd, $duration);
}
if ($cmd === 'timeout') {
$duration = $this->timeout_duration;
$reason = $this->timeout_reason;
$duration = $this->duration;
$reason = $this->reason;
if ($asHtml) {
$reason = htmlspecialchars($reason);
}
@ -59,8 +61,14 @@ public function formatted($asHtml = false) : string
return sprintf('/%s %s %s %s', $cmd, $this->targetName($asHtml), $duration, $reason ?? '');
}
if ($discriminator === 'TermAction') {
$text = $this->text;
if (str_contains($cmd, 'unban_request')) {
$message = $this->moderator_message ?? '';
return sprintf('/%s %s %s', $cmd, $this->targetName($asHtml), $message);
}
// Added / blocked terms via Automod
if (str_contains($cmd, '_term')) {
$text = $this->term_text;
if ($asHtml) {
$text = htmlspecialchars($text);
}
@ -74,7 +82,7 @@ public function formatted($asHtml = false) : string
/**
* Get the target name of the action, if any
*
* @param bool $linkToViewerPage Returns an HTML link to the viewer page
* @param bool $linkToViewerPage Returns an HTML link to the viewer page instead of just the plaintext name. Defaults to false.
* @return string
*/
public function targetName($linkToViewerPage = false) : ?string
@ -92,17 +100,6 @@ public function targetName($linkToViewerPage = false) : ?string
return sprintf($format, route('viewer', ['viewer' => $id]), $name);
}
if (!empty($this->targeted_moderator_action_target_name)) {
$name = $this->targeted_moderator_action_target_name;
if (!$linkToViewerPage) {
return $name;
}
$id = $this->target_id ?? $name;
return sprintf($format, route('viewer', ['viewer' => $id]), $name);
}
return '';
}