Repositories | Polyback | Log in to see private repositories


polyback-website / bcef206a2944792d992fb4d0f10cb8969bd17386 / api/chat/friends.php

669 bytes | parent directory

<?php require $_SERVER['DOCUMENT_ROOT'].'/api/private/core.php';

// Chat page: all of your friends with their status (and avatars), and unread counts.
// Response: {"success":true,"friends":[...],"unread":{"<friendId>":n},"unreadTotal":n}

use pizzaboxer\ProjectPolygon\API;
use pizzaboxer\ProjectPolygon\Chat;

API::initialize(["method" => "POST", "logged_in" => true, "secure" => true]);

$unread = Chat::GetUnreadCounts(SESSION["user"]["id"]);

API::respondCustom([
	"status" => 200,
	"success" => true,
	"message" => "OK",
	"friends" => Chat::GetFriendsPresence(SESSION["user"]["id"], true),
	"unread" => (object) $unread,
	"unreadTotal" => array_sum($unread)
]);