search

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package search provides search and discovery services for the Lesser ActivityPub server.

This service handles all operations related to searching and discovering content including: - Account search and suggestions - Content search (statuses, hashtags) - Profile directory browsing - Follow suggestions and recommendations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountResult

type AccountResult struct {
	Actor          *activitypub.Actor `json:"actor"`
	FollowersCount int                `json:"followers_count"`
	FollowingCount int                `json:"following_count"`
	StatusesCount  int                `json:"statuses_count"`
	IsLocal        bool               `json:"is_local"`
	LastStatusAt   string             `json:"last_status_at,omitempty"`
}

AccountResult represents an account in search results

type DirectoryQuery

type DirectoryQuery struct {
	Local  bool   `json:"local"` // Only local accounts
	Order  string `json:"order"` // active, new
	Limit  int    `json:"limit"`
	Offset int    `json:"offset"`
}

DirectoryQuery contains parameters for browsing the profile directory

type DirectoryResult

type DirectoryResult struct {
	Accounts []AccountResult    `json:"accounts"`
	Events   []*streaming.Event `json:"events"`
}

DirectoryResult contains directory listings

type HashtagHistory

type HashtagHistory struct {
	Day      string `json:"day"`
	Uses     int    `json:"uses"`
	Accounts int    `json:"accounts"`
}

HashtagHistory represents hashtag usage statistics

type HashtagResult

type HashtagResult struct {
	Name      string           `json:"name"`
	URL       string           `json:"url"`
	History   []HashtagHistory `json:"history"`
	Following bool             `json:"following"`
}

HashtagResult represents a hashtag in search results

type Query

type Query struct {
	Query             string `json:"query" validate:"required,min=1,max=500"`
	AccountID         string `json:"account_id,omitempty"`
	Type              string `json:"type,omitempty"` // accounts, hashtags, statuses
	Resolve           bool   `json:"resolve"`        // Whether to resolve remote accounts
	Following         bool   `json:"following"`      // Only from accounts the user follows
	ExcludeUnreviewed bool   `json:"exclude_unreviewed"`
	Limit             int    `json:"limit"`
	Offset            int    `json:"offset"`
}

Query contains parameters for searching content

type RemoveSuggestionCommand

type RemoveSuggestionCommand struct {
	Username  string `json:"username" validate:"required"`
	AccountID string `json:"account_id" validate:"required"`
}

RemoveSuggestionCommand contains data to remove a suggestion

type Result

type Result struct {
	Accounts []AccountResult    `json:"accounts"`
	Statuses []StatusResult     `json:"statuses"`
	Hashtags []HashtagResult    `json:"hashtags"`
	Events   []*streaming.Event `json:"events"`
}

Result contains search results

type Service

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

Service provides business logic for search and discovery operations

func NewService

func NewService(
	searchRepo searchRepository,
	actorRepo actorRepository,
	relationshipRepo relationshipRepository,
	statusRepo statusRepository,
	hashtagRepo hashtagRepository,
	publisher streaming.Publisher,
	logger *zap.Logger,
	domain string,
) *Service

NewService creates a new search service

func (*Service) GetDirectory

func (s *Service) GetDirectory(ctx context.Context, query *DirectoryQuery) (*DirectoryResult, error)

GetDirectory retrieves the profile directory

func (*Service) GetSuggestions

func (s *Service) GetSuggestions(ctx context.Context, query *SuggestionsQuery) (*SuggestionsResult, error)

GetSuggestions retrieves follow suggestions for a user

func (*Service) RemoveSuggestion

func (s *Service) RemoveSuggestion(ctx context.Context, cmd *RemoveSuggestionCommand) error

RemoveSuggestion removes an account from suggestions

func (*Service) Search

func (s *Service) Search(ctx context.Context, query *Query) (*Result, error)

Search performs a search across accounts, statuses, and hashtags

type StatusResult

type StatusResult struct {
	Status       interface{} `json:"status"` // Using interface{} as Status type varies
	ReblogsCount int         `json:"reblogs_count"`
	LikesCount   int         `json:"likes_count"`
	RepliesCount int         `json:"replies_count"`
}

StatusResult represents a status in search results

type SuggestionItem

type SuggestionItem struct {
	Account AccountResult `json:"account"`
	Source  string        `json:"source,omitempty"` // For v2: staff, past_interactions, global
}

SuggestionItem represents a single suggestion

type SuggestionsQuery

type SuggestionsQuery struct {
	Username string `json:"username" validate:"required"`
	Limit    int    `json:"limit"`
	Version  int    `json:"version"` // API version (1 or 2)
}

SuggestionsQuery contains parameters for getting follow suggestions

type SuggestionsResult

type SuggestionsResult struct {
	Suggestions []SuggestionItem   `json:"suggestions"`
	Events      []*streaming.Event `json:"events"`
}

SuggestionsResult contains follow suggestions

Jump to

Keyboard shortcuts

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