Skip to content

Commit

Permalink
Combined public and private chan archive
Browse files Browse the repository at this point in the history
  • Loading branch information
Grazfather committed Feb 7, 2021
1 parent 4ce0d16 commit 4b941ff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion handlers/challenge_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def execute(cls, slack_wrapper, args, timestamp, channel_id, user_id, user_is_ad
raise InvalidCommand("This challenge does not exist.")

# Remove the challenge channel and ctf challenge entry
slack_wrapper.archive_private_channel(challenge.channel_id)
slack_wrapper.archive_channel(challenge.channel_id)
remove_challenge_by_channel_id(ChallengeHandler.DB, challenge.channel_id, ctf.channel_id)

# Show confirmation message
Expand Down
4 changes: 2 additions & 2 deletions tests/slackwrapper_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def get_private_channels(self):
"""Fetch all private channels in which the user participates."""
return json.loads(self.get_private_channels_response)

def archive_private_channel(self, channel_id):
"""Archive a private channel"""
def archive_channel(self, channel_id):
"""Archive a public or private channel."""
# TODO: The git handler must be mocked before testing archive command to avoid uploading test cases
pass

Expand Down
9 changes: 2 additions & 7 deletions util/slack_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,8 @@ def get_private_channels(self) -> List[Dict]:

return self.get_channels(types="private_channel")

def archive_private_channel(self, channel_id: str) -> Dict:
"""Archive a private channel"""

return self.client.conversations_archive(channel=channel_id).data

def archive_public_channel(self, channel_id: str) -> Dict:
"""Archive a public channel"""
def archive_channel(self, channel_id: str) -> Dict:
"""Archive a public or private channel."""

return self.client.conversations_archive(channel=channel_id).data

Expand Down

0 comments on commit 4b941ff

Please sign in to comment.