Skip to content

Commit

Permalink
fix: don't override DraftReply.send_status based on application-level…
Browse files Browse the repository at this point in the history
… state

Since #750, application-level state transitions (logging in, logging
out, and switching into offline mode) call
securedrop_client.storage.mark_all_pending_draft_replies().  However,
one or more SendReplyJobs (and their underlying POSTs requests to
"/sources/<source_uuid/replies") may be in flight on the network at that
time, whether or not the application is connected (or even running) to
receive their responses.  It's up to a given SendReplyJob to raise an
exception if it's failed; the state of a given DraftReply can't be
determined, or meaningfully overriden, by an application-level event.
  • Loading branch information
cfm committed May 10, 2022
1 parent 21e6cd2 commit 3a91f39
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ def login(self, username: str, password: str, totp: str) -> None:
default_request_timeout for Queue API requests in ApiJobQueue in order to display errors
faster.
"""
storage.mark_all_pending_drafts_as_failed(self.session)
self.api = sdclientapi.API(
self.hostname, username, password, totp, self.proxy, default_request_timeout=60
)
Expand Down Expand Up @@ -579,7 +578,6 @@ def login_offline_mode(self) -> None:
# may have attempted online mode login, then switched to offline)
self.gui.clear_clipboard()
self.gui.show_main_window()
storage.mark_all_pending_drafts_as_failed(self.session)
self.update_sources()
self.show_last_sync()
self.show_last_sync_timer.start(TIME_BETWEEN_SHOWING_LAST_SYNC_MS)
Expand Down Expand Up @@ -775,10 +773,6 @@ def logout(self) -> None:

self.invalidate_token()

failed_replies = storage.mark_all_pending_drafts_as_failed(self.session)
for failed_reply in failed_replies:
self.reply_failed.emit(failed_reply.uuid)

self.api_sync.stop()
self.api_job_queue.stop()
self.gui.logout()
Expand Down

0 comments on commit 3a91f39

Please sign in to comment.