Skip to content

Commit

Permalink
fix: add no_token in SpaceConnector of notification plugin connector
Browse files Browse the repository at this point in the history
  • Loading branch information
stat-kwon committed Jan 5, 2024
1 parent 9a41bef commit 1c00f62
Showing 1 changed file with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from spaceone.core.connector import BaseConnector
from spaceone.core.connector.space_connector import SpaceConnector
from spaceone.core.auth.jwt.jwt_util import JWTUtil

__all__ = ["NotificationPluginConnector"]
_LOGGER = logging.getLogger(__name__)
Expand All @@ -11,8 +10,6 @@
class NotificationPluginConnector(BaseConnector):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
token = self.transaction.get_meta("token")
self.token_type = JWTUtil.get_value_from_token(token, "typ")
self.noti_plugin_connector = None

def initialize(self, endpoint: str):
Expand All @@ -22,18 +19,13 @@ def initialize(self, endpoint: str):
endpoint = static_endpoint

self.noti_plugin_connector: SpaceConnector = self.locator.get_connector(
"SpaceConnector", endpoint=endpoint
"SpaceConnector", endpoint=endpoint, token="NO_TOKEN"
)

def init(self, options, domain_id=None):
if self.token_type == "SYSTEM_TOKEN":
return self.noti_plugin_connector.dispatch(
"Protocol.init", {"options": options}, x_domain_id=domain_id
)
else:
return self.noti_plugin_connector.dispatch(
"Protocol.init", {"options": options}
)
return self.noti_plugin_connector.dispatch(
"Protocol.init", {"options": options}
)

def verify(self, options, secret_data):
params = {"options": options, "secret_data": secret_data}
Expand All @@ -51,9 +43,4 @@ def dispatch_notification(
"options": options,
}

if self.token_type == "SYSTEM_TOKEN":
return self.noti_plugin_connector.dispatch(
"Notification.dispatch", params, x_domain_id=domain_id
)
else:
return self.noti_plugin_connector.dispatch("Notification.dispatch", params)
return self.noti_plugin_connector.dispatch("Notification.dispatch", params)

0 comments on commit 1c00f62

Please sign in to comment.