Open asaunier opened 6 years ago
How it was done in v5:
What has changed:
What we have to do:
Example of third-party script (with DB access) in v6_api: https://github.com/c2corg/v6_api/blob/merge-users/c2corg_api/scripts/users/merge.py
Example of email sending in v6_api (registration and password change emails):
The v6_api app has a built-in email service, defined at https://github.com/c2corg/v6_api/blob/master/c2corg_api/emails/email_service.py
The email service settings (including third-party email service host and API key etc.) are located in https://github.com/c2corg/v6_api/blob/master/common.ini.in#L79-L92
The actual settings values are set by default in https://github.com/c2corg/v6_api/blob/master/config/default#L66-L79 and overridden in demo and prod in the docker-compose.yml
files (eg. the SparkPost data).
Sending emails is then quite easy, eg.:
from c2corg_api.emails.email_service import get_email_service
# ...
email_service = get_email_service(self.request)
# ...
email_service.send_change_email_confirmation(user, link)
See https://github.com/c2corg/v6_api/blob/master/c2corg_api/views/user_account.py#L111 for the actual code.
It would probably be required to create a new method in the EmailService
class like https://github.com/c2corg/v6_api/blob/master/c2corg_api/emails/email_service.py#L86
I need to find out if one should call the email service method for every email address registered to the avalanche forecast reports or if it is possible to send group/batch emails. (edit: see just below for an answer)
v6_api's EmailService is based upon pyramid_mailer
: https://docs.pylonsproject.org/projects/pyramid_mailer/en/latest/
=> it is possible to pass a list of emails as the recipients
property of the Message
object. See https://docs.pylonsproject.org/projects/pyramid_mailer/en/latest/#pyramid_mailer.message.Message
Note that:
Concerning SparkPost, the python client https://github.com/SparkPost/python-sparkpost offers interesting features. For instance:
For the last feature, please note we can already send emails to a list of email addresses using our existing pyramid_mailer
tool: https://docs.pylonsproject.org/projects/pyramid_mailer/en/latest/#pyramid_mailer.message.Message
According to the info above it looks possible to create a python script in the API (a bit like https://github.com/c2corg/v6_api/blob/merge-users/c2corg_api/scripts/users/merge.py) that would:
EmailService
or the SparkPost python client@lbesson What do you think? You could explain how the report importing script is triggered (cron?) and how it figures out when a new report has been published? Does it store reports locally every time it connects to the source website and then compare them to detect new reports?
Number of subscribers per list:
c2corg=# select count(user_subscriber), list_subscriber from sympa.subscriber_table group by list_subscriber;
count | list_subscriber
-------+---------------------
131 | meteofrance-66
161 | meteofrance-64
612 | meteofrance-05
1027 | meteofrance-74
164 | valanghe
83 | lawinen
42 | meteofrance-2b
896 | meteofrance-38
166 | meteofrance-06
134 | meteofrance-31
34 | meteofrance-2a
258 | meteofrance-65
28 | avalanche.en
75 | aran
102 | meteofrance-andorre
176 | meteofrance-04
61 | catalunya
166 | meteofrance-09
853 | meteofrance-73
708 | avalanche
(20 rows)
With Yeti, is this issue still relevant ? Or should it be closed ?
Sympa, the mailing list system we used to send avalanche reports by email can no longer be used.
We need an alternate tool that we coud plug between: