api

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(cfg config.Config, version, commit string) error

Types

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

func (*Scheduler) Start

func (sc *Scheduler) Start(ctx context.Context) error

func (*Scheduler) Stop

func (sc *Scheduler) Stop()

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg config.Config, st *store.Store, hub *ws.Hub, telegram TelegramService, logger *slog.Logger, version string) (*Server, error)

func (*Server) ClearTelegram

func (s *Server) ClearTelegram(ctx context.Context, userID string) error

ClearTelegram stops the poller and removes all telegram config for the user.

func (*Server) ConfigureTelegram

func (s *Server) ConfigureTelegram(ctx context.Context, userID, botToken, allowedUserIDs string) (string, error)

ConfigureTelegram validates a bot token, stores it encrypted along with the allowed sender ids, and (re)starts the user's long-poller. It is shared by the JSON API handler and the browser (/account) form so both paths keep encryption and poller lifecycle in one place.

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) Now

func (s *Server) Now() time.Time

func (*Server) TestTelegram

func (s *Server) TestTelegram(ctx context.Context, userID, chatID string) error

TestTelegram sends a test notification to the linked chat.

type TelegramService

type TelegramService interface {
	ValidateToken(ctx context.Context, botToken string) (username string, err error)
	SendTest(ctx context.Context, userID, chatID, text string) error
	SendReminder(ctx context.Context, userID, chatID, text, taskID, buttonLabel string) error
	StartForUser(ctx context.Context, userID string) error
	StopForUser(userID string) error
	StartAll(ctx context.Context) error
	StopAll()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL