Repositories | Polyback | Log in to see private repositories


polyback-website / 8b48bedad56346c44734ee80e6f153429435481c / api/chat/typing.php

829 bytes | parent directory

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

// "I'm typing to this friend" (the page sends it at most every few seconds while typing;
// it expires on its own after Chat::TYPING_SECONDS, and typing=0 or sending clears it).
//   POST friendId, typing=1|0
// The friend sees it through their poll (api/chat/poll "typing").

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

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

$friendId = API::GetParameter("POST", "friendId", "int");
$typing = API::GetParameter("POST", "typing", "bool", true);

if (!Chat::AreFriends(SESSION["user"]["id"], $friendId)) API::respond(200, false, "You can only chat with your friends");

Chat::SetTyping(SESSION["user"]["id"], $friendId, $typing);
API::respond(200, true, "OK");