diff options
author | Bryan Gilbert <gilbertw1@gmail.com> | 2017-07-19 11:49:27 -0400 |
---|---|---|
committer | Bryan Gilbert <gilbertw1@gmail.com> | 2017-07-19 11:49:27 -0400 |
commit | cf925197db601bab09ddf5aecd38817b137a5689 (patch) | |
tree | 5c539c6df9a1d046fa2e25e43ccff934d67d94c3 | |
parent | 6106d9e766f0ea759be3ece5a74ab0e5c3833126 (diff) | |
download | wee-slack-cf925197db601bab09ddf5aecd38817b137a5689.tar.gz |
use im.open endpoint to properly update unread count for ims on startup
-rw-r--r-- | wee_slack.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py index f269349..801b61d 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1243,6 +1243,11 @@ class SlackChannel(object): s = SlackRequest(self.team.token, SLACK_API_TRANSLATOR[self.type]["info"], {"channel": self.identifier}, team_hash=self.team.team_hash, channel_identifier=self.identifier) self.eventrouter.receive(s) + if self.type == "im": + if "join" in SLACK_API_TRANSLATOR[self.type]: + s = SlackRequest(self.team.token, SLACK_API_TRANSLATOR[self.type]["join"], {"user": self.user, "return_im": "true"}, team_hash=self.team.team_hash, channel_identifier=self.identifier) + self.eventrouter.receive(s) + def destroy_buffer(self, update_remote): if self.channel_buffer is not None: self.channel_buffer = None @@ -2081,20 +2086,26 @@ def handle_rtmstart(login_data, eventrouter): # self.identifier = self.domain def handle_channelsinfo(channel_json, eventrouter, **kwargs): - unread_count_display = channel_json['channel']['unread_count_display'] - channel_id = channel_json['channel']['id'] request_metadata = pickle.loads(channel_json["wee_slack_request_metadata"]) team = eventrouter.teams[request_metadata.team_hash] - channel = team.channels[channel_id] + channel = team.channels[request_metadata.channel_identifier] + unread_count_display = channel_json['channel']['unread_count_display'] channel.set_unread_count_display(unread_count_display) def handle_groupsinfo(group_json, eventrouter, **kwargs): - unread_count_display = group_json['group']['unread_count_display'] - group_id = group_json['group']['id'] request_metadata = pickle.loads(group_json["wee_slack_request_metadata"]) team = eventrouter.teams[request_metadata.team_hash] - group = team.channels[group_id] + group = team.channels[request_metadata.channel_identifier] + unread_count_display = group_json['group']['unread_count_display'] + group_id = group_json['group']['id'] group.set_unread_count_display(unread_count_display) + +def handle_imopen(im_json, eventrouter, **kwargs): + request_metadata = pickle.loads(im_json["wee_slack_request_metadata"]) + team = eventrouter.teams[request_metadata.team_hash] + im = team.channels[request_metadata.channel_identifier] + unread_count_display = im_json['channel']['unread_count_display'] + im.set_unread_count_display(unread_count_display) def handle_groupshistory(message_json, eventrouter, **kwargs): handle_history(message_json, eventrouter, **kwargs) |