Skip to content

Commit

Permalink
Added: support for send_mail method from_user_field (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Oct 3, 2024
1 parent f46dbe7 commit e686c69
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libreforms_fastapi/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,19 @@ def run_event_hooks(
if method == "static":
emails = [target]

if method == "from_user_field":

if target.startswith("__metadata__"):
_username = document['metadata'].get(target[12:], None)
else:
_username = document['data'].get(target, None)

_user = session.query(User).filter_by(username=_username).first()
if not _user:
continue

emails = [_user.email]

elif method == "group":
group = session.query(Group).filter(Group.name == target).one_or_none()

Expand Down

0 comments on commit e686c69

Please sign in to comment.