@@ -58,13 +58,28 @@ def send_complaint_to_service(self, complaint_data):
58
58
def _send_data_to_service_callback_api (self , data , service_callback_url , token , function_name ):
59
59
notification_id = data ["notification_id" ] if "notification_id" in data else data ["id" ]
60
60
try :
61
- response = request (
62
- method = "POST" ,
63
- url = service_callback_url ,
64
- data = json .dumps (data ),
65
- headers = {"Content-Type" : "application/json" , "Authorization" : "Bearer {}" .format (token )},
66
- timeout = 5 ,
67
- )
61
+ ssl_crt = current_app .config ["SSL_CLIENT_OVERRIDE_CERT" ]
62
+
63
+ if ssl_crt :
64
+ current_app .logger .warning ("!!! USING CLIENT CERT !!!" )
65
+ response = request (
66
+ method = "POST" ,
67
+ url = service_callback_url ,
68
+ data = json .dumps (data ),
69
+ headers = {"Content-Type" : "application/json" , "Authorization" : "Bearer {}" .format (token )},
70
+ cert = ssl_crt ,
71
+ timeout = 5 ,
72
+ )
73
+ else :
74
+ current_app .logger .warning ("!!! NOT USING CLIENT CERT !!!" )
75
+ response = request (
76
+ method = "POST" ,
77
+ url = service_callback_url ,
78
+ data = json .dumps (data ),
79
+ headers = {"Content-Type" : "application/json" , "Authorization" : "Bearer {}" .format (token )},
80
+ timeout = 5 ,
81
+ )
82
+
68
83
current_app .logger .info (
69
84
"%s sending %s to %s, response %s" ,
70
85
function_name ,
@@ -108,9 +123,9 @@ def create_delivery_status_callback_data(notification, service_callback_api):
108
123
"notification_to" : notification .to ,
109
124
"notification_status" : notification .status ,
110
125
"notification_created_at" : notification .created_at .strftime (DATETIME_FORMAT ),
111
- "notification_updated_at" : notification . updated_at . strftime ( DATETIME_FORMAT )
112
- if notification .updated_at
113
- else None ,
126
+ "notification_updated_at" : (
127
+ notification . updated_at . strftime ( DATETIME_FORMAT ) if notification .updated_at else None
128
+ ) ,
114
129
"notification_sent_at" : notification .sent_at .strftime (DATETIME_FORMAT ) if notification .sent_at else None ,
115
130
"notification_type" : notification .notification_type ,
116
131
"service_callback_api_url" : service_callback_api .url ,
0 commit comments