Documentation
¶
Overview ¶
Package lists provides the core Lists Service for the Lesser project's API alignment. This service handles all list operations including creation, management, membership, and timeline generation. It emits appropriate events for real-time streaming.
Index ¶
- type AddToListCommand
- type CreateListCommand
- type DeleteListCommand
- type GetListMembersQuery
- type GetListQuery
- type GetListTimelineQuery
- type ListResult
- type ListUserListsQuery
- type MembersResult
- type MembershipResult
- type RemoveFromListCommand
- type Result
- type Service
- func (s *Service) AddToList(ctx context.Context, cmd *AddToListCommand) (*MembershipResult, error)
- func (s *Service) CreateList(ctx context.Context, cmd *CreateListCommand) (*ListResult, error)
- func (s *Service) DeleteList(ctx context.Context, cmd *DeleteListCommand) error
- func (s *Service) GetList(ctx context.Context, query *GetListQuery) (*models.List, error)
- func (s *Service) GetListMembers(ctx context.Context, query *GetListMembersQuery) (*MembersResult, error)
- func (s *Service) GetListTimeline(ctx context.Context, query *GetListTimelineQuery) (*TimelineResult, error)
- func (s *Service) ListUserLists(ctx context.Context, query *ListUserListsQuery) (*Result, error)
- func (s *Service) RemoveFromList(ctx context.Context, cmd *RemoveFromListCommand) (*MembershipResult, error)
- func (s *Service) UpdateList(ctx context.Context, cmd *UpdateListCommand) (*ListResult, error)
- type TimelineResult
- type UpdateListCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddToListCommand ¶
type AddToListCommand struct {
ListID string `json:"list_id" validate:"required"`
MemberUsername string `json:"member_username" validate:"required"`
AdderID string `json:"adder_id" validate:"required"` // Must be the list owner
}
AddToListCommand contains data needed to add a member to a list
type CreateListCommand ¶
type CreateListCommand struct {
Username string `json:"username" validate:"required"`
Title string `json:"title" validate:"required,min=1,max=100"`
RepliesPolicy string `json:"replies_policy" validate:"oneof=followed list none"`
CreatorID string `json:"creator_id" validate:"required"` // Must be the list owner
}
CreateListCommand contains all data needed to create a new list
type DeleteListCommand ¶
type DeleteListCommand struct {
ListID string `json:"list_id" validate:"required"`
DeleterID string `json:"deleter_id" validate:"required"` // Must be the list owner
}
DeleteListCommand contains data needed to delete a list
type GetListMembersQuery ¶
type GetListMembersQuery struct {
ListID string `json:"list_id" validate:"required"`
ViewerID string `json:"viewer_id" validate:"required"` // Must be list owner
Pagination interfaces.PaginationOptions `json:"pagination"`
}
GetListMembersQuery contains parameters for retrieving list members
type GetListQuery ¶
type GetListQuery struct {
ListID string `json:"list_id" validate:"required"`
ViewerID string `json:"viewer_id"` // User requesting the list (for privacy checks)
}
GetListQuery contains parameters for retrieving a list
type GetListTimelineQuery ¶
type GetListTimelineQuery struct {
ListID string `json:"list_id" validate:"required"`
ViewerID string `json:"viewer_id" validate:"required"` // Must be list owner or member
Pagination interfaces.PaginationOptions `json:"pagination"`
}
GetListTimelineQuery contains parameters for retrieving a list timeline
type ListResult ¶
type ListResult struct {
List *models.List `json:"list"`
Events []*streaming.Event `json:"events"`
}
ListResult contains a list and associated events that were emitted
type ListUserListsQuery ¶
type ListUserListsQuery struct {
Username string `json:"username" validate:"required"`
ViewerID string `json:"viewer_id"` // User requesting the lists
Pagination interfaces.PaginationOptions `json:"pagination"`
}
ListUserListsQuery contains parameters for listing a user's lists
type MembersResult ¶
type MembersResult struct {
Members []*storage.Account `json:"members"`
Pagination *interfaces.PaginatedResult[*storage.Account] `json:"pagination"`
Events []*streaming.Event `json:"events"`
}
MembersResult contains list members with pagination and events
type MembershipResult ¶
type MembershipResult struct {
Success bool `json:"success"`
Events []*streaming.Event `json:"events"`
}
MembershipResult contains membership operation result and events
type RemoveFromListCommand ¶
type RemoveFromListCommand struct {
ListID string `json:"list_id" validate:"required"`
MemberUsername string `json:"member_username" validate:"required"`
RemoverID string `json:"remover_id" validate:"required"` // Must be the list owner
}
RemoveFromListCommand contains data needed to remove a member from a list
type Result ¶
type Result struct {
Lists []*models.List `json:"lists"`
Pagination *interfaces.PaginatedResult[*models.List] `json:"pagination"`
Events []*streaming.Event `json:"events"`
}
Result contains multiple lists with pagination and events
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides list operations
func NewService ¶
func NewService( listRepo interfaces.ListRepository, statusRepo interfaces.StatusRepository, publisher streaming.Publisher, logger *zap.Logger, ) *Service
NewService creates a new Lists Service with the required dependencies
func (*Service) AddToList ¶
func (s *Service) AddToList(ctx context.Context, cmd *AddToListCommand) (*MembershipResult, error)
AddToList adds an account to a list and emits events
func (*Service) CreateList ¶
func (s *Service) CreateList(ctx context.Context, cmd *CreateListCommand) (*ListResult, error)
CreateList creates a new list, validates input, stores it, and emits events
func (*Service) DeleteList ¶
func (s *Service) DeleteList(ctx context.Context, cmd *DeleteListCommand) error
DeleteList deletes a list and emits events
func (*Service) GetListMembers ¶
func (s *Service) GetListMembers(ctx context.Context, query *GetListMembersQuery) (*MembersResult, error)
GetListMembers retrieves all members of a list with pagination
func (*Service) GetListTimeline ¶
func (s *Service) GetListTimeline(ctx context.Context, query *GetListTimelineQuery) (*TimelineResult, error)
GetListTimeline retrieves posts from list members with pagination
func (*Service) ListUserLists ¶
ListUserLists retrieves a user's lists with pagination
func (*Service) RemoveFromList ¶
func (s *Service) RemoveFromList(ctx context.Context, cmd *RemoveFromListCommand) (*MembershipResult, error)
RemoveFromList removes an account from a list and emits events
func (*Service) UpdateList ¶
func (s *Service) UpdateList(ctx context.Context, cmd *UpdateListCommand) (*ListResult, error)
UpdateList updates an existing list and emits events
type TimelineResult ¶
type TimelineResult struct {
Statuses []*models.Status `json:"statuses"`
Pagination *interfaces.PaginatedResult[*models.Status] `json:"pagination"`
Events []*streaming.Event `json:"events"`
}
TimelineResult contains timeline posts with pagination and events
type UpdateListCommand ¶
type UpdateListCommand struct {
ListID string `json:"list_id" validate:"required"`
Title string `json:"title,omitempty" validate:"omitempty,min=1,max=100"`
RepliesPolicy string `json:"replies_policy,omitempty" validate:"omitempty,oneof=followed list none"`
UpdaterID string `json:"updater_id" validate:"required"` // Must be the list owner
}
UpdateListCommand contains data needed to update an existing list