Documentation
¶
Overview ¶
Package hashtags implements the hashtag follow/mute business logic used by GraphQL resolvers.
Index ¶
- Variables
- type ActivityEvent
- type Hashtag
- type HashtagRepository
- type Service
- func (s *Service) FollowHashtag(ctx context.Context, userID, hashtag string, ...) (*Hashtag, error)
- func (s *Service) GetFollowedHashtags(ctx context.Context, userID string, pagination *interfaces.PaginationOptions) ([]*Hashtag, string, error)
- func (s *Service) GetHashtag(ctx context.Context, name, viewerID string) (*Hashtag, error)
- func (s *Service) GetHashtagActivity(ctx context.Context, hashtags []string) (<-chan *ActivityEvent, error)
- func (s *Service) MuteHashtag(ctx context.Context, userID, hashtag string, until *time.Time) (*Hashtag, error)
- func (s *Service) UnfollowHashtag(ctx context.Context, userID, hashtag string) (*Hashtag, error)
Constants ¶
This section is empty.
Variables ¶
var ( // Query errors ErrGetHashtag = errors.New("failed to get hashtag") ErrGetHashtagTimeline = errors.New("failed to get hashtag timeline") ErrGetMultiHashtagTimeline = errors.New("failed to get multi-hashtag timeline") ErrGetHashtagStats = errors.New("failed to get hashtag statistics") ErrCheckFollowingHashtag = errors.New("failed to check if following hashtag") // Mutation errors ErrFollowHashtag = errors.New("failed to follow hashtag") ErrUnfollowHashtag = errors.New("failed to unfollow hashtag") ErrUpdateHashtagNotifications = errors.New("failed to update hashtag notification settings") ErrMuteHashtag = errors.New("failed to mute hashtag") ErrUnmuteHashtag = errors.New("failed to unmute hashtag") // Validation errors ErrHashtagNameRequired = errors.New("hashtag name is required") ErrHashtagNameTooLong = errors.New("hashtag name is too long") ErrInvalidHashtagFormat = errors.New("invalid hashtag format") ErrInvalidMode = errors.New("invalid timeline mode, must be ANY or ALL") // Resource errors ErrHashtagNotFound = errors.New("hashtag not found") ErrHashtagAlreadyFollowed = errors.New("hashtag is already followed") ErrHashtagNotFollowed = errors.New("hashtag is not followed") // Infrastructure errors ErrPublisherNotAvailable = errors.New("publisher not available for hashtag events") )
Error variables for hashtag service operations
Functions ¶
This section is empty.
Types ¶
type ActivityEvent ¶
type ActivityEvent struct {
Hashtag string
StatusID string
ActorID string
Timestamp time.Time
Event *streaming.InternalEvent
}
ActivityEvent represents a hashtag-related streaming event forwarded from the global bus.
type Hashtag ¶
type Hashtag struct {
Name string
URL string
PostCount int
FollowerCount int
TrendingScore float64
Related []string
IsFollowing bool
IsMuted bool
FollowedAt *time.Time
NotificationSettings *storage.HashtagNotificationSettings
Stats *storage.HashtagStats
CreatedAt time.Time
UpdatedAt time.Time
}
Hashtag captures the service-level representation of a hashtag enriched with viewer state.
type HashtagRepository ¶
type HashtagRepository interface {
FollowHashtag(ctx context.Context, userID, hashtag string) error
UnfollowHashtag(ctx context.Context, userID, hashtag string) error
IsFollowingHashtag(ctx context.Context, userID, hashtag string) (bool, error)
GetHashtagInfo(ctx context.Context, hashtag string) (*storage.Hashtag, error)
GetHashtagStats(ctx context.Context, hashtag string) (any, error)
GetHashtagTimelineAdvanced(ctx context.Context, hashtag string, maxID *string, limit int, visibility string) ([]*storage.StatusSearchResult, error)
UpdateHashtagNotificationSettings(ctx context.Context, userID, hashtag string, settings *storage.HashtagNotificationSettings) error
MuteHashtag(ctx context.Context, userID, hashtag string, until *time.Time) error
IsHashtagMuted(ctx context.Context, userID, hashtag string) (bool, error)
GetHashtagNotificationSettings(ctx context.Context, userID, hashtag string) (*storage.HashtagNotificationSettings, error)
}
HashtagRepository defines the storage interface needed by the hashtag service.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service coordinates hashtag follow/mute state with storage repositories and the streaming layer.
func NewService ¶
func NewService( hashtagRepo HashtagRepository, accountRepo interfaces.AccountRepository, objectRepo interfaces.ObjectRepository, publisher streaming.Publisher, logger *zap.Logger, ) *Service
NewService wires repositories and infrastructure needed for the hashtag service.
func (*Service) FollowHashtag ¶
func (s *Service) FollowHashtag(ctx context.Context, userID, hashtag string, settings *storage.HashtagNotificationSettings) (*Hashtag, error)
FollowHashtag creates a follow record, optionally updates notification settings, and emits streaming events.
func (*Service) GetFollowedHashtags ¶
func (s *Service) GetFollowedHashtags( ctx context.Context, userID string, pagination *interfaces.PaginationOptions, ) ([]*Hashtag, string, error)
GetFollowedHashtags returns the viewer's followed hashtags enriched with current metadata.
func (*Service) GetHashtag ¶
GetHashtag loads the latest hashtag metadata plus viewer specific state.
func (*Service) GetHashtagActivity ¶
func (s *Service) GetHashtagActivity(ctx context.Context, hashtags []string) (<-chan *ActivityEvent, error)
GetHashtagActivity subscribes to hashtag-related events via DynamoDB-backed streaming. DEPRECATED: This method uses in-memory EventBus pattern that doesn't work on Lambda. Clients should use GraphQL subscriptions (SubscribeToHashtagActivity) instead, which properly persists subscriptions in DynamoDB and delivers via stream-router.