Add admin endpoints for weekly digest and test email, remove broken scheduler
This commit is contained in:
parent
7cfe936e13
commit
e938b3748c
2 changed files with 50 additions and 14 deletions
|
|
@ -603,3 +603,50 @@ def bulk_import_links(
|
||||||
"updated_performances": updated_performances,
|
"updated_performances": updated_performances,
|
||||||
"errors": errors
|
"errors": errors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ============ EMAIL & NOTIFICATIONS ============
|
||||||
|
|
||||||
|
@router.post("/send-weekly-digest")
|
||||||
|
def trigger_weekly_digest(
|
||||||
|
session: Session = Depends(get_session),
|
||||||
|
_: User = Depends(allow_admin)
|
||||||
|
):
|
||||||
|
"""Manually trigger weekly digest emails (runs automatically every Sunday 9am UTC)"""
|
||||||
|
from services.weekly_digest import send_weekly_digests
|
||||||
|
|
||||||
|
try:
|
||||||
|
send_weekly_digests()
|
||||||
|
return {"message": "Weekly digest emails sent successfully"}
|
||||||
|
except Exception as e:
|
||||||
|
raise HTTPException(status_code=500, detail=f"Failed to send digest: {str(e)}")
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/test-email")
|
||||||
|
def test_email(
|
||||||
|
to_email: str,
|
||||||
|
session: Session = Depends(get_session),
|
||||||
|
_: User = Depends(allow_admin)
|
||||||
|
):
|
||||||
|
"""Send a test email to verify email configuration"""
|
||||||
|
from services.email_service import email_service
|
||||||
|
|
||||||
|
subject = "Elmeg Test Email"
|
||||||
|
html_content = """
|
||||||
|
<html>
|
||||||
|
<body style="font-family: sans-serif; padding: 20px;">
|
||||||
|
<h2>Test Email</h2>
|
||||||
|
<p>This is a test email from Elmeg to verify email configuration.</p>
|
||||||
|
<p>If you received this, SMTP is working correctly!</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
text_content = "This is a test email from Elmeg. If you received this, SMTP is working correctly!"
|
||||||
|
|
||||||
|
success = email_service.send_email(to_email, subject, html_content, text_content)
|
||||||
|
|
||||||
|
if success:
|
||||||
|
return {"message": f"Test email sent to {to_email}"}
|
||||||
|
else:
|
||||||
|
raise HTTPException(status_code=500, detail="Failed to send test email")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,20 +130,9 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- elmeg
|
- elmeg
|
||||||
|
|
||||||
# Weekly digest email scheduler
|
# Note: Weekly digest emails are triggered via admin API: POST /api/admin/send-weekly-digest
|
||||||
scheduler:
|
# Or set up system cron to call: curl -X POST https://elmeg.xyz/api/admin/send-weekly-digest -H "Authorization: Bearer $ADMIN_TOKEN"
|
||||||
image: mcuadros/ofelia:latest
|
|
||||||
command: daemon --docker
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
||||||
labels:
|
|
||||||
# Run weekly digest every Sunday at 9am UTC
|
|
||||||
- "ofelia.job-exec.weekly-digest.schedule=0 9 * * 0"
|
|
||||||
- "ofelia.job-exec.weekly-digest.container=elmeg-demo-backend-1"
|
|
||||||
- "ofelia.job-exec.weekly-digest.command=python services/weekly_digest.py"
|
|
||||||
restart: unless-stopped
|
|
||||||
networks:
|
|
||||||
- elmeg
|
|
||||||
|
|
||||||
umami:
|
umami:
|
||||||
image: ghcr.io/umami-software/umami:postgresql-latest
|
image: ghcr.io/umami-software/umami:postgresql-latest
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue