Periodical sync from dev FTP
This commit is contained in:
		@@ -77,9 +77,9 @@ class AutomationManager{
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
					} else if ($onValue['type'] == 'outHome') {
 | 
			
		||||
 | 
			
		||||
						//TODO: Add Ovner to automation
 | 
			
		||||
					} else if ($onValue['type'] == 'inHome') {
 | 
			
		||||
 | 
			
		||||
						//TODO: Add Ovner to automation
 | 
			
		||||
					} else if ($onValue['type'] == 'noOneHome') {
 | 
			
		||||
						$users = UserManager::getUsers();
 | 
			
		||||
						$membersHome = 0;
 | 
			
		||||
@@ -120,14 +120,19 @@ class AutomationManager{
 | 
			
		||||
						$subscribers = NotificationManager::getSubscription();
 | 
			
		||||
						$i = 0;
 | 
			
		||||
 | 
			
		||||
						foreach ($subscribers as $key => $subscriber) {
 | 
			
		||||
							$logManager->write("[NOTIFICATION] SENDING NOTIFICATION TO" . $subscriber['id'] . " was executed" . $i);
 | 
			
		||||
							$title = 'Automatization '.$automation['name']." was just executed";
 | 
			
		||||
							$notification = new Notification(SERVERKEY);
 | 
			
		||||
							$notification->to($subscriber['token']);
 | 
			
		||||
							$notification->notification($title, ''  , '', '');
 | 
			
		||||
							$notification->send();
 | 
			
		||||
							$notification = null;
 | 
			
		||||
						$notificationMng = new NotificationManager;
 | 
			
		||||
						$notificationData = [
 | 
			
		||||
							'title' => 'Automatization',
 | 
			
		||||
							'body' => 'Automatization '.$automation['name']." was just executed",
 | 
			
		||||
							'icon' => BASEDIR . '/app/templates/images/icon-192x192.png',
 | 
			
		||||
						];
 | 
			
		||||
 | 
			
		||||
						if ($notificationData != []) {
 | 
			
		||||
							$subscribers = $notificationMng::getSubscription();
 | 
			
		||||
							foreach ($subscribers as $key => $subscriber) {
 | 
			
		||||
								$logManager->write("[NOTIFICATION/AUTOOMATION] SENDING TO" . $subscriber['id'] . " ");
 | 
			
		||||
								$notificationMng::sendSimpleNotification(SERVERKEY, $subscriber['token'], $notificationData);
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
						$logManager->write("[AUTOMATIONS] automation id ". $automation['automation_id'] . " was executed");
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@
 | 
			
		||||
/**
 | 
			
		||||
* Notification Manager
 | 
			
		||||
*/
 | 
			
		||||
//TODO: Working timestamp to body or $title
 | 
			
		||||
class NotificationManager
 | 
			
		||||
{
 | 
			
		||||
	function addSubscriber($userID = '', $token = ''){
 | 
			
		||||
@@ -19,7 +20,7 @@ class NotificationManager
 | 
			
		||||
		return Db::loadAll('SELECT * FROM notifications;', array());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function sendSimpleNotification(string $serverKey, string $to, array $data){
 | 
			
		||||
	function sendSimpleNotification(string $serverKey, string $to, array $data, bool $timeStamp = false){
 | 
			
		||||
		$dataTemplate = [
 | 
			
		||||
			'title' => '',
 | 
			
		||||
			'body' => '',
 | 
			
		||||
@@ -30,6 +31,10 @@ class NotificationManager
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($timeStamp) {
 | 
			
		||||
			$data['title'] = $data['title'] . date();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$notification = new Notification($serverKey);
 | 
			
		||||
		$notification->to($to);
 | 
			
		||||
		$notification->notification($data['title'], $data['body'], $data['icon'], '');
 | 
			
		||||
@@ -64,8 +69,12 @@ class Notification
 | 
			
		||||
		$this->jsonPayload["to"] = $to;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function notification($title = '', $body = '', $icon = '', $action = '')
 | 
			
		||||
	function notification($title = '', $body = '', $icon = '', $action = '', bool $timeStamp = false)
 | 
			
		||||
	{
 | 
			
		||||
		if ($timeStamp) {
 | 
			
		||||
			$data['title'] = $data['title'] . date();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->jsonPayload["data"]["notification"]["title"] = $title;
 | 
			
		||||
		$this->jsonPayload["data"]["notification"]["body"] = $body;
 | 
			
		||||
		$this->jsonPayload["data"]["notification"]["icon"] = $icon;
 | 
			
		||||
 
 | 
			
		||||
@@ -119,7 +119,7 @@ class Utilities
 | 
			
		||||
			case '>=': // Greater than or equal to
 | 
			
		||||
			return $value1 >= $value2;
 | 
			
		||||
			case '==': // Equal
 | 
			
		||||
			return $value1 == $value2;
 | 
			
		||||
			return ($value1 == $value2);
 | 
			
		||||
			case '===': // Identical
 | 
			
		||||
			return $value1 === $value2;
 | 
			
		||||
			case '!==': // Not Identical
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user