change to dynamic ur
This commit is contained in:
parent
856e51ff09
commit
455d71693d
|
|
@ -4,7 +4,8 @@ export default class extends Controller {
|
||||||
static targets = ['badge', 'list'];
|
static targets = ['badge', 'list'];
|
||||||
static values = {
|
static values = {
|
||||||
userId: Number,
|
userId: Number,
|
||||||
mercureUrl: String
|
mercureUrl: String,
|
||||||
|
url: String,
|
||||||
};
|
};
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
|
|
@ -39,7 +40,7 @@ export default class extends Controller {
|
||||||
|
|
||||||
|
|
||||||
// Use server-provided topic if available, otherwise fallback to default per-user topic
|
// Use server-provided topic if available, otherwise fallback to default per-user topic
|
||||||
const topic = data.topic || `http://portail.solutions-easy.moi/notifications/user/${this.userIdValue}`;
|
const topic = data.topic || `${this.urlValue}/notifications/user/${this.userIdValue}`;
|
||||||
const url = new URL(this.mercureUrlValue);
|
const url = new URL(this.mercureUrlValue);
|
||||||
url.searchParams.append('topic', topic);
|
url.searchParams.append('topic', topic);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ twig:
|
||||||
globals:
|
globals:
|
||||||
application: '%env(APPLICATION)%'
|
application: '%env(APPLICATION)%'
|
||||||
aws_url: '%env(AWS_S3_PORTAL_URL)%'
|
aws_url: '%env(AWS_S3_PORTAL_URL)%'
|
||||||
|
app_url: '%env(APP_URL)%'
|
||||||
version: '0.5'
|
version: '0.5'
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ parameters:
|
||||||
aws_url: '%env(AWS_ENDPOINT)%'
|
aws_url: '%env(AWS_ENDPOINT)%'
|
||||||
aws_public_url: '%env(AWS_ENDPOINT)%'
|
aws_public_url: '%env(AWS_ENDPOINT)%'
|
||||||
aws_bucket: '%env(S3_PORTAL_BUCKET)%'
|
aws_bucket: '%env(S3_PORTAL_BUCKET)%'
|
||||||
|
app_url: '%env(APP_URL)%'
|
||||||
mercure_secret: '%env(MERCURE_JWT_SECRET)%'
|
mercure_secret: '%env(MERCURE_JWT_SECRET)%'
|
||||||
logos_directory: '%kernel.project_dir%/public/uploads/logos'
|
logos_directory: '%kernel.project_dir%/public/uploads/logos'
|
||||||
|
|
||||||
|
|
@ -24,6 +25,9 @@ services:
|
||||||
- '../src/DependencyInjection/'
|
- '../src/DependencyInjection/'
|
||||||
- '../src/Entity/'
|
- '../src/Entity/'
|
||||||
- '../src/Kernel.php'
|
- '../src/Kernel.php'
|
||||||
|
App\MessageHandler\NotificationMessageHandler:
|
||||||
|
arguments:
|
||||||
|
$appUrl: '%app_url%'
|
||||||
App\EventSubscriber\:
|
App\EventSubscriber\:
|
||||||
resource: '../src/EventSubscriber/'
|
resource: '../src/EventSubscriber/'
|
||||||
tags: ['kernel.event_subscriber']
|
tags: ['kernel.event_subscriber']
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ class NotificationMessageHandler
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
private readonly HubInterface $hub
|
private readonly HubInterface $hub,
|
||||||
|
private string $appUrl
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,7 +49,7 @@ class NotificationMessageHandler
|
||||||
|
|
||||||
private function publishToMercure(Notification $notification): void
|
private function publishToMercure(Notification $notification): void
|
||||||
{
|
{
|
||||||
$topic = sprintf('http://portail.solutions-easy.moi/notifications/user/%d', $notification->getUser()->getId());
|
$topic = sprintf('%s/notifications/user/%d', $this->appUrl, $notification->getUser()->getId());
|
||||||
|
|
||||||
$update = new Update(
|
$update = new Update(
|
||||||
$topic,
|
$topic,
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
<li class="nav-item dropdown nav-notif"
|
<li class="nav-item dropdown nav-notif"
|
||||||
data-controller="notification"
|
data-controller="notification"
|
||||||
data-notification-user-id-value="{{ app.user.id }}"
|
data-notification-user-id-value="{{ app.user.id }}"
|
||||||
|
data-notification-url-value="{{ app_url }}"
|
||||||
data-notification-mercure-url-value="{{ app.request.server.get('MERCURE_PUBLIC_URL') ?: 'http://mercure.solutions-easy.moi/.well-known/mercure' }}">
|
data-notification-mercure-url-value="{{ app.request.server.get('MERCURE_PUBLIC_URL') ?: 'http://mercure.solutions-easy.moi/.well-known/mercure' }}">
|
||||||
<a id="notificationDropdown"
|
<a id="notificationDropdown"
|
||||||
class="nav-link count-indicator dropdown-toggle m-auto"
|
class="nav-link count-indicator dropdown-toggle m-auto"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue