add send email to admin when user upload new entry#79
Conversation
📝 WalkthroughWalkthroughAdds admin email storage and retrieval, CLI support to set/display emails, an SMTP2GO-backed EmailService, and async notification of admins after record creation; includes DB migrations for adding/dropping the email column and index. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Upload Client
participant Handler as RecordHandler
participant Repo as AdminRepository
participant Email as EmailService
participant SMTP as SMTP2GO API
Client->>Handler: CreateRecord (upload)
Handler->>Handler: Validate & store record
Handler->>Handler: Upload file to S3
Handler->>Handler: Spawn goroutine for notifications
Handler->>Repo: GetAllEmails(ctx)
Repo->>Repo: Query admin_orcids for non-empty emails
Repo-->>Handler: []string (emails)
Handler->>Email: SendNewRecordNotification(emails, record, siteURL)
Email->>Email: Build text and HTML bodies
Email->>SMTP: POST /api/email/send (SMTP2GORequest)
SMTP-->>Email: API response
Email-->>Handler: Return success/error
Handler->>Handler: Log result
Handler-->>Client: Return response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
| } | ||
|
|
||
| // GetAllEmails retrieves all admin email addresses (non-null only) | ||
| func (r *PostgresAdminRepository) GetAllEmails(ctx context.Context) ([]string, error) { |
There was a problem hiding this comment.
why is this function repeated from cmd/repositories.go ? Can't we share such code between web and cli?
Closes #70
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.