mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-10-08 13:13:20 -04:00
27 lines
595 B
PHP
27 lines
595 B
PHP
<?php
|
|
/** @phpstan-var \Gazelle\User $Viewer */
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Gazelle;
|
|
|
|
authorize();
|
|
|
|
$recipient = new Manager\User()->findById((int)($_POST['toid'] ?? 0));
|
|
if (is_null($recipient)) {
|
|
Error404::error("No such recipient!");
|
|
}
|
|
|
|
$subject = trim($_POST['subject']);
|
|
if (empty($subject)) {
|
|
Error400::error("You can't send a message without a subject.");
|
|
}
|
|
$body = trim($_POST['body'] ?? '');
|
|
if ($body === '') {
|
|
Error400::error("You can't send a message without a body!");
|
|
}
|
|
|
|
$recipient->inbox()->create($Viewer, $subject, $body);
|
|
|
|
header('Location: reports.php');
|