Merge pull request #99 from PietroCarrara/api-messages

Add warning and ban messages to the API
This commit is contained in:
towards-a-new-leftypol 2021-01-04 21:11:18 -05:00 committed by GitHub
commit 9033f6dc99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -113,7 +113,7 @@ class Api {
if (isset($config['poster_ids']) && $config['poster_ids']) $apiPost['id'] = poster_id($post->ip, $post->thread, $board['uri']); if (isset($config['poster_ids']) && $config['poster_ids']) $apiPost['id'] = poster_id($post->ip, $post->thread, $board['uri']);
if ($threadsPage) return $apiPost; if ($threadsPage) return $apiPost;
// Handle country field // Handle special fields
if (isset($post->body_nomarkup) && ($this->config['country_flags'] || $this->config['user_flag'])) { if (isset($post->body_nomarkup) && ($this->config['country_flags'] || $this->config['user_flag'])) {
$modifiers = extract_modifiers($post->body_nomarkup); $modifiers = extract_modifiers($post->body_nomarkup);
if (isset($modifiers['flag']) && isset($modifiers['flag alt']) && preg_match('/^[1-9a-z_-]{2,}$/', $modifiers['flag'])) { if (isset($modifiers['flag']) && isset($modifiers['flag alt']) && preg_match('/^[1-9a-z_-]{2,}$/', $modifiers['flag'])) {
@ -123,6 +123,12 @@ class Api {
$apiPost['country_name'] = $modifiers['flag alt']; $apiPost['country_name'] = $modifiers['flag alt'];
} }
} }
if (isset($modifiers['warning message'])) {
$apiPost['warning_msg'] = $modifiers['warning message'];
}
if (isset($modifiers['ban message'])) {
$apiPost['ban_msg'] = $modifiers['ban message'];
}
} }
if ($config['slugify'] && !$post->thread) { if ($config['slugify'] && !$post->thread) {