api fixes

This commit is contained in:
2018-09-26 23:13:50 +02:00
parent 7ea0572d79
commit 28ef5cb2f5
8 changed files with 12 additions and 11 deletions

View File

@@ -21,7 +21,7 @@
<div class="section">
<h3 class="doc">Message sent</h3>
<p class="doc">Message succesfully sent<br>
<?php echo isset($_GET['quota'])?$_GET['quota']:'ERR';?>/<?php echo isset($_GET['quota_max'])?$_GET['quota_max']:'ERR';?> remaining</p>
<?php echo isset($_GET['quota_remain'])?$_GET['quota_remain']:'ERR';?>/<?php echo isset($_GET['quota_max'])?$_GET['quota_max']:'ERR';?> remaining</p>
</div>
</a>

View File

@@ -9,7 +9,7 @@ if (!isset($INPUT['user_id'])) die(json_encode(['success' => false, 'errid'=>10
if (!isset($INPUT['user_key'])) die(json_encode(['success' => false, 'errid'=>102, 'message' => 'Missing parameter [[user_key]]']));
$user_id = $INPUT['user_id'];
$user_key = $INPUT['token'];
$user_key = $INPUT['user_key'];
//----------------------

View File

@@ -55,6 +55,7 @@ function send()
'?ok=' + 1 +
'&message_count=' + resp.messagecount +
'&quota=' + resp.quota +
'&quota_remain=' + (resp.quota_max-resp.quota) +
'&quota_max=' + resp.quota_max +
'&preset_user_id=' + uid.value +
'&preset_user_key=' + key.value;

View File

@@ -1,7 +1,7 @@
CREATE TABLE `users`
(
`id` INT(11) NOT NULL AUTO_INCREMENT,
`auth_token` VARCHAR(64) NOT NULL,
`user_id` INT(11) NOT NULL AUTO_INCREMENT,
`user_key` VARCHAR(64) NOT NULL,
`fcm_token` VARCHAR(256) NULL DEFAULT NULL,
`messages_sent` INT(11) NOT NULL DEFAULT '0',
`timestamp_created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -11,5 +11,5 @@ CREATE TABLE `users`
`quota_day` DATE NULL DEFAULT NULL,
`quota_max` INT(11) NOT NULL DEFAULT '100',
PRIMARY KEY (`id`)
PRIMARY KEY (`user_id`)
);

View File

@@ -44,7 +44,7 @@ if ($data['user_key'] !== $user_key) die(json_encode(['success' => false, 'errhi
$fcm = $data['fcm_token'];
$new_quota = $data['quota_today'] + 1;
if ($data['quota_day'] === null || $data['quota_day'] !== date("Y-m-d")) $new_quota=0;
if ($data['quota_day'] === null || $data['quota_day'] !== date("Y-m-d")) $new_quota=1;
if ($new_quota > $data['quota_max']) die(json_encode(['success' => false, 'errhighlight' => -1, 'message' => 'Daily quota reached ('.$data['quota_max'].')']));
//------------------------------------------------------------------
@@ -54,6 +54,7 @@ $payload = json_encode(
[
'to' => $fcm,
//'dry_run' => true,
'android' => [ 'priority' => 'high' ],
'notification' =>
[
'title' => $message,