Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add safe deletion parity with journalist interface #1263

Merged
merged 2 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions securedrop_client/api_jobs/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,35 @@ def call_api(self, api_client: API, session: Session) -> str:
raise DeleteSourceJobException(error_message, self.uuid)


class DeleteConversationJob(ApiJob):
def __init__(self, uuid: str) -> None:
super().__init__()
self.uuid = uuid

def call_api(self, api_client: API, session: Session) -> str:
"""
Override ApiJob.

Delete a source on the server
"""
try:
api_client.delete_conversation(uuid=self.uuid)
return self.uuid
except (RequestTimeoutError, ServerConnectionError):
raise
except Exception as e:
error_message = "Failed to delete conversation for source {uuid}: {exception}".format(
uuid=self.uuid, exception=repr(e)
)
raise DeleteConversationJobException(error_message, self.uuid)


class DeleteConversationJobException(Exception):
def __init__(self, message: str, source_uuid: str):
super().__init__(message)
self.source_uuid = source_uuid


class DeleteSourceJobException(Exception):
def __init__(self, message: str, source_uuid: str):
super().__init__(message)
Expand Down
2 changes: 1 addition & 1 deletion securedrop_client/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def refresh_current_source_conversation(self):
"""
Update the current conversation if the source collection has changed.
"""
self.main_view.on_source_changed()
self.main_view.refresh_source_conversations()

def show_sources(self, sources: List[Source]):
"""
Expand Down
Loading