<?php
namespace Claromentis\Communication\Controller;

$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] = (@$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] ?: array()) + array("_2c48e221d3fc1acee3788d535112df" . "7a" => base64_decode("SW52YWxpZCB" . "vZmZzZXQ="), "_66aaa4202afc08" . "7ccc629429b94f2" . "6cf" => base64_decode("bmV4dA=" . "="), "_decf18bb747cbba55f12f65abcc007" . "97" => base64_decode("aH" . "Rt" . "bA" . "=="), "_62d701c3c53404f06345eb" . "35720a47b4" => base64_decode("aXNfbnVtZXJpYw" . "=="), "_1f50e30be8c2fefa6881834e71d504" . "a2" => base64_decode("b2Zmc2V" . "0"), "_4b5e91a0a6f7f822ac389ad9" . "a3fb0ee2" => base64_decode("c3V" . "jY2" . "Vzc" . "w=="), "_6d77bf7" . "3cec2f3b" . "4ec1e0d2" . "e69daf17" . "1" => base64_decode("dHJ" . "1ZQ" . "=="), "_112a8c1b185e5" . "9fd71917e0e81e" . "a68a4" => base64_decode("Y29tbXVuaWNhdGlvbi94aHIvYWxsX3V" . "zZXJzX2xpc3QuaHRtbA=="), "_a2013f91" . "4345f2720" . "cc08eb8e2" . "3f0361" => base64_decode("SW52YWxpZCBtZXNzYW" . "dlIElE"), "_f4eafa5f4" . "93306ffdb5" . "1a688b21dd" . "507" => base64_decode("dG" . "90" . "YW" . "w="), "_d70d65aa993c89b370f2de094df" . "9102f" => base64_decode("Y29tbXVuaWNhdGlvbi9pbmNsdWRlcy9jb252ZXJzYXRpb2" . "5fbWVzc2FnZXMuaHRtbA=="));
use Claromentis\Communication\Message;
use Claromentis\Communication\Repository\ConversationRepository;
use Claromentis\Core\Acl\AclRepository;
use Claromentis\Core\Application;
use Claromentis\Core\Config\Config;
use Claromentis\Core\DAL\Interfaces\DbInterface;
use Claromentis\Core\Http\gpc;
use Claromentis\Core\Http\JsonPrettyResponse;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\Core\TextUtil\ClaText;
use InvalidArgumentException;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\HttpFoundation\JsonResponse;




class MessagesController
{
    
    
    
    
    protected $repo;
    
    
    
    
    
    
    public function __construct(ConversationRepository $repo)
    {
        $this->repo = $repo;
    }
    
    
    
    
    
    
    
    
    
    
    public function ListMessages(Application $app, ServerRequestInterface $request, SecurityContext $context, $message_id)
    {
        $user_id = $context->GetUserId();
        $_f11369824f533e8206f9ccc0c9aab3a0 = Message::PAGINATION_LIMIT;
        $_1f50e30be8c2fefa6881834e71d504a2 = gpc::get($request, $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_1f50e30be8c2fefa68818" . "34e71d504a2"]) ?? 0;
        if (empty($message_id) || !$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_62d701c3c534" . "04f06345eb357" . "20a47b4"]($message_id)) {
            throw new InvalidArgumentException($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_a2013f914345f27" . "20cc08eb8e23f036" . "1"]);
        }
        if (isset($_1f50e30be8c2fefa6881834e71d504a2) && !$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_62d701c3c534" . "04f06345eb357" . "20a47b4"]($_1f50e30be8c2fefa6881834e71d504a2)) {
            throw new InvalidArgumentException($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_2c48e221d3fc1acee3788d" . "535112df7a"]);
        }
        
        
        $controller = new Message($app->db, $app->acl, $app->config, $app->{ClaText::class}, $this->repo, $user_id);
        $args = $controller->GetTemplateData($message_id, 0, $_1f50e30be8c2fefa6881834e71d504a2);
        $templater = $app->templater;
        $_597b318ad8c4cb04e32425cd301e04af = $this->repo->CountMessagesForUser($message_id, $user_id);
        $_decf18bb747cbba55f12f65abcc00797 = $templater->Render($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_d70d65aa993c89b370f2" . "de094df9102f"], $args);
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_f4eafa5f49330" . "6ffdb51a688b21" . "dd507"] => $_597b318ad8c4cb04e32425cd301e04af, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_66aaa4202afc087ccc629429b9" . "4f26cf"] => $_1f50e30be8c2fefa6881834e71d504a2 + $_f11369824f533e8206f9ccc0c9aab3a0, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_decf18bb747cbba55f12f65a" . "bcc00797"] => $_decf18bb747cbba55f12f65abcc00797]);
    }
    public function ShowParticipants(Application $app, SecurityContext $context, AclRepository $acl, Config $config, ClaText $claText, DbInterface $db, int $message_id)
    {
        $templater = $app->templater;
        $_e05e0022a2e5ad344b9c4a0d3f64e1a5 = new Message($db, $acl, $config, $claText, $this->repo, $context->GetUserId());
        $args = $_e05e0022a2e5ad344b9c4a0d3f64e1a5->GetTemplateData($message_id, 0);
        $_decf18bb747cbba55f12f65abcc00797 = $templater->Render($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_112a8c1b185e59fd71917e0" . "e81ea68a4"], $args);
        return new JsonPrettyResponse([$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_4b5e91a0a6f7f" . "822ac389ad9a3f" . "b0ee2"] => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_6d77bf73cec2f3b4ec1e0d2e6" . "9daf171"], $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_decf18bb747c" . "bba55f12f65ab" . "cc00797"] => $_decf18bb747cbba55f12f65abcc00797]);
    }
}