services

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatService

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

func NewChatService

func NewChatService(repo Repository) *ChatService

func (*ChatService) CreateRoom

func (s *ChatService) CreateRoom(ctx context.Context, name string, password *string) (*models.Room, error)

func (*ChatService) GetAllUsers

func (s *ChatService) GetAllUsers(ctx context.Context) ([]models.User, error)

func (*ChatService) GetMessages

func (s *ChatService) GetMessages(ctx context.Context, room string, params MessageQueryParams) ([]models.Message, error)

func (*ChatService) GetRooms

func (s *ChatService) GetRooms(ctx context.Context) ([]models.Room, error)

func (*ChatService) GetUser

func (s *ChatService) GetUser(ctx context.Context, publicKey string) (*models.User, error)

func (*ChatService) GetUserByPublicKey

func (s *ChatService) GetUserByPublicKey(ctx context.Context, publicKey string) (*models.User, error)

func (*ChatService) GetUserWithPostCount

func (s *ChatService) GetUserWithPostCount(ctx context.Context, publicKey string) (*models.UserWithPostCount, error)

func (*ChatService) RegisterUser

func (s *ChatService) RegisterUser(ctx context.Context, publicKey string) (*models.User, error)

func (*ChatService) SearchRooms

func (s *ChatService) SearchRooms(ctx context.Context, query string) ([]models.Room, error)

func (*ChatService) SendMessage

func (s *ChatService) SendMessage(ctx context.Context, room, user, content, signature, pubkey string, timestamp int64) (*models.Message, error)

func (*ChatService) UnverifyUser

func (s *ChatService) UnverifyUser(ctx context.Context, publicKey string) error

func (*ChatService) ValidateRoomPassword

func (s *ChatService) ValidateRoomPassword(ctx context.Context, roomName, password string) error

func (*ChatService) VerifyUser

func (s *ChatService) VerifyUser(ctx context.Context, publicKey string) error

type MessageQueryParams

type MessageQueryParams struct {
	Limit  int        // 0 = default (50)
	Before *time.Time // nil = latest
}

MessageQueryParams controls pagination for GetMessages. Zero values apply defaults: Limit=50, Before=now.

type Repository

type Repository interface {
	SaveMessage(ctx context.Context, room, user, content, signature, pubkey string, timestamp int64) (*models.Message, error)
	GetMessages(ctx context.Context, room string, params MessageQueryParams) ([]models.Message, error)
	GetRooms(ctx context.Context) ([]models.Room, error)
	SearchRooms(ctx context.Context, query string) ([]models.Room, error)
	CreateRoom(ctx context.Context, name string, password *string) (*models.Room, error)
	ValidateRoomPassword(ctx context.Context, roomName, password string) error

	// User management
	RegisterUser(ctx context.Context, publicKey string) (*models.User, error)
	GetUser(ctx context.Context, publicKey string) (*models.User, error)
	GetUserByPublicKey(ctx context.Context, publicKey string) (*models.User, error)
	GetUserWithPostCount(ctx context.Context, publicKey string) (*models.UserWithPostCount, error)
	GetAllUsers(ctx context.Context) ([]models.User, error)
	VerifyUser(ctx context.Context, publicKey string) error
	UnverifyUser(ctx context.Context, publicKey string) error
}

Jump to

Keyboard shortcuts

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