54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
package schedule
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"velox-bot/internal/db/repos/schedulerepo"
|
|
)
|
|
|
|
type Service struct {
|
|
repo *schedulerepo.Repo
|
|
}
|
|
|
|
func New(repo *schedulerepo.Repo) *Service {
|
|
return &Service{repo: repo}
|
|
}
|
|
|
|
func (s *Service) CreateSchedule(ctx context.Context, guildID, requesterID, inviteeID int64, when time.Time, description string) (int64, error) {
|
|
return s.repo.CreateSchedule(ctx, guildID, requesterID, inviteeID, when, description)
|
|
}
|
|
|
|
func (s *Service) AddMessage(ctx context.Context, scheduleID, messageID, channelID int64, isDM bool) error {
|
|
return s.repo.AddMessage(ctx, scheduleID, messageID, channelID, isDM)
|
|
}
|
|
|
|
func (s *Service) GetByMessageID(ctx context.Context, messageID int64) (*schedulerepo.Schedule, error) {
|
|
return s.repo.GetByMessageID(ctx, messageID)
|
|
}
|
|
|
|
func (s *Service) UpdateStatus(ctx context.Context, scheduleID int64, status schedulerepo.ScheduleStatus) error {
|
|
return s.repo.UpdateStatus(ctx, scheduleID, status)
|
|
}
|
|
|
|
func (s *Service) ListForUser(ctx context.Context, guildID, userID int64, limit int) ([]*schedulerepo.Schedule, error) {
|
|
return s.repo.ListForUser(ctx, guildID, userID, limit)
|
|
}
|
|
|
|
func (s *Service) ListDueForReminder(ctx context.Context, now time.Time, ahead time.Duration) ([]*schedulerepo.Schedule, error) {
|
|
return s.repo.ListDueForReminder(ctx, now, ahead)
|
|
}
|
|
|
|
func (s *Service) MarkReminded(ctx context.Context, scheduleID int64) error {
|
|
return s.repo.MarkReminded(ctx, scheduleID)
|
|
}
|
|
|
|
func (s *Service) GetByID(ctx context.Context, id int64) (*schedulerepo.Schedule, error) {
|
|
return s.repo.GetByID(ctx, id)
|
|
}
|
|
|
|
func (s *Service) Reschedule(ctx context.Context, id int64, when time.Time) error {
|
|
return s.repo.Reschedule(ctx, id, when)
|
|
}
|
|
|