dandi / dandi/dandi-archive

Create admin API endpoint(s) for sending out emails

Open
#2,184 1 comment 0 reactions 1 assignee Claimed by @asmacdo View on GitHub
API DX
Dominant language
Python
Stars
26
Forks
21
Avg merge
4d 23h
Merged PRs (30d)
15

Description

We already are sending some emails e.g. when notifying users during registration.

DB has email information for dandiset owners and contacts, and all registered users of the archive.

I think it would make total sense to centralize ability to email DANDI users by use via API, so we could potentially use it in services outside of the dandi-archive, e.g. for admins

- dandi-hub to notify on home directories being reset (https://github.com/dandi/dandi-hub/issues/228) -- so for a specific user
- downtime notifications -- to all registered users
- validation errors reminders -- to corresponding authors of dandisets
- audit summaries -- to corresponding authors of dandisets

there could potentially be use cases even for authenticated users, although not immediately needed

- `dandi-cli reportbug {dandiset_id}` (does not exist but could)

So having endpoint(s) allowing for those above would have been nice IMHO. It could potentially also take care about proper re-formatting of markdown message text into html and txt versions, adding "branded" header/footnotes and other conveniences.

We could have per dandiset endpoint `/dandisets/{dandiset__pk}/contact` and then `/users/contact` with data fields like

- content
- content-encoding (for markdown vs txt vs html)
- subject
- from

Related

- I think it closes https://github.com/dandi/dandi-archive/issues/569

Current functionality which does emailing

```shell
❯ git grep 'def send_'
dandiapi/api/mail.py:def send_ownership_change_emails(dandiset, removed_owners, added_owners):
dandiapi/api/mail.py:def send_registered_notice_email(user: User, socialaccount: SocialAccount):
dandiapi/api/mail.py:def send_new_user_message_email(user: User, socialaccount: SocialAccount):
dandiapi/api/mail.py:def send_approved_user_message(user: User, socialaccount: SocialAccount):
dandiapi/api/mail.py:def send_rejected_user_message(user: User, socialaccount: SocialAccount):
dandiapi/api/mail.py:def send_pending_users_message(users: Iterable[User]):
dandiapi/api/mail.py:def send_dandiset_unembargoed_message(dandiset: Dandiset):
dandiapi/api/mail.py:def send_dandiset_unembargo_failed_message(dandiset: Dandiset):
dandiapi/api/tasks/scheduled.py:def send_pending_users_email() -> None:
```

so the skeleton is already there in https://github.com/dandi/dandi-archive/blob/HEAD/dandiapi/api/mail.py and there is already the [`build_message()`](https://github.com/dandi/dandi-archive/blob/HEAD/dandiapi/api/mail.py#L48) to serve as a starting point!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.