From bf7241dd9603cd25b0a1b06c174fe01ccf39acec Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Sat, 15 Jun 2024 10:54:51 -0400 Subject: [PATCH 1/2] fix: detect hidden_by_limit closes 101 --- slack_cleaner2/model.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/slack_cleaner2/model.py b/slack_cleaner2/model.py index 846a7f9..7e42dac 100644 --- a/slack_cleaner2/model.py +++ b/slack_cleaner2/model.py @@ -686,7 +686,7 @@ def __init__(self, entry: JSONDict, slack: "SlackCleaner"): :type slack: SlackCleaner """ self.id = entry["id"] - self.hidden_by_limit = "hidden_by_limit" in entry + self.hidden_by_limit = "hidden_by_limit" in entry or entry.get("mode", "") == "hidden_by_limit" self.name = entry.get("name", "Unknown") self.title = entry.get("title", "Unknown") self.pinned_to = entry.get("pinned_to", False) @@ -698,11 +698,13 @@ def __init__(self, entry: JSONDict, slack: "SlackCleaner"): self._slack = slack @cached_property - def user(self) -> SlackUser: + def user(self) -> Optional[SlackUser]: """ user created this file """ - return self._slack.users.resolve_user(self.json["user"]) + if "user" in self.json: + return self._slack.users.resolve_user(self.json["user"]) + return None @staticmethod def list( From ad9cbeb59faf4d74ab466dbb424cd50e89a06c1d Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Sat, 15 Jun 2024 10:57:15 -0400 Subject: [PATCH 2/2] fix: mypy warning --- slack_cleaner2/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slack_cleaner2/model.py b/slack_cleaner2/model.py index 7e42dac..6f0c051 100644 --- a/slack_cleaner2/model.py +++ b/slack_cleaner2/model.py @@ -625,7 +625,7 @@ def _context(self) -> str: return str(self.msg) def _delete_impl(self): - return self._slack.call_rate_limited(lambda: self._slack.client.reactions_remove(name=self.name, channel=self.msg.channel.id, timestamp=self.msg.ts)) + return self._slack.call_rate_limited(lambda: self._slack.client.reactions_remove(name=self.name, channel=self.msg.channel.id, timestamp=self.msg.json["ts"])) class SlackFile: