fix(sse): isolate price stream inbox per tenant
Shared Redis global inbox mixed other shops' product lists into this catalog and made the grid jump. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -126,14 +126,37 @@ class PriceStreamService
|
||||
return $store;
|
||||
}
|
||||
|
||||
/**
|
||||
* چند مستأجر روی یک Redis با پیشوند یکسان inbox را قاطی میکردند
|
||||
* (لیست شمش یک فروشگاه روی صفحهٔ فروشگاه دیگر).
|
||||
*/
|
||||
public function tenantScope(): string
|
||||
{
|
||||
$default = (string) config('database.default', 'mysql');
|
||||
$db = (string) config("database.connections.{$default}.database");
|
||||
$host = '';
|
||||
try {
|
||||
$host = app(ConfigService::class)->resolvePublicHost();
|
||||
} catch (\Throwable) {
|
||||
$host = '';
|
||||
}
|
||||
|
||||
$parts = array_values(array_filter(
|
||||
[$db, $host],
|
||||
static fn (string $value): bool => $value !== ''
|
||||
));
|
||||
|
||||
return $parts !== [] ? implode(':', $parts) : 'default';
|
||||
}
|
||||
|
||||
private function inboxKey(): string
|
||||
{
|
||||
return self::INBOX_PREFIX.'global';
|
||||
return self::INBOX_PREFIX.$this->tenantScope();
|
||||
}
|
||||
|
||||
private function customerInboxKey(int $customerId): string
|
||||
{
|
||||
return self::CUSTOMER_INBOX_PREFIX.$customerId;
|
||||
return self::CUSTOMER_INBOX_PREFIX.$this->tenantScope().':'.$customerId;
|
||||
}
|
||||
|
||||
private function currentInboxSeq(string $key): int
|
||||
|
||||
Reference in New Issue
Block a user