api fixes

This commit is contained in:
Mike Schwörer 2018-09-26 23:13:50 +02:00
parent 7ea0572d79
commit 28ef5cb2f5
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
8 changed files with 12 additions and 11 deletions

View File

@ -21,8 +21,7 @@ import okhttp3.ResponseBody;
public class ServerCommunication
{
//public static final String BASE_URL = "https://simplecloudnotifier.blackforestbytes.com/";
public static final String BASE_URL = "http://10.0.2.2:1010/";
public static final String BASE_URL = "https://simplecloudnotifier.blackforestbytes.com/";
private static final OkHttpClient client = new OkHttpClient();

View File

@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -1,6 +1,6 @@
#Fri Sep 21 22:14:10 CEST 2018
#Wed Sep 26 22:10:14 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

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,