Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Which images to pull for production deployment
VERSION=2.4.1
VERSION=2.4.2

# Impact containers names, see
# https://docs.docker.com/compose/how-tos/environment-variables/envvars/#compose_project_name
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog of AgentJ

## 2025-12-19 - 2.4.2

### Bug fixes

- Execute the `messenger:consume` command as `www-data` ([0ad0113e](https://github.com/Probesys/agentj/commit/0ad0113e))
- Fix setting the default locale ([b428b41d](https://github.com/Probesys/agentj/commit/b428b41d))
- Fix autorelease with a high number of untreated messages ([faccbb2c](https://github.com/Probesys/agentj/commit/faccbb2c))
- Fix an English translation in the dashboard stats ([e9b39cdf](https://github.com/Probesys/agentj/commit/e9b39cdf))

## 2025-12-18 - 2.4.1

### Maintenance
Expand Down
32 changes: 12 additions & 20 deletions app/src/Command/AmavisAutoReleaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)]
class AmavisAutoReleaseCommand extends Command
{
private int $batchSize = 1000;
private int $batchSize = 500;

public function __construct(
private MsgrcptSearchRepository $msgrcptSearchRepository,
Expand All @@ -43,28 +43,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::FAILURE;
}

$searchQuery = $this->msgrcptSearchRepository->getSearchQuery(
null,
MessageStatus::UNTREATED
);
$users = $this->userRepository->findAllWithoutHumanAuthentication();

$messageRecipients = $searchQuery->setMaxResults($this->batchSize)->getResult();
foreach ($users as $user) {
$searchQuery = $this->msgrcptSearchRepository->getSearchQuery(
$user,
MessageStatus::UNTREATED
);

foreach ($messageRecipients as $messageRecipient) {
if ($messageRecipient->isAmavisReleaseOngoing()) {
continue;
}

$user = $this->userRepository->findOneBy([
'email' => $messageRecipient->getRid()->getEmailClear()
]);

if (!$user) {
continue;
}
$messageRecipients = $searchQuery->setMaxResults($this->batchSize)->getResult();

if ($user->getBypassHumanAuth()) {
$this->messageService->dispatchRelease($messageRecipient);
foreach ($messageRecipients as $messageRecipient) {
if (!$messageRecipient->isAmavisReleaseOngoing()) {
$this->messageService->dispatchRelease($messageRecipient);
}
}
}

Expand Down
26 changes: 11 additions & 15 deletions app/src/EventSubscriber/LocaleSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,35 @@

namespace App\EventSubscriber;

use App\Service\LocaleService;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class LocaleSubscriber implements EventSubscriberInterface
{
private string $defaultLocale;

public function __construct(string $defaultLocale = 'fr')
{
$this->defaultLocale = $defaultLocale;
public function __construct(
private LocaleService $localeService,
) {
}

public function onKernelRequest(RequestEvent $event): void
{
$request = $event->getRequest();
if (!$request->hasPreviousSession()) {
return;
}

// try to see if the locale has been set as a _locale routing parameter
if ($locale = $request->attributes->get('_locale')) {
$request->getSession()->set('_locale', $locale);
} else {
// if no explicit locale has been set on this request, use one from the session
$request->setLocale($request->getSession()->get('_locale', $this->defaultLocale));
$supportedLocalesCodes = $this->localeService->getSupportedLocalesCodes();
$locale = $request->getPreferredLanguage($supportedLocalesCodes);

if ($request->hasPreviousSession()) {
$locale = $request->getSession()->get('_locale', $locale);
}

$request->setLocale($locale);
}

public static function getSubscribedEvents(): array
{
return [
// must be registered before (i.e. with a higher priority than) the default Locale listener
KernelEvents::REQUEST => [['onKernelRequest', 20]],
];
}
Expand Down
38 changes: 38 additions & 0 deletions app/src/EventSubscriber/UserLocaleSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\EventSubscriber;

use App\Service\LocaleService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\SecurityEvents;

class UserLocaleSubscriber implements EventSubscriberInterface
{
public function __construct(
private RequestStack $requestStack,
private LocaleService $localeService,
) {
}

public function onInteractiveLogin(InteractiveLoginEvent $event): void
{
/** @var ?\App\Entity\User $user */
$user = $event->getAuthenticationToken()->getUser();

$request = $this->requestStack->getCurrentRequest();
$session = $this->requestStack->getSession();
$userLocale = $this->localeService->getUserLocale($user);

$session->set('_locale', $userLocale);
$request->setLocale($userLocale);
}

public static function getSubscribedEvents(): array
{
return [
SecurityEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin',
];
}
}
10 changes: 10 additions & 0 deletions app/src/Repository/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ public function findOneByPrincipalName(string $principalName): ?User
->getOneOrNullResult();
}

/**
* @return User[]
*/
public function findAllWithoutHumanAuthentication(): array
{
return $this->findBy([
'bypassHumanAuth' => true,
]);
}

/**
* Return all users from active domains
*
Expand Down
12 changes: 0 additions & 12 deletions app/src/Security/LoginFormAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,6 @@ private function getLocalUser(string $userName): ?User

public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
{
/** @var User $user */
$user = $token->getUser();

if ($user->getDomain() && $user->getDomain()->getDefaultLang()) {
$request->getSession()->set('_locale', $user->getDomain()->getDefaultLang());
}


if ($user->getPreferedLang()) {
$request->getSession()->set('_locale', $user->getPreferedLang());
}

if ($targetPath = $this->getTargetPath($request->getSession(), $firewallName)) {
return new RedirectResponse($targetPath);
}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/dashboard/stats-by-status.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
if (filteredData.datasets[0].data.length === 0) { // Display a message if there is no data
document.getElementById('messagesChart').style.display = 'none';
var noDataMessage = document.createElement('p');
noDataMessage.textContent = 'Aucun message bloqué';
noDataMessage.textContent = '{{ 'Entities.Message.noBlockedMessages' | trans }}';
noDataMessage.style.textAlign = 'center';
noDataMessage.style.marginTop = '20px';
document.getElementById('messagesChart').parentNode.appendChild(noDataMessage);
Expand Down
1 change: 1 addition & 0 deletions app/translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ Entities:
spamLevel: Note
dateAuthRequestAt: "Authentication request sent the"
isMailingList: "Mailing list? "
noBlockedMessages: 'No blocked messages'
labels:
infos: "Information about the blockage"
preview: "Preview of the message"
Expand Down
1 change: 1 addition & 0 deletions app/translations/messages.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ Entities:
spamLevel: Note
dateAuthRequestAt: "Demande d'authentification envoyée le"
isMailingList: "Mailing liste ? "
noBlockedMessages: 'Aucun message bloqué'
labels:
infos: "Informations sur les refus"
preview: "Aperçu du message"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ services:
image: probesys38/agentj_app:$VERSION
build:
context: ./app
command: "php /var/www/agentj/bin/console messenger:consume async scheduler_default --memory-limit=128M"
command: "sudo -u www-data php /var/www/agentj/bin/console messenger:consume async scheduler_default --memory-limit=128M"
entrypoint: "/entrypoint-worker.sh"
restart: unless-stopped
env_file:
Expand Down
Loading