PHRAS-3442_optimize-list-notifications_4.1-bis

WIP
fix tests
todo : mark read notifications (button ? click ?)
This commit is contained in:
jygaulier
2021-06-15 19:23:00 +02:00
parent c6784d14c1
commit 6472ce360f
5 changed files with 15 additions and 35 deletions

0
cache/.gitkeep vendored Normal file → Executable file
View File

View File

@@ -47,22 +47,12 @@ class SessionController extends Controller
];
$authenticator = $this->getAuthenticator();
// every request is catched by SessionManagerSubscriber, which handles disconnect
// so this code is probably useless
/*
if ($authenticator->isAuthenticated()) {
$usr_id = $authenticator->getUser()->getId();
if ($usr_id != $request->request->get('usr')) { // I logged with another user
$ret['status'] = 'disconnected';
return $this->app->json($ret);
}
} else {
if (!$authenticator->isAuthenticated()) {
$ret['status'] = 'disconnected';
return $this->app->json($ret);
}
*/
try {
$this->getApplicationBox()->get_connection();

View File

@@ -70,8 +70,12 @@ class SessionManagerSubscriber implements EventSubscriberInterface
return;
}
$moduleIName= $this->getModuleName($request->getPathInfo());
$moduleId = $this->getModuleId($request->getPathInfo());
if(is_null($moduleId) && $moduleIName !== "login") {
return;
}
// if we are already disconnected (ex. from another window), quit immediately
//
if (!($this->app->getAuthenticator()->isAuthenticated())) {

View File

@@ -211,6 +211,10 @@ class eventsmanager_broker
public function get_notifications(int $offset=0, int $limit=10, $readFilter = self::READ | self::UNREAD, \Alchemy\Phrasea\Utilities\Stopwatch $stopwatch = null)
{
if(!$this->app->getAuthenticatedUser()) {
return;
}
if($stopwatch) $stopwatch->lap("broker start");
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

View File

@@ -6,17 +6,17 @@ use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration\Configuration;
use Alchemy\Phrasea\Core\Configuration\HostConfiguration;
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
use Symfony\Component\BrowserKit\Cookie as BrowserCookie;
use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpKernel\Client;
use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\Cookie as BrowserCookie;
use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\Generator\UrlGenerator;
/**
* @group functional
@@ -143,24 +143,6 @@ class ApplicationTest extends \PhraseanetTestCase
$this->assertEquals('en_USA', $client->getResponse()->getContent());
}
/**
* @covers Alchemy\Phrasea\Application
*/
public function testFlashSession()
{
$app = new Application(Application::ENV_TEST);
$sessionId = null;
$app->post('/prod/upload/', function (Application $app) use (&$sessionId) {
$sessionId = $app['session']->getId();
return "";
});
$client = new Client($app);
$client->request('POST', '/prod/upload/', ['php_session_id'=>'123456'], [], ['HTTP_USER_AGENT'=>'flash']);
$this->assertEquals('123456', $sessionId);
}
public function testGeneratePath()
{
$generator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGenerator')