Help us shape the future of Go! Take the 2026 Go Developer Survey

channel

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("not found")
	ErrInvalidInput = errors.New("invalid input")
	ErrForbidden    = errors.New("forbidden")
)

Functions

This section is empty.

Types

type Channel

type Channel struct {
	ID        ID
	NameEnc   string
	CreatedBy user.ID
	CreatedAt time.Time
}

type ID

type ID string

type KeyEnvelope

type KeyEnvelope struct {
	ChannelID       ID
	DeviceID        device.ID
	SenderDeviceID  device.ID
	SenderPublicKey string
	Envelope        string
	CreatedAt       time.Time
}

type Message

type Message struct {
	ID            string
	ChannelID     ID
	SenderID      user.ID
	SenderNameEnc string
	Body          string
	SentAt        time.Time
}

type Repository

type Repository interface {
	CreateChannel(ctx context.Context, ch Channel) error
	GetChannel(ctx context.Context, id ID) (Channel, error)
	ListChannels(ctx context.Context) ([]Channel, error)
	UpdateChannelName(ctx context.Context, id ID, nameEnc string) error
	DeleteChannel(ctx context.Context, id ID) error
	SaveMessage(ctx context.Context, msg Message) error
	ListRecentMessages(ctx context.Context, channelID ID, limit int) ([]Message, error)
	UpsertKeyEnvelope(ctx context.Context, env KeyEnvelope) error
	GetKeyEnvelope(ctx context.Context, channelID ID, deviceID device.ID) (KeyEnvelope, error)
}

type Service

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

func NewService

func NewService(repo Repository, users *user.Service) *Service

func (*Service) CreateChannel

func (s *Service) CreateChannel(ctx context.Context, userID user.ID, nameEnc string) (Channel, error)

func (*Service) DeleteChannel

func (s *Service) DeleteChannel(ctx context.Context, userID user.ID, channelID ID) error

func (*Service) GetChannel

func (s *Service) GetChannel(ctx context.Context, userID user.ID, channelID ID) (Channel, error)

func (*Service) GetKeyEnvelope

func (s *Service) GetKeyEnvelope(ctx context.Context, userID user.ID, channelID ID, deviceID device.ID) (KeyEnvelope, error)

func (*Service) ListChannels

func (s *Service) ListChannels(ctx context.Context, userID user.ID) ([]Channel, error)

func (*Service) ListMessages

func (s *Service) ListMessages(ctx context.Context, userID user.ID, channelID ID, limit int) ([]Message, error)

func (*Service) UpdateChannelName

func (s *Service) UpdateChannelName(ctx context.Context, userID user.ID, channelID ID, nameEnc string) (Channel, error)

func (*Service) UpsertKeyEnvelope

func (s *Service) UpsertKeyEnvelope(ctx context.Context, userID user.ID, env KeyEnvelope) error

Jump to

Keyboard shortcuts

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