Skip to content

Commit

Permalink
fix: Fix an issue where feedback that shared contact info was not sent
Browse files Browse the repository at this point in the history
Feedback emails are sent in a background task to decrease response latency. Unfortunately, this
means that the SQLAlchemy session is already closed and none of the fields of DatabaseUser can be
resolved. This bug was not found because the error messages are swallowed by the background task.
The bug is fixed by turning the DatabaseUser object into a normal User object before passing it to
the background task.
  • Loading branch information
zusorio committed Oct 15, 2024
1 parent ce0f9de commit 4fba5a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion backend/capellacollab/feedback/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ def submit_feedback(
util.send_feedback_email,
db,
feedback,
feedback_user,
(
users_models.User.model_validate(feedback_user)
if feedback_user
else None
),
user_agent,
logger,
)
6 changes: 3 additions & 3 deletions backend/capellacollab/feedback/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def check_if_feedback_is_allowed(db: orm.Session):

def format_email(
feedback: models.Feedback,
user: users_models.DatabaseUser | None,
user: users_models.User | None,
user_agent: str | None,
) -> email_models.EMailContent:
rating = feedback.rating.value
Expand All @@ -76,7 +76,7 @@ def format_email(

message_list.append("---")
message_list.append(
f"You receive this email because you're registered as feedback recipient in the "
f"You received this email because you're registered as feedback recipient in the "
f"Capella Collaboration Manager ({config.general.scheme}://{config.general.host}:{config.general.port})."
)
message_list.append(
Expand Down Expand Up @@ -105,7 +105,7 @@ def format_email(
def send_feedback_email(
db: orm.Session,
feedback: models.Feedback,
user: users_models.DatabaseUser | None,
user: users_models.User | None,
user_agent: str | None,
logger: logging.LoggerAdapter,
):
Expand Down

0 comments on commit 4fba5a7

Please sign in to comment.