Add permissions checks for spam_noticer ui
This commit is contained in:
parent
37ac429d60
commit
3fa80c6e39
|
@ -48,7 +48,7 @@ function proxy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
global $mod;
|
global $mod, $config;
|
||||||
|
|
||||||
check_login(true);
|
check_login(true);
|
||||||
|
|
||||||
|
@ -61,7 +61,12 @@ function main() {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#echo json_encode($mod);
|
if (!hasPermission($config['mod']['spam_noticer'])) {
|
||||||
|
header("HTTP/1.1 403 Forbidden");
|
||||||
|
echo "You do not have sufficient privileges.";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
proxy();
|
proxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1623,6 +1623,8 @@
|
||||||
// Allow searching posts (can be used with board configuration file to disallow searching through a
|
// Allow searching posts (can be used with board configuration file to disallow searching through a
|
||||||
// certain board)
|
// certain board)
|
||||||
$config['mod']['search_posts'] = JANITOR;
|
$config['mod']['search_posts'] = JANITOR;
|
||||||
|
// Access SpamNoticer UI
|
||||||
|
$config['mod']['spam_noticer'] = MOD;
|
||||||
// Read the moderator noticeboard
|
// Read the moderator noticeboard
|
||||||
$config['mod']['noticeboard'] = JANITOR;
|
$config['mod']['noticeboard'] = JANITOR;
|
||||||
// Post to the moderator noticeboard
|
// Post to the moderator noticeboard
|
||||||
|
|
|
@ -107,6 +107,7 @@ $config['thread_subject_in_title'] = true;
|
||||||
$config['spam']['enabled'] = true;
|
$config['spam']['enabled'] = true;
|
||||||
$config['spam_noticer']['enabled'] = true;
|
$config['spam_noticer']['enabled'] = true;
|
||||||
$config['spam_noticer']['base_url'] = 'http://localhost:8300';
|
$config['spam_noticer']['base_url'] = 'http://localhost:8300';
|
||||||
|
$config['spam_noticer']['ui_url'] = 'https://dev-spamnoticer.leftychan.net/static/index.html';
|
||||||
$config['spam_noticer']['website_name'] = "leftychan_dev";
|
$config['spam_noticer']['website_name'] = "leftychan_dev";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -192,10 +192,14 @@ function checkWithSpamNoticer($config, $post, $boardname) {
|
||||||
|
|
||||||
$status_code = $response->getStatusCode();
|
$status_code = $response->getStatusCode();
|
||||||
|
|
||||||
|
print_err("spamnoticer status code: " . $status_code);
|
||||||
|
print_err("spamnoticer response body: " . $response->getBody());
|
||||||
|
|
||||||
if ($status_code >= 200 && $status_code < 300) {
|
if ($status_code >= 200 && $status_code < 300) {
|
||||||
$result->succeeded = true;
|
$result->succeeded = true;
|
||||||
$result->result_json = json_decode($response->getBody(), true);
|
$result->result_json = json_decode($response->getBody(), true);
|
||||||
$result->noticed = $result->result_json['noticed'] == true;
|
$result->noticed = $result->result_json['noticed'] == true;
|
||||||
|
|
||||||
if ($result->noticed) {
|
if ($result->noticed) {
|
||||||
$result->reason = (string) $response->getBody();
|
$result->reason = (string) $response->getBody();
|
||||||
}
|
}
|
||||||
|
@ -205,8 +209,6 @@ function checkWithSpamNoticer($config, $post, $boardname) {
|
||||||
|
|
||||||
$result->client = $client;
|
$result->client = $client;
|
||||||
|
|
||||||
print_err($response->getBody());
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
} catch (GuzzleHttp\Exception\ConnectException $e) {
|
} catch (GuzzleHttp\Exception\ConnectException $e) {
|
||||||
$result->reason = $e->getMessage();
|
$result->reason = $e->getMessage();
|
||||||
|
|
|
@ -75,9 +75,9 @@
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if config.spam_noticer.enabled %}
|
{% if (config.spam_noticer.enabled) and (mod|hasPermission(config.mod.spam_noticer)) %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ config.spam_noticer.base_url }}/static/index.html">
|
<a href="{{ config.spam_noticer.ui_url }}">
|
||||||
SpamNoticer
|
SpamNoticer
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Reference in New Issue