diff --git a/charts/veaiops/Chart.yaml b/charts/veaiops/Chart.yaml index 27d4bd81..84785075 100644 --- a/charts/veaiops/Chart.yaml +++ b/charts/veaiops/Chart.yaml @@ -29,13 +29,13 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 0.1.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.1.0" +appVersion: "0.1.1" dependencies: - name: common diff --git a/charts/veaiops/values.yaml b/charts/veaiops/values.yaml index 329264e7..b320ab0b 100644 --- a/charts/veaiops/values.yaml +++ b/charts/veaiops/values.yaml @@ -245,7 +245,7 @@ backend: image: registry: veaiops-registry-cn-beijing.cr.volces.com repository: veaiops/backend - tag: v0.1.0 + tag: v0.1.1 pullPolicy: Always ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace. @@ -312,7 +312,7 @@ chatops: image: registry: veaiops-registry-cn-beijing.cr.volces.com repository: veaiops/chatops - tag: v0.1.0 + tag: v0.1.1 pullPolicy: Always ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace. @@ -378,7 +378,7 @@ frontend: image: registry: veaiops-registry-cn-beijing.cr.volces.com repository: veaiops/frontend - tag: v0.1.0 + tag: v0.1.1 pullPolicy: Always ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace. @@ -445,7 +445,7 @@ intelligentThreshold: image: registry: veaiops-registry-cn-beijing.cr.volces.com repository: veaiops/intelligent-threshold - tag: v0.1.0 + tag: v0.1.1 pullPolicy: Always ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace. @@ -538,7 +538,7 @@ initial: image: registry: veaiops-registry-cn-beijing.cr.volces.com repository: veaiops/initial - tag: v0.1.0 + tag: v0.1.1 pullPolicy: Always ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace. diff --git a/veaiops/handler/services/event/subscribe.py b/veaiops/handler/services/event/subscribe.py index f3e5c9bd..c251c1d7 100644 --- a/veaiops/handler/services/event/subscribe.py +++ b/veaiops/handler/services/event/subscribe.py @@ -93,40 +93,50 @@ async def create_notice_details(event: Event, subscribes: List[Subscribe]) -> Li """ logger.info(f"start create notice details. event_id={event.id} matched_subscribes={subscribes}") notice_details = [] + seen_notifications = set() for subscribe in subscribes: # 2.1 Webhook notification if subscribe.enable_webhook is True and subscribe.webhook_endpoint: - logger.info(f"create notice detail with webhook endpoint {subscribe.webhook_endpoint} meet") - notice_details.append( - EventNoticeDetail( - event_main_id=event.id, - notice_channel=ChannelType.Webhook, - target=subscribe.webhook_endpoint, - extra={"headers": subscribe.webhook_headers}, - status=EventStatus.INITIAL, + key = (event.id, ChannelType.Webhook, subscribe.webhook_endpoint) + if key not in seen_notifications: + logger.info(f"create notice detail with webhook endpoint {subscribe.webhook_endpoint} meet") + notice_details.append( + EventNoticeDetail( + event_main_id=event.id, + notice_channel=ChannelType.Webhook, + target=subscribe.webhook_endpoint, + extra={"headers": subscribe.webhook_headers}, + status=EventStatus.INITIAL, + ) ) - ) + seen_notifications.add(key) # 2.2 Channel notifications for strategy in subscribe.inform_strategy_ids: logger.info(f"create notice detail with channel strategy {strategy}") for chat_id in strategy.chat_ids: - logger.info( - f"create notice detail with channel strategy {strategy} channel{strategy.channel} chat_id {chat_id}" - ) - notice_details.append( - EventNoticeDetail( - event_main_id=event.id, - notice_channel=ChannelType(strategy.channel), - target=chat_id, - extra={ - "bot_id": strategy.bot_id, - "msg_id": event.raw_data.msg_id if isinstance(event.raw_data, AgentNotification) else "", - "chat_id": chat_id, - }, - status=EventStatus.INITIAL, + key = (event.id, ChannelType(strategy.channel), chat_id) + if key not in seen_notifications: + logger.info( + f"create notice detail with channel strategy {strategy} " + f"channel {strategy.channel} chat_id {chat_id}" ) - ) + notice_details.append( + EventNoticeDetail( + event_main_id=event.id, + notice_channel=ChannelType(strategy.channel), + target=chat_id, + extra={ + "bot_id": strategy.bot_id, + "msg_id": event.raw_data.msg_id + if isinstance(event.raw_data, AgentNotification) + else "", + "chat_id": chat_id, + }, + status=EventStatus.INITIAL, + ) + ) + seen_notifications.add(key) return notice_details