aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-02-09 15:49:21 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2020-02-23 18:47:05 +0100
commit5766b9f7a0053f94106614e995166a21b94c5f8e (patch)
tree5468e04764035163b267bac3eb1833d393a81320
parent324890c3d0155a700fb247f5ee8f3b0778d83fe5 (diff)
downloadwee-slack-5766b9f7a0053f94106614e995166a21b94c5f8e.tar.gz
Support populating kwargs metadata from json properly
-rw-r--r--wee_slack.py21
1 files changed, 11 insertions, 10 deletions
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: