fixed notifying non-existent user

This commit is contained in:
Tony Yang 2019-07-03 09:11:28 +08:00
parent 60501428ce
commit 45b778484a
Signed by: t510599
GPG Key ID: D88388851C28715D

View File

@ -1,6 +1,12 @@
<?php <?php
function cavern_notify_user($username, $message="你有新的通知!", $url="", $type="") { function cavern_notify_user($username, $message="你有新的通知!", $url="", $type="") {
global $SQL; global $SQL;
try {
// do not notify the user that doesn't exist
$user = new User($username);
} catch (NoUserException $e) {
return $e;
}
$time = date('Y-m-d H:i:s'); $time = date('Y-m-d H:i:s');
$SQL->query("INSERT INTO `notification` (`username`, `message`, `url`, `type`, `time`) VALUES ('%s', '%s', '%s', '%s', '%s')", array($username, $message, $url, $type, $time)); $SQL->query("INSERT INTO `notification` (`username`, `message`, `url`, `type`, `time`) VALUES ('%s', '%s', '%s', '%s', '%s')", array($username, $message, $url, $type, $time));
} }