From 28ef5cb2f5bf3778754142e96b74d41141b3ad9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Wed, 26 Sep 2018 23:13:50 +0200 Subject: [PATCH] api fixes --- .../simplecloudnotifier/model/ServerCommunication.java | 3 +-- android/build.gradle | 2 +- android/gradle/wrapper/gradle-wrapper.properties | 4 ++-- web/index_sent.php | 2 +- web/info.php | 2 +- web/js/logic.js | 1 + web/schema.sql | 6 +++--- web/send.php | 3 ++- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java index 5b691b1..e31f859 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java @@ -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(); diff --git a/android/build.gradle b/android/build.gradle index af5e896..de549d3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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 diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 6a71c3b..7465871 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/web/index_sent.php b/web/index_sent.php index 8a9795b..3dc6b50 100644 --- a/web/index_sent.php +++ b/web/index_sent.php @@ -21,7 +21,7 @@

Message sent

Message succesfully sent
- / remaining

+ / remaining

diff --git a/web/info.php b/web/info.php index 1c9bc8b..a1b5980 100644 --- a/web/info.php +++ b/web/info.php @@ -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']; //---------------------- diff --git a/web/js/logic.js b/web/js/logic.js index 1c5135b..c23fcab 100644 --- a/web/js/logic.js +++ b/web/js/logic.js @@ -55,6 +55,7 @@ function send() '?ok=' + 1 + '&message_count=' + resp.messagecount + '"a=' + resp.quota + + '"a_remain=' + (resp.quota_max-resp.quota) + '"a_max=' + resp.quota_max + '&preset_user_id=' + uid.value + '&preset_user_key=' + key.value; diff --git a/web/schema.sql b/web/schema.sql index 5a8f95b..2e177fb 100644 --- a/web/schema.sql +++ b/web/schema.sql @@ -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`) ); diff --git a/web/send.php b/web/send.php index 7aa0090..a7218f7 100644 --- a/web/send.php +++ b/web/send.php @@ -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,