in client/securedrop_client/gui/widgets.py [0:0]
def add_reply(self, reply: Union[DraftReply, Reply], sender: User, index: int) -> None:
"""
Add a reply from a journalist to the source.
"""
try:
send_status = reply.send_status.name
except AttributeError:
send_status = "SUCCEEDED" # TODO: Add and use success status in db.ReplySendStatusCodes
if (
self.controller.authenticated_user
and self.controller.authenticated_user.id == reply.journalist_id
):
sender_is_current_user = True
else:
sender_is_current_user = False
conversation_item = ReplyWidget(
self.controller,
reply.uuid,
str(reply),
send_status,
self.controller.reply_ready,
self.controller.reply_download_failed,
self.controller.reply_succeeded,
self.controller.reply_failed,
index,
self._scroll.widget().width(),
sender,
sender_is_current_user,
self.controller.authenticated_user,
failed_to_decrypt=getattr(reply, "download_error", None) is not None,
)
# Connect the on_update_authenticated_user pyqtSlot to the update_authenticated_user signal.
self.controller.update_authenticated_user.connect(
conversation_item.on_update_authenticated_user
)
# Retrieve the list of usernames of the users who have seen the reply.
conversation_item.update_seen_by_list(reply.seen_by_list)
self._scroll.add_widget_to_conversation(index, conversation_item, Qt.AlignRight)
self.current_messages[reply.uuid] = conversation_item