Skip to content

Commit

Permalink
Add safe deletion parity with journalist interface
Browse files Browse the repository at this point in the history
Permit the deletion of a source's conversation items, without deleting
their account.
  • Loading branch information
rmol committed Jul 7, 2021
1 parent 8e6ece0 commit fe91a5d
Show file tree
Hide file tree
Showing 23 changed files with 1,415 additions and 343 deletions.
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

0 comments on commit fe91a5d

Please sign in to comment.