moved to json api

This commit is contained in:
Synox 2018-06-14 18:57:50 +02:00
parent 44db2432dc
commit 1257f83e57
3 changed files with 12 additions and 7 deletions

View File

@ -28,6 +28,11 @@ class RestRouter extends Router {
&& $this->action === 'random_username') { && $this->action === 'random_username') {
return new RedirectToRandomAddressController($this->config['domains']); return new RedirectToRandomAddressController($this->config['domains']);
} elseif ($this->action === "has_new_messages"
&& isset($this->get_vars['email_ids'])
&& isset($this->get_vars['address'])) {
return new HasNewMessagesController($this->get_vars['email_ids'], $this->get_vars['address'], $this->config['domains'], $this->config['blocked_usernames']);
} elseif ($this->method === "GET" } elseif ($this->method === "GET"
&& $this->action === 'emails' && $this->action === 'emails'
&& isset($this->get_vars['address'])) { && isset($this->get_vars['address'])) {
@ -76,6 +81,12 @@ class JsonViewHandler implements ViewHandler {
function invalid_input($config_domains) { function invalid_input($config_domains) {
$this->error(400, 'Bad Request'); $this->error(400, 'Bad Request');
} }
function new_mail_counter_json($counter) {
header('Content-Type: application/json');
print json_encode($counter);
}
} }

View File

@ -37,11 +37,6 @@ class Router {
&& isset($this->get_vars['address'])) { && isset($this->get_vars['address'])) {
return new DeleteEmailController($this->get_vars['email_id'], $this->get_vars['address'], $this->config['domains'], $this->config['blocked_usernames']); return new DeleteEmailController($this->get_vars['email_id'], $this->get_vars['address'], $this->config['domains'], $this->config['blocked_usernames']);
} elseif ($this->action === "has_new_messages"
&& isset($this->get_vars['email_ids'])
&& isset($this->get_vars['address'])) {
return new HasNewMessagesController($this->get_vars['email_ids'], $this->get_vars['address'], $this->config['domains'], $this->config['blocked_usernames']);
} elseif ($this->action === 'random') { } elseif ($this->action === 'random') {
return new RedirectToRandomAddressController($this->config['domains']); return new RedirectToRandomAddressController($this->config['domains']);

View File

@ -53,7 +53,6 @@ class ServerRenderViewHandler implements ViewHandler {
} }
function new_mail_counter_json($counter) { function new_mail_counter_json($counter) {
header('Content-Type: application/json'); $this->error("not implemented for ServerRenderViewHandler, see json-api");
print json_encode($counter);
} }
} }