Bläddra i källkod

Aggressively filter empty text in slack hooks.

master
Chris Smith 6 år sedan
förälder
incheckning
6b107fbbb9
1 ändrade filer med 7 tillägg och 2 borttagningar
  1. 7
    2
      lineandsinker/services/slack.py

+ 7
- 2
lineandsinker/services/slack.py Visa fil

13
         else:
13
         else:
14
             content = json.loads(request.form["payload"])
14
             content = json.loads(request.form["payload"])
15
 
15
 
16
-        text = content["text"]
16
+        text = content["text"].strip()
17
         if "attachments" in content:
17
         if "attachments" in content:
18
-            text += " " + " ".join(a["fallback"] for a in content["attachments"])
18
+            text += " " + " ".join(
19
+                filter(
20
+                    lambda x: len(x) > 0,
21
+                    (a["fallback"].strip() for a in content["attachments"]),
22
+                )
23
+            )
19
 
24
 
20
         yield {"type": f"slack", "source": identifier, "text": text}
25
         yield {"type": f"slack", "source": identifier, "text": text}

Laddar…
Avbryt
Spara