added priority to messages
This commit is contained in:
@@ -27,7 +27,7 @@ body
|
||||
min-width: 300px;
|
||||
max-width: 900px;
|
||||
position: relative;
|
||||
min-height: 445px;
|
||||
min-height: 485px;
|
||||
}
|
||||
|
||||
#mainpnl input,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>Simple Cloud Notifications</title>
|
||||
<link rel="stylesheet" href="/css/toastify.min.css"/>
|
||||
<link rel="stylesheet" href="/css/mini-default.min.css">
|
||||
<link rel="stylesheet" href="/css/mini-default.min.css"> <!-- https://minicss.org/ -->
|
||||
<!--<link rel="stylesheet" href="/css/mini-nord.min.css">-->
|
||||
<!--<link rel="stylesheet" href="/css/mini-dark.min.css">-->
|
||||
<link rel="stylesheet" href="/css/style.css">
|
||||
@@ -28,6 +28,17 @@
|
||||
<div class="col-sm-12 col-md"><input placeholder="Key" id="ukey" class="doc" <?php echo (isset($_GET['preset_user_key']) ? (' value="'.$_GET['preset_user_key'].'" '):(''));?> type="text" maxlength="64"></div>
|
||||
</div>
|
||||
|
||||
<div class="row responsive-label">
|
||||
<div class="col-sm-12 col-md-3"><label for="prio" class="doc">Priority</label></div>
|
||||
<div class="col-sm-12 col-md">
|
||||
<select id="prio" class="doc" type="text" style="width:100%;">
|
||||
<option value="0" <?php echo (( isset($_GET['preset_priority'])&&$_GET['preset_priority']==='0') ? 'selected':'');?>>Low</option>
|
||||
<option value="1" <?php echo ((!isset($_GET['preset_priority'])||$_GET['preset_priority']==='1') ? 'selected':'');?>>Normal</option>
|
||||
<option value="2" <?php echo (( isset($_GET['preset_priority'])&&$_GET['preset_priority']==='2') ? 'selected':'');?>>High</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row responsive-label">
|
||||
<div class="col-sm-12 col-md-3"><label for="msg" class="doc">Message Title</label></div>
|
||||
<div class="col-sm-12 col-md"><input placeholder="Message" id="msg" class="doc" <?php echo (isset($_GET['preset_title']) ? (' value="'.$_GET['preset_title'].'" '):(''));?> type="text" maxlength="80"></div>
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
<pre>curl \
|
||||
--data "user_id={userid}" \
|
||||
--data "user_key={userkey}" \
|
||||
--data "priority={0|1|2}" \
|
||||
--data "title={message_title}" \
|
||||
--data "content={message_content}" \
|
||||
https://scn.blackforestbytes.com/send.php</pre>
|
||||
<p>The <code>content</code> parameter is optional, you can also send message with only a title</p>
|
||||
<p>The <code>content</code> and <code>priority</code> parameters are optional, you can also send message with only a title and the default priority</p>
|
||||
<pre>curl \
|
||||
--data "user_id={userid}" \
|
||||
--data "user_key={userkey}" \
|
||||
|
||||
@@ -19,7 +19,7 @@ $stmt = $pdo->prepare('SELECT user_id, user_key, quota_today, quota_max, quota_d
|
||||
$stmt->execute(['uid' => $user_id]);
|
||||
|
||||
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($datas)<=0) die(json_encode(['success' => false, 'errid'=>201, 'message' => 'No User found']));
|
||||
if (count($datas)<=0) die(json_encode(['success' => false, 'errid'=>201, 'message' => 'User not found']));
|
||||
$data = $datas[0];
|
||||
|
||||
if ($data === null) die(json_encode(['success' => false, 'errid'=>202, 'message' => 'User not found']));
|
||||
|
||||
@@ -12,17 +12,20 @@ function send()
|
||||
let key = document.getElementById("ukey");
|
||||
let msg = document.getElementById("msg");
|
||||
let txt = document.getElementById("txt");
|
||||
let pio = document.getElementById("prio");
|
||||
|
||||
uid.classList.remove('input-invalid');
|
||||
key.classList.remove('input-invalid');
|
||||
msg.classList.remove('input-invalid');
|
||||
txt.classList.remove('input-invalid');
|
||||
pio.classList.remove('input-invalid');
|
||||
|
||||
let data = new FormData();
|
||||
data.append('user_id', uid.value);
|
||||
data.append('user_key', key.value);
|
||||
data.append('title', msg.value);
|
||||
data.append('content', txt.value);
|
||||
data.append('priority', pio.value);
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/send.php', true);
|
||||
@@ -40,6 +43,7 @@ function send()
|
||||
if (resp.errhighlight === 102) key.classList.add('input-invalid');
|
||||
if (resp.errhighlight === 103) msg.classList.add('input-invalid');
|
||||
if (resp.errhighlight === 104) txt.classList.add('input-invalid');
|
||||
if (resp.errhighlight === 105) pio.classList.add('input-invalid');
|
||||
|
||||
Toastify({
|
||||
text: resp.message,
|
||||
|
||||
@@ -17,11 +17,13 @@ if (!isset($INPUT['title'])) die(json_encode(['success' => false, 'errhighlig
|
||||
$user_id = $INPUT['user_id'];
|
||||
$user_key = $INPUT['user_key'];
|
||||
$message = $INPUT['title'];
|
||||
$content = $INPUT['content'];
|
||||
if ($content === null || $content === false) $content = '';
|
||||
$content = isset($INPUT['content']) ? $INPUT['content'] : '';
|
||||
$priority = isset($INPUT['priority']) ? $INPUT['priority'] : '1';
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
if ($priority !== '0' && $priority !== '1' && $priority !== '2') die(json_encode(['success' => false, 'errhighlight' => 105, 'message' => 'Invalid priority']));
|
||||
|
||||
if (strlen(trim($message)) == 0) die(json_encode(['success' => false, 'errhighlight' => 103, 'message' => 'No title specified']));
|
||||
if (strlen($message) > 120) die(json_encode(['success' => false, 'errhighlight' => 103, 'message' => 'Title too long (120 characters)']));
|
||||
if (strlen($content) > 10000) die(json_encode(['success' => false, 'errhighlight' => 104, 'message' => 'Content too long (10000 characters)']));
|
||||
@@ -34,7 +36,7 @@ $stmt = $pdo->prepare('SELECT user_id, user_key, fcm_token, messages_sent, quota
|
||||
$stmt->execute(['uid' => $user_id]);
|
||||
|
||||
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($datas)<=0) die(json_encode(['success' => false, 'errhighlight' => 101, 'message' => 'No User found']));
|
||||
if (count($datas)<=0) die(json_encode(['success' => false, 'errhighlight' => 101, 'message' => 'User not found']));
|
||||
$data = $datas[0];
|
||||
|
||||
if ($data === null) die(json_encode(['success' => false, 'errhighlight' => 101, 'message' => 'User not found']));
|
||||
@@ -64,6 +66,7 @@ $payload = json_encode(
|
||||
[
|
||||
'title' => $message,
|
||||
'body' => $content,
|
||||
'priority' => $priority,
|
||||
'timestamp' => time(),
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -20,7 +20,7 @@ $stmt = $pdo->prepare('SELECT user_id, user_key, quota_today, quota_max, quota_d
|
||||
$stmt->execute(['uid' => $user_id]);
|
||||
|
||||
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($datas)<=0) die(json_encode(['success' => false, 'message' => 'No User found']));
|
||||
if (count($datas)<=0) die(json_encode(['success' => false, 'message' => 'User not found']));
|
||||
$data = $datas[0];
|
||||
|
||||
if ($data === null) die(json_encode(['success' => false, 'message' => 'User not found']));
|
||||
|
||||
Reference in New Issue
Block a user