in client/securedrop_client/logic.py [0:0]
def send_reply(self, source_uuid: str, reply_uuid: str, message: str) -> None:
"""
Send a reply to a source.
"""
# If the user account no longer exists, do not send
if not self.authenticated_user:
logger.error(f"Sender of reply {reply_uuid} has been deleted")
return
source = self.session.query(db.Source).filter_by(uuid=source_uuid).one_or_none()
if not source:
logger.error("Cannot send a reply to a source account that has been deleted")
self.update_sources() # Refresh source list to remove deleted source widget
return
# Before we send the reply, add the draft to the database with a PENDING
# reply send status.
reply_status = (
self.session.query(db.ReplySendStatus)
.filter_by(name=db.ReplySendStatusCodes.PENDING.value)
.one()
)
draft_reply = db.DraftReply(
uuid=reply_uuid,
timestamp=datetime.utcnow(),
source_id=source.id,
journalist_id=self.authenticated_user.id,
file_counter=source.interaction_count,
content=message,
send_status_id=reply_status.id,
)
self.session.add(draft_reply)
self.session.commit()
job = SendReplyJob(source_uuid, reply_uuid, message, self.gpg)
job.success_signal.connect(self.on_reply_success)
job.failure_signal.connect(self.on_reply_failure)
self.add_job.emit(job)