- Priority 1: Test NewSendEmailTask + NewSendPushTask (5 tests) - Priority 2: Test customHTTPErrorHandler — all 15+ branches (21 tests) - Priority 3: Extract Enqueuer interface + payload builders in worker pkg (5 tests) - Priority 4: Extract ClassifyFile/ComputeRelPath in migrate-encrypt (6 tests) - Priority 5: Define Handler interfaces, refactor to accept them, mock-based tests (14 tests) - Fix .gitignore: /worker instead of worker to stop ignoring internal/worker/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
56 lines
2.0 KiB
Go
56 lines
2.0 KiB
Go
package jobs
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/treytartt/honeydue-api/internal/models"
|
|
"github.com/treytartt/honeydue-api/internal/repositories"
|
|
)
|
|
|
|
// 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
|
|
}
|
|
|
|
// OnboardingEmailSender sends onboarding campaign emails.
|
|
type OnboardingEmailSender interface {
|
|
CheckAndSendNoResidenceEmails() (int, error)
|
|
CheckAndSendNoTasksEmails() (int, error)
|
|
}
|