b54493f785
BE-3 observability: expose the worker's Prometheus metrics on :6060/metrics (apns/fcm/asynq histograms + a new cache_ops_total counter were recorded all along but never scraped — which is why those dashboard panels read empty); add the worker containerPort, the vmagent worker scrape job, and two additive NetworkPolicies. Instrument cache Get/Set hit/miss. BE-2 retention: three periodic Asynq cleanup crons mirroring the reminder-log cleanup — notifications (90d), webhook dedup log (180d), audit_log (365d). BE-1 GDPR data export: POST /api/auth/export/ enqueues a low-priority Asynq job that gathers all of the user's data (owned residences + their tasks/contractors/ documents/share-codes, plus profile/notifications/prefs/push-tokens/subscription/ audit log), zips one JSON file per category, and emails it as an attachment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
58 lines
2.2 KiB
Go
58 lines
2.2 KiB
Go
package jobs
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/treytartt/honeydue-api/internal/models"
|
|
"github.com/treytartt/honeydue-api/internal/repositories"
|
|
"github.com/treytartt/honeydue-api/internal/services"
|
|
)
|
|
|
|
// TaskRepo defines task query operations needed by job handlers.
|
|
type TaskRepo interface {
|
|
GetOverdueTasks(now time.Time, opts repositories.TaskFilterOptions) ([]models.Task, error)
|
|
GetDueSoonTasks(now time.Time, daysThreshold int, opts repositories.TaskFilterOptions) ([]models.Task, error)
|
|
GetActiveTasksForUsers(now time.Time, opts repositories.TaskFilterOptions) ([]models.Task, error)
|
|
}
|
|
|
|
// ResidenceRepo defines residence query operations needed by job handlers.
|
|
type ResidenceRepo interface {
|
|
FindResidenceIDsByUser(userID uint) ([]uint, error)
|
|
}
|
|
|
|
// ReminderRepo defines reminder log operations needed by job handlers.
|
|
type ReminderRepo interface {
|
|
HasSentReminderBatch(keys []repositories.ReminderKey) (map[int]bool, error)
|
|
LogReminder(taskID, userID uint, dueDate time.Time, stage models.ReminderStage, notificationID *uint) (*models.TaskReminderLog, error)
|
|
CleanupOldLogs(daysOld int) (int64, error)
|
|
}
|
|
|
|
// NotificationRepo defines notification preference operations needed by job handlers.
|
|
type NotificationRepo interface {
|
|
FindPreferencesByUser(userID uint) (*models.NotificationPreference, error)
|
|
GetActiveTokensForUser(userID uint) ([]string, []string, error)
|
|
}
|
|
|
|
// NotificationSender creates and sends task notifications.
|
|
type NotificationSender interface {
|
|
CreateAndSendTaskNotification(ctx context.Context, userID uint, notificationType models.NotificationType, task *models.Task) error
|
|
}
|
|
|
|
// PushSender sends push notifications to device tokens.
|
|
type PushSender interface {
|
|
SendToAll(ctx context.Context, iosTokens, androidTokens []string, title, message string, data map[string]string) error
|
|
}
|
|
|
|
// EmailSender sends emails.
|
|
type EmailSender interface {
|
|
SendEmail(to, subject, htmlBody, textBody string) error
|
|
SendEmailWithAttachment(to, subject, htmlBody, textBody string, attachment *services.EmailAttachment) error
|
|
}
|
|
|
|
// OnboardingEmailSender sends onboarding campaign emails.
|
|
type OnboardingEmailSender interface {
|
|
CheckAndSendNoResidenceEmails() (int, error)
|
|
CheckAndSendNoTasksEmails() (int, error)
|
|
}
|