Explorar o código

Implemented Notifications V1 API

seavenois %!s(int64=9) %!d(string=hai) anos
pai
achega
6d3f5d78ea
Modificáronse 1 ficheiros con 16 adicións e 12 borrados
  1. 16 12
      www/API/v1/notifications.php

+ 16 - 12
www/API/v1/notifications.php

@@ -68,15 +68,20 @@
 			$query = "SELECT id, title_es, title_en, title_eu, text_es, text_en, text_eu, dtime, internal AS gm, duration, action, 0 AS seen FROM notification WHERE dtime > NOW() - INTERVAL duration MINUTE ORDER BY dtime DESC";
 		}
 		$q = mysqli_query($con, $query);
-		switch ($format){
-			case FOR_JSON:
-				//Create result array
-				$rows = array();
-				while($r = mysqli_fetch_assoc($q)) {
-					$rows[] = $r;
-				}
-				return(json_encode($rows));
-				break;
+		if (mysqli_num_rows($q) == 0){
+			http_response_code(204);
+		}
+		else{
+			switch ($format){
+				case FOR_JSON:
+					//Create result array
+					$rows = array();
+					while($r = mysqli_fetch_assoc($q)) {
+						$rows[] = $r;
+					}
+					return(json_encode($rows));
+					break;
+			}
 		}
 	}
 	
@@ -121,6 +126,5 @@
 	if (strlen($error) == 0){
 		echo(show_notifications($con, $target, $format));
 	}
-	
-	//Log the request
-	//log_sync(); //TODO;
+
+?>