promoted

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("promoted chat not found")
	ErrExists        = errors.New("promoted chat already exists")
	ErrInvalidChatID = errors.New("invalid chat ID")
	ErrInvalidScore  = errors.New("invalid score")
	ErrInvalidTopic  = errors.New("invalid topic")
)

Functions

This section is empty.

Types

type PromotedChat

type PromotedChat struct {
	ChatID    *commonpb.ChatId
	Score     int
	Topic     string
	CreatedAt time.Time
	UpdatedAt time.Time
}

PromotedChat represents a promoted chat entity.

func (*PromotedChat) Clone

func (pc *PromotedChat) Clone() *PromotedChat

Clone creates a deep copy of the PromotedChat.

type Server

type Server struct {
	promotedpb.UnimplementedPromotedServer
	// contains filtered or unexported fields
}

Server implements the Promoted service.

func NewServer

func NewServer(log *zap.Logger, promoted Store, authz auth.Authorizer) *Server

NewServer creates a new Promoted server.

func (*Server) GetPromotedChats

GetPromotedChats handles the GetPromotedChats RPC.

type Store

type Store interface {
	// GetPromotedChats retrieves promoted chats by topic.
	GetPromotedChats(ctx context.Context, topic string) ([]*PromotedChat, error)

	// PromoteChat promotes a chat (or updates the score if it already exists).
	PromoteChat(ctx context.Context, chatID *commonpb.ChatId, topic string, score int) error

	// DemoteChat demotes a chat (remove it from the promoted list for the topic).
	DemoteChat(ctx context.Context, chatID *commonpb.ChatId, topic string) error
}

Store defines the interface for Promoted Chat storage.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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