From 4fd27a8dcb062e29fbb4ebabe0ddaf33fc9c6577 Mon Sep 17 00:00:00 2001 From: Anton Mrosek Date: Mon, 25 Aug 2025 09:53:58 +0200 Subject: [PATCH 1/4] Scope Data Update: Prefix topic with scope ID --- packages/opal-server/opal_server/scopes/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opal-server/opal_server/scopes/api.py b/packages/opal-server/opal_server/scopes/api.py index d54b1074c..8d0cd4c0f 100644 --- a/packages/opal-server/opal_server/scopes/api.py +++ b/packages/opal-server/opal_server/scopes/api.py @@ -347,7 +347,7 @@ async def publish_data_update_event( restrict_optional_topics_to_publish(authenticator, claims, update) for entry in update.entries: - entry.topics = [f"data:{topic}" for topic in entry.topics] + entry.topics = [f"{scope_id}:data:{topic}" for topic in entry.topics] await DataUpdatePublisher( ScopedServerSideTopicPublisher(pubsub_endpoint, scope_id) From 7885f6ebd11c08458bd5cc340f8fc5e791a90e25 Mon Sep 17 00:00:00 2001 From: Anton Mrosek Date: Mon, 25 Aug 2025 10:26:39 +0200 Subject: [PATCH 2/4] Scoped Publisher: Remove scope prefixing to avoid duplicate prefix --- packages/opal-common/opal_common/topics/publisher.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/opal-common/opal_common/topics/publisher.py b/packages/opal-common/opal_common/topics/publisher.py index 95ef58755..c9eab4668 100644 --- a/packages/opal-common/opal_common/topics/publisher.py +++ b/packages/opal-common/opal_common/topics/publisher.py @@ -202,7 +202,6 @@ def __init__(self, endpoint: PubSubEndpoint, scope_id: str): super().__init__(endpoint) self._scope_id = scope_id - async def publish(self, topics: TopicList, data: Any = None): - scoped_topics = [f"{self._scope_id}:{topic}" for topic in topics] + async def publish(self, scoped_topics: TopicList, data: Any = None): logger.info("Publishing to topics: {topics}", topics=scoped_topics) await super().publish(scoped_topics, data) From 4daae829b24a97fe80ba6e955cadb3c6985ab743 Mon Sep 17 00:00:00 2001 From: Anton Mrosek Date: Thu, 28 Aug 2025 16:28:30 +0200 Subject: [PATCH 3/4] Revert "Scoped Publisher: Remove scope prefixing to avoid duplicate prefix" This reverts commit 7885f6ebd11c08458bd5cc340f8fc5e791a90e25. --- packages/opal-common/opal_common/topics/publisher.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/opal-common/opal_common/topics/publisher.py b/packages/opal-common/opal_common/topics/publisher.py index c9eab4668..95ef58755 100644 --- a/packages/opal-common/opal_common/topics/publisher.py +++ b/packages/opal-common/opal_common/topics/publisher.py @@ -202,6 +202,7 @@ def __init__(self, endpoint: PubSubEndpoint, scope_id: str): super().__init__(endpoint) self._scope_id = scope_id - async def publish(self, scoped_topics: TopicList, data: Any = None): + async def publish(self, topics: TopicList, data: Any = None): + scoped_topics = [f"{self._scope_id}:{topic}" for topic in topics] logger.info("Publishing to topics: {topics}", topics=scoped_topics) await super().publish(scoped_topics, data) From 4ed51460adebe64aac3b643d3d0e9273e6db9334 Mon Sep 17 00:00:00 2001 From: Anton Mrosek Date: Thu, 28 Aug 2025 16:31:56 +0200 Subject: [PATCH 4/4] Use ServerSideTopicPublisher for already scoped topics --- packages/opal-server/opal_server/scopes/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opal-server/opal_server/scopes/api.py b/packages/opal-server/opal_server/scopes/api.py index 8d0cd4c0f..4fe14049b 100644 --- a/packages/opal-server/opal_server/scopes/api.py +++ b/packages/opal-server/opal_server/scopes/api.py @@ -350,7 +350,7 @@ async def publish_data_update_event( entry.topics = [f"{scope_id}:data:{topic}" for topic in entry.topics] await DataUpdatePublisher( - ScopedServerSideTopicPublisher(pubsub_endpoint, scope_id) + ServerSideTopicPublisher(pubsub_endpoint) ).publish_data_updates(update) except Unauthorized as ex: logger.error(f"Unauthorized to publish update: {repr(ex)}")