From abcc9c1c7bbd264fb3b5bc38ad18c488e25d701c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Tue, 25 Nov 2025 11:39:15 +0000 Subject: [PATCH] Fix FLEXIAPI-412 Restrict the default messages statistics graph to the space... --- .../Http/Controllers/Admin/StatisticsController.php | 10 +++++++--- flexiapi/app/Libraries/StatisticsGraphFactory.php | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/flexiapi/app/Http/Controllers/Admin/StatisticsController.php b/flexiapi/app/Http/Controllers/Admin/StatisticsController.php index 9a45fa6..7c89b70 100644 --- a/flexiapi/app/Http/Controllers/Admin/StatisticsController.php +++ b/flexiapi/app/Http/Controllers/Admin/StatisticsController.php @@ -106,9 +106,13 @@ class StatisticsController extends Controller $fromQuery = StatisticsCall::query(); $toQuery = StatisticsCall::query(); - if ($request->get('domain')) { - $fromQuery->where('to_domain', $request->get('domain')); - $toQuery->where('from_domain', $request->get('domain')); + $domain = $request->user()->superAdmin + ? $request->get('domain') + : $request->space->domain; + + if ($domain) { + $fromQuery->where('to_domain', $domain); + $toQuery->where('from_domain', $domain); } if ($request->get('to')) { diff --git a/flexiapi/app/Libraries/StatisticsGraphFactory.php b/flexiapi/app/Libraries/StatisticsGraphFactory.php index 1a5e993..5c3cbee 100644 --- a/flexiapi/app/Libraries/StatisticsGraphFactory.php +++ b/flexiapi/app/Libraries/StatisticsGraphFactory.php @@ -57,9 +57,9 @@ class StatisticsGraphFactory $fromQuery = StatisticsMessage::query(); $toQuery = StatisticsMessage::query(); - if (!Auth::user()?->admin) { - $fromQuery->where('from_domain', space()->domain); - $toQuery->toDomain($this->domain); + if (!Auth::user()?->superAdmin) { + $fromQuery->where('from_domain', $this->request->space->domain); + $toQuery->toDomain(space()->domain); } elseif ($this->domain) { $fromQuery->where('from_domain', $this->domain); $toQuery->toDomain($this->domain);