Fix BASE_URL config loading, add tasks/projects; robust .env path resolution

- Config: try ENV_FILE, .env, ../.env for loading; trim trailing slash from BaseURL
- Log BASE_URL at server startup for verification
- .env.example: document BASE_URL
- Tasks, projects, tags, migrations and related API/handlers

Made-with: Cursor
This commit is contained in:
Michilis
2026-03-09 18:57:51 +00:00
parent 75105b8b46
commit bd24545b7b
61 changed files with 6595 additions and 90 deletions

View File

@@ -46,6 +46,44 @@ func (w *ReminderWorker) HandleReminderTask(ctx context.Context, t *asynq.Task)
return nil
}
func (w *ReminderWorker) HandleTaskReminder(ctx context.Context, t *asynq.Task) error {
var payload TaskReminderPayload
if err := json.Unmarshal(t.Payload(), &payload); err != nil {
return fmt.Errorf("unmarshal task reminder payload: %w", err)
}
task, err := w.queries.GetTaskByID(ctx, repository.GetTaskByIDParams{
ID: utils.ToPgUUID(payload.TaskID),
OwnerID: utils.ToPgUUID(payload.OwnerID),
})
if err != nil {
return fmt.Errorf("get task: %w", err)
}
if task.DeletedAt.Valid {
return nil
}
log.Printf("task reminder triggered: task=%s title=%s", payload.TaskID, task.Title)
return nil
}
func (w *ReminderWorker) HandleRecurringTask(ctx context.Context, t *asynq.Task) error {
var payload RecurringTaskPayload
if err := json.Unmarshal(t.Payload(), &payload); err != nil {
return fmt.Errorf("unmarshal recurring task payload: %w", err)
}
task, err := w.queries.GetTaskByID(ctx, repository.GetTaskByIDParams{
ID: utils.ToPgUUID(payload.TaskID),
OwnerID: utils.ToPgUUID(payload.OwnerID),
})
if err != nil {
return nil
}
if !task.RecurrenceRule.Valid || task.RecurrenceRule.String == "" {
return nil
}
log.Printf("recurring task: task=%s (generation stub)", payload.TaskID)
return nil
}
type SubscriptionSyncWorker struct {
syncer SubscriptionSyncer
}
@@ -82,6 +120,8 @@ func StartWorker(redisAddr string, worker *ReminderWorker, subSyncWorker *Subscr
mux := asynq.NewServeMux()
mux.HandleFunc(TypeReminder, worker.HandleReminderTask)
mux.HandleFunc(TypeTaskReminder, worker.HandleTaskReminder)
mux.HandleFunc(TypeRecurringTask, worker.HandleRecurringTask)
if subSyncWorker != nil {
mux.HandleFunc(TypeSubscriptionSync, subSyncWorker.HandleSubscriptionSync)
}