From 71f003dd66e3866f308f2128937ad994ca2724ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 12 Nov 2018 15:07:48 +0100 Subject: [PATCH] fix error in send.php --- web/schema.sql | 2 +- web/send.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/web/schema.sql b/web/schema.sql index acf2653..634d604 100644 --- a/web/schema.sql +++ b/web/schema.sql @@ -29,7 +29,7 @@ CREATE TABLE `messages` `content` VARCHAR(12288) NULL, `priority` INT(11) NOT NULL, - `fcn_message_id` VARCHAR(256) NOT NULL, + `fcn_message_id` VARCHAR(256) NULL, `usr_message_id` VARCHAR(256) NULL, PRIMARY KEY (`scn_message_id`) diff --git a/web/send.php b/web/send.php index 8f256fe..f698a51 100644 --- a/web/send.php +++ b/web/send.php @@ -112,13 +112,13 @@ try if (try_json($httpresult, ['success']) != 1) { reportError("FCM communication failed (success_1 <> true)\n\n".$httpresult); - api_return(403, json_encode(['success' => false, 'error' => 9902, 'errhighlight' => -1, 'message' => 'Communication with firebase service failed.'])); + api_return(500, json_encode(['success' => false, 'error' => 9902, 'errhighlight' => -1, 'message' => 'Communication with firebase service failed.'])); } } catch (Exception $e) { reportError("FCM communication failed", $e); - api_return(403, json_encode(['success' => false, 'error' => 9901, 'errhighlight' => -1, 'message' => 'Communication with firebase service failed.'."\n\n".'Exception: ' . $e->getMessage()])); + api_return(500, json_encode(['success' => false, 'error' => 9901, 'errhighlight' => -1, 'message' => 'Communication with firebase service failed.'."\n\n".'Exception: ' . $e->getMessage()])); } $stmt = $pdo->prepare('UPDATE users SET timestamp_accessed=NOW(), messages_sent=messages_sent+1, quota_today=:q, quota_day=NOW() WHERE user_id = :uid'); @@ -131,7 +131,7 @@ try 't' => $message, 'c' => $content, 'p' => $priority, - 'fmid' => try_json($httpresult, ['results', 'message_id']), + 'fmid' => try_json($httpresult, ['results', 0, 'message_id']), 'umid' => $usrmsgid, ]); @@ -150,4 +150,5 @@ try catch (Exception $mex) { reportError("Root try-catch triggered", $mex); + api_return(500, json_encode(['success' => false, 'error' => 9903, 'errhighlight' => -1, 'message' => 'PHP script threw exception.'."\n\n".'Exception: ' . $e->getMessage()])); }