From c1047e13606db620a08df35dc817fd5eb93aa242 Mon Sep 17 00:00:00 2001 From: David Berndtsson Date: Tue, 11 Sep 2018 20:20:42 +0200 Subject: [PATCH] Added function to remove whitespace There was a problem with formatting when posting to space if there was a trailing or leading space in Subject. Added function to remove the spaces. --- services/webexTeams.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/webexTeams.py b/services/webexTeams.py index aad7cc8..6e21d55 100644 --- a/services/webexTeams.py +++ b/services/webexTeams.py @@ -3,6 +3,11 @@ from flata import Query, where from . import log +#Remove whitespace from trailing and leading +def remove_whitespace(text): + cleanedtext = text.rstrip().lstrip() + + return cleanedtext #Send data to Cisco Teams space. def send_it(token, room_id, message): @@ -42,6 +47,9 @@ def buildJson(jsonObject): lastUpdated = n["Updated"] tags = "" incidentId = n["Id"] + + #Clean whitespace from subject to avoid formating error when posting to space. + subject = remove_whitespace(subject) if n["NewsType"]: type = type = n["NewsType"]["Name"] @@ -102,4 +110,4 @@ def postToSpace(objectset, database, logdb, botToken, roomId): database.update(n, where('IncidentId') == incidentIddb) send_it(botToken, roomId, n) - logdb.insert(log.log("New update on object with incidentID of: " + incidentIddb)) \ No newline at end of file + logdb.insert(log.log("New update on object with incidentID of: " + incidentIddb))