From f0815d08f9c304866fe012c7cacda79f36ceb890 Mon Sep 17 00:00:00 2001
From: edebrye <edebrye@ippon.fr>
Date: Thu, 18 Mar 2021 09:50:26 +0100
Subject: [PATCH] modified lambda for slack alerting

---
 deploy/lambda/slack/slack.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/deploy/lambda/slack/slack.py b/deploy/lambda/slack/slack.py
index 50c0ac5..4711780 100644
--- a/deploy/lambda/slack/slack.py
+++ b/deploy/lambda/slack/slack.py
@@ -15,15 +15,17 @@ def lambda_handler(event, context):
 "\t- New State Value : "+m.get('NewStateValue')+"\n"+ \
 "\t- New State Reason : "+m.get('NewStateReason')+"\n"+ \
 "\t- New State Time : "+m.get('StateChangeTime')+"\n")
+    print("Number of messages : " +str(len(text)))
     msg = {
         "text": "\n-------\n".join(text)
     }
     
     encoded_msg = json.dumps(msg).encode('utf-8')
     resp = http.request('POST',url, body=encoded_msg)
-    print(json.dumps({
-        "messages": messages,
+    ret = json.dumps({
+        "body": {"messages":messages},
         "status_code": resp.status,
         "response": resp.data.decode("utf-8")
-        })
-    )
\ No newline at end of file
+    })
+    print(ret)
+    return ret
\ No newline at end of file
-- 
GitLab