From 2a367c7a30dd6596dd2e4667c706ef8a52e10bdc Mon Sep 17 00:00:00 2001 From: Richard Qi Date: Wed, 29 Nov 2023 23:01:04 -0800 Subject: [PATCH] bug fix and code cleanup --- .../services/notificationservice.py | 6 ++--- notification-manager/sample.env | 2 +- .../services/notificationservice.py | 24 ++++++++----------- sample.env | 2 +- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/notification-manager/notification_api/services/notificationservice.py b/notification-manager/notification_api/services/notificationservice.py index 29d793ae3..8c46a8fff 100644 --- a/notification-manager/notification_api/services/notificationservice.py +++ b/notification-manager/notification_api/services/notificationservice.py @@ -101,7 +101,5 @@ def __mutenotification(self, requesttype, notificationtype, request): if notificationtype.upper() in (_notificationtype.upper() for _notificationtype in mutenotifications[bcgovcode]["type_exceptions"]): return False return True - else: - return False - else: - return False \ No newline at end of file + + return False \ No newline at end of file diff --git a/notification-manager/sample.env b/notification-manager/sample.env index 56b81ebda..8898ee81e 100644 --- a/notification-manager/sample.env +++ b/notification-manager/sample.env @@ -19,4 +19,4 @@ NOTIFICATION_REDIS_PORT= NOTIFICATION_REDIS_PASSWORD= NOTIFICATION_REDIS_HEALTHCHECK_INT=10 NOTIFICATION_STREAM_KEY=FOINOTIFICATION -MUTE_NOTIFICATION={"MCF": {"request_types": ["Personal"], "state_exceptions": ["Call For Record", "Ministry Signoff"], "type_exceptions":["Reply User Comments", "Tagged User Comments"]}} \ No newline at end of file +MUTE_NOTIFICATION={"MCF": {"request_types": ["Personal"], "state_exceptions": ["Call For Records", "Ministry Sign Off"], "type_exceptions":["Reply User Comments", "Tagged User Comments"]}} \ No newline at end of file diff --git a/request-management-api/request_api/services/notificationservice.py b/request-management-api/request_api/services/notificationservice.py index cc32ecc5d..036a4ae60 100644 --- a/request-management-api/request_api/services/notificationservice.py +++ b/request-management-api/request_api/services/notificationservice.py @@ -306,21 +306,17 @@ def __mutenotification(self, requesttype, notificationtype, request): #get mute conditions from env mutenotifications = notificationconfig().getmutenotifications() if "programarea.bcgovcode" in request: - return False + bcgovcode = request["programarea.bcgovcode"].upper() + if requesttype == "ministryrequest"and bcgovcode in mutenotifications: + foirequest = FOIRequest.getrequest(request["foirequest_id"]) + if foirequest["requesttype"].upper() in (_requesttype.upper() for _requesttype in mutenotifications[bcgovcode]["request_types"]): + if request["requeststatus.name"].upper() in (_state.upper() for _state in mutenotifications[bcgovcode]["state_exceptions"]): + return False + if notificationtype.upper() in (_notificationtype.upper() for _notificationtype in mutenotifications[bcgovcode]["type_exceptions"]): + return False + return True - bcgovcode = request["programarea.bcgovcode"].upper() - if requesttype == "ministryrequest"and bcgovcode in mutenotifications: - foirequest = FOIRequest.getrequest(request["foirequest_id"]) - if foirequest["requesttype"].upper() in (_requesttype.upper() for _requesttype in mutenotifications[bcgovcode]["request_types"]): - if request["requeststatus.name"].upper() in (_state.upper() for _state in mutenotifications[bcgovcode]["state_exceptions"]): - return False - if notificationtype.upper() in (_notificationtype.upper() for _notificationtype in mutenotifications[bcgovcode]["type_exceptions"]): - return False - return True - else: - return False - else: - return False + return False def getrequest(self, requestid, requesttype): if requesttype == "ministryrequest": diff --git a/sample.env b/sample.env index e219c9c8e..b0f5583d4 100644 --- a/sample.env +++ b/sample.env @@ -159,4 +159,4 @@ DISABLE_REDACT_WEBLINK=false DISABLE_GATHERINGRECORDS_TAB=false KC_SRC_ACC_TOKEN_EXPIRY=60 -MUTE_NOTIFICATION={"MCF": {"request_types": ["Personal"], "state_exceptions": ["Call For Record", "Ministry Signoff"], "type_exceptions":["Reply User Comments", "Tagged User Comments"]}} \ No newline at end of file +MUTE_NOTIFICATION={"MCF": {"request_types": ["Personal"], "state_exceptions": ["Call For Records", "Ministry Sign Off"], "type_exceptions":["Reply User Comments", "Tagged User Comments"]}} \ No newline at end of file