From 5766b9f7a0053f94106614e995166a21b94c5f8e Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 9 Feb 2020 15:49:21 +0100 Subject: Support populating kwargs metadata from json properly --- wee_slack.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'wee_slack.py') diff --git a/wee_slack.py b/wee_slack.py index bf144ff..1831958 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -637,16 +637,17 @@ class EventRouter(object): # Here we are passing the actual objects. No more lookups. team = j.get("wee_slack_metadata_team") if team: - try: - kwargs["team"] = team - if "user" in j: - kwargs["user"] = team.users[j["user"]] - if "channel" in j: - kwargs["channel"] = team.channels[j["channel"]] - if "subteam" in j: - kwargs["subteam"] = team.subteams[j["subteam"]] - except: - dbg("metadata failure") + kwargs["team"] = team + if "user" in j: + user_id = j["user"]["id"] if type(j["user"]) == dict else j["user"] + kwargs["user"] = team.users.get(user_id) + if "channel" in j: + channel_id = j["channel"]["id"] if type(j["channel"]) == dict else j["channel"] + kwargs["channel"] = team.channels.get(channel_id) + if "subteam" in j: + kwargs["subteam"] = team.subteams.get(j["subteam"]["id"]) + if "subteam_id" in j: + kwargs["subteam"] = team.subteams.get(j["subteam_id"]) dbg("running {}".format(function_name)) if function_name.startswith("local_") and function_name in self.local_proc: -- cgit