mirror of
https://github.com/suitenumerique/people.git
synced 2026-08-17 21:25:52 +02:00
✨(dimail) allow auto-import from dimail
add an automated task automatically importing mailboxes and aliases from dimail
This commit is contained in:
committed by
Marie
parent
eb88229e6a
commit
d83023db33
@@ -33,6 +33,7 @@ and this project adheres to
|
||||
### Added
|
||||
|
||||
- 🧑💻(admin) export domain contact info #1061
|
||||
- ✨(dimail) allow auto-import from dimail
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
@@ -46,6 +46,12 @@ def setup_periodic_tasks(sender: Celery, **kwargs):
|
||||
name="fetch_failed_domains_every_hour",
|
||||
serializer="json",
|
||||
)
|
||||
sender.add_periodic_task(
|
||||
crontab(hour="2", minute="00"), # Run every night at 2 am
|
||||
import_missing_dimail_mailboxes.s(),
|
||||
name="import mailboxes from dimail",
|
||||
serializer="json",
|
||||
)
|
||||
|
||||
|
||||
@celery_app.task
|
||||
@@ -66,3 +72,14 @@ def fetch_domains_status_task(status: str):
|
||||
domain.notify_status_change()
|
||||
changed_domains.append(f"{domain.name} ({domain.status})")
|
||||
return changed_domains
|
||||
|
||||
|
||||
@celery_app.task
|
||||
def import_missing_dimail_mailboxes():
|
||||
"""Celery task to import missing mailboxes from dimail."""
|
||||
client = DimailAPIClient()
|
||||
|
||||
for domain in MailDomain.objects.filter(
|
||||
status=enums.MailDomainStatusChoices.ENABLED
|
||||
):
|
||||
client.import_mailboxes(domain)
|
||||
|
||||
Reference in New Issue
Block a user