Spamnoticer - addToSpamNoticer, guard against null files field

This commit is contained in:
towards-a-new-leftypol 2023-10-11 13:50:46 -04:00
parent e25908d87e
commit 18f63222f8
1 changed files with 22 additions and 20 deletions

View File

@ -150,29 +150,31 @@ function addToSpamNoticer($config, $post, $boardname, BanFormFieldsForSpamnotice
$attachments = array(); $attachments = array();
foreach ($post->files as $file) { if (isset($post->files) && is_array($post->files)) {
$key = $file->file_id . '.' . $file->extension; foreach ($post->files as $file) {
$file_info = $form_info->files_info[$key]; $key = $file->file_id . '.' . $file->extension;
$thumb_uri $file_info = $form_info->files_info[$key];
= $config['spam_noticer']['imageboard_root'] $thumb_uri
. $board['uri'] = $config['spam_noticer']['imageboard_root']
. '/' . $config['dir']['thumb'] . $board['uri']
. $file->file_id . '/' . $config['dir']['thumb']
. '.png'; . $file->file_id
. '.png';
$a = array( $a = array(
'filename' => $file->filename, 'filename' => $file->filename,
'mimetype' => $file->type ? $file->type : mime_content_type($file->tmp_name), 'mimetype' => $file->type ? $file->type : mime_content_type($file->tmp_name),
'md5_hash' => $file->hash, 'md5_hash' => $file->hash,
'thumbnail_url' => $thumb_uri, 'thumbnail_url' => $thumb_uri,
'is_spam' => $file_info->is_spam 'is_spam' => $file_info->is_spam
); );
if ($file_info->is_illegal) { if ($file_info->is_illegal) {
$a['is_illegal'] = true; $a['is_illegal'] = true;
}
$attachments[] = $a;
} }
$attachments[] = $a;
} }
$json_payload = [ $json_payload = [