accounts

package
v1.2.59 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: AGPL-3.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Accounts Service

The Accounts Service is part of Lesser's Phase 2.2 API Alignment implementation. It provides comprehensive account and profile management functionality with real-time streaming and ActivityPub federation support.

Features

  • Profile Management: Update display name, bio, avatar, header, and custom fields
  • Privacy Controls: Account locking, discoverability, bot flags, and content sensitivity
  • User Preferences: Timeline order, media expansion, language settings, and more
  • Privacy-Aware Queries: Account retrieval with viewer-based privacy filtering
  • Account Search: Search accounts with suspended account filtering
  • Real-Time Events: Emits streaming events for profile updates and preferences changes
  • ActivityPub Federation: Automatically queues Update activities for profile changes

Core Operations

UpdateProfile

Updates user profile information including display name, bio, images, and custom fields.

cmd := &UpdateProfileCommand{
    Username:    "alice",
    DisplayName: "Alice Smith",
    Bio:         "Software developer and coffee enthusiast",
    Avatar:      "https://example.com/avatars/alice.jpg",
    Header:      "https://example.com/headers/alice-banner.jpg",
    Locked:      false,
    Bot:         false,
    Fields: []ProfileField{
        {Name: "Website", Value: "https://alice.dev"},
        {Name: "Location", Value: "San Francisco, CA"},
    },
    Discoverable: true,
    UpdaterID:    "alice", // Must match Username for authorization
}

result, err := service.UpdateProfile(ctx, cmd)
UpdatePreferences

Updates user preferences for timeline behavior, media handling, and privacy settings.

cmd := &UpdatePreferencesCommand{
    Username:                  "alice",
    Language:                  "en",
    DefaultPostingVisibility:  "public",
    DefaultMediaSensitive:     false,
    ExpandSpoilers:            true,
    ExpandMedia:               "default",
    AutoplayGifs:              true,
    ShowFollowCounts:          true,
    PreferredTimelineOrder:    "newest",
    SearchSuggestionsEnabled:  true,
    PersonalizedSearchEnabled: true,
    UpdaterID:                 "alice",
}

result, err := service.UpdatePreferences(ctx, cmd)
GetAccount

Retrieves account information with privacy filtering based on the viewer.

query := &GetAccountQuery{
    Username: "alice",
    ViewerID: "bob", // Optional - affects privacy filtering
}

account, err := service.GetAccount(ctx, query)
SearchAccounts

Searches for accounts with filtering and privacy controls.

query := &SearchAccountsQuery{
    Query:      "alice",
    ViewerID:   "bob",
    Pagination: interfaces.PaginationOptions{Limit: 20},
    Resolve:    false, // Don't resolve remote accounts
}

result, err := service.SearchAccounts(ctx, query)

Event Emission

The service emits streaming events for real-time updates:

Profile Updates
  • Event Type: account.updated
  • Streams: User's own stream (user:username) and followers stream (followers:username)
  • Federation: Queues ActivityPub Update activity
Preference Updates
  • Event Type: preferences.updated
  • Streams: User's own stream only (user:username)
  • Federation: None (preferences are local only)

Privacy and Security

Authorization
  • Profile updates require UpdaterID to match the account username
  • Preference updates require UpdaterID to match the account username
  • No admin override functionality (implement separately if needed)
Privacy Filtering
  • Suspended accounts are hidden from other users
  • Email addresses are never exposed to other users
  • Account information is sanitized based on viewer relationship
Validation
  • Display name limited to 100 characters
  • Bio limited to 5,000 characters
  • Maximum 4 custom profile fields
  • Field names and values limited to 255 characters each
  • Posting visibility must be valid (public, unlisted, private)

Dependencies

  • AccountRepository: For account data persistence
  • Publisher: For real-time event streaming
  • FederationService: For ActivityPub federation (optional)
  • Logger: For structured logging

Integration Example

// Create the service
service := accounts.NewService(
    accountRepository,
    streamingPublisher,
    federationService,
    logger,
    "example.com", // domain name
)

// Update a user's profile
cmd := &accounts.UpdateProfileCommand{
    Username:    "alice",
    DisplayName: "Alice Smith",
    Bio:         "Updated bio",
    UpdaterID:   "alice",
}

result, err := service.UpdateProfile(ctx, cmd)
if err != nil {
    return err
}

// Result contains the updated account and emitted events
fmt.Printf("Updated account: %s\n", result.Account.User.DisplayName)
fmt.Printf("Events emitted: %d\n", len(result.Events))

Testing

The service includes comprehensive tests covering:

  • Successful operations
  • Validation failures
  • Authorization checks
  • Privacy filtering
  • Event emission
  • Error handling

Run tests with:

go test ./pkg/services/accounts/... -v

ActivityPub Compatibility

Profile updates are automatically federated using ActivityPub Update activities:

  • Bot status is mapped to ActivityPub Actor Type (Person or Service)
  • Profile fields are stored as PropertyValue attachments
  • Profile images use standard ActivityPub icon and image properties
  • Update activities are sent to followers' inboxes

Documentation

Overview

Package accounts provides the core Accounts Service for the Lesser project's API alignment. This service handles all account/user profile operations including profile updates, preferences management, and account discovery. It emits appropriate events for real-time streaming and queues federation delivery for remote followers.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Input validation errors
	ErrValidationFailed  = errors.New("validation failed")
	ErrEmptySearchQuery  = errors.New("search query cannot be empty")
	ErrUsernameRequired  = errors.New("username is required")
	ErrUpdaterIDRequired = errors.New("updater_id is required")

	// Account operations
	ErrGetAccount                = errors.New("failed to get account")
	ErrUpdateProfile             = errors.New("failed to update profile")
	ErrStoreAccount              = errors.New("failed to store account")
	ErrGetPreferences            = errors.New("failed to get preferences")
	ErrUpdatePreferences         = errors.New("failed to update preferences")
	ErrAccountNotFound           = errors.New("account not found")
	ErrSearchAccounts            = errors.New("failed to search accounts")
	ErrProfileFieldNameEmpty     = errors.New("profile field name cannot be empty")
	ErrProfileFieldNameTooLong   = errors.New("profile field name too long (max 255 characters)")
	ErrProfileFieldValueTooLong  = errors.New("profile field value too long (max 255 characters)")
	ErrInvalidExpandMediaSetting = errors.New("invalid expand media setting")
	ErrInvalidTimelineOrder      = errors.New("invalid timeline order")
	ErrAccountNoActivityPubActor = errors.New("account has no ActivityPub actor")

	// Actor operations
	ErrGetActor             = errors.New("failed to get actor")
	ErrGetFollowersAccounts = errors.New("failed to get followers")
	ErrGetFollowingList     = errors.New("failed to get following list")
	ErrGetViewerActor       = errors.New("failed to get viewer actor")
	ErrGetViewerFollowing   = errors.New("failed to get viewer following")

	// Repository availability errors
	ErrRelationshipRepositoryNotAvailable = errors.New("relationship repository not available")
	ErrActorRepositoryNotAvailable        = errors.New("actor repository not available")

	// Account relationships
	ErrTargetAccountNotFound = errors.New("target account not found")
	ErrAccountAlreadyPinned  = errors.New("account already pinned")
	ErrPinAccount            = errors.New("failed to pin account")
	ErrUnpinAccount          = errors.New("failed to unpin account")
	ErrGetAccountPins        = errors.New("failed to get account pins")
	ErrSetAccountNote        = errors.New("failed to set account note")
	ErrRemoveFollower        = errors.New("failed to remove follower")

	// Account creation
	ErrEmailRequired              = errors.New("email is required")
	ErrMustAgreeToTerms           = errors.New("must agree to terms of service")
	ErrUsernameAlreadyTaken       = errors.New("username already taken")
	ErrGenerateKeypair            = errors.New("failed to generate keypair")
	ErrEncodePublicKey            = errors.New("failed to encode public key")
	ErrHashPassword               = errors.New("failed to hash password")
	ErrCreateAccount              = errors.New("failed to create account")
	ErrCryptoServiceNotConfigured = errors.New("crypto service not configured")
	ErrAuthServiceNotConfigured   = errors.New("auth service not configured")
	ErrStorageNotAvailable        = errors.New("storage not available")

	// User operations
	ErrCheckAccountPinned                = errors.New("failed to check if account is pinned")
	ErrGetUser                           = errors.New("failed to get user")
	ErrGetUserPreferences                = errors.New("failed to get user preferences")
	ErrCheckDomainBlockedByUser          = errors.New("failed to check if domain is blocked by user")
	ErrGetFieldVerification              = errors.New("failed to get field verification")
	ErrGetAccountNote                    = errors.New("failed to get account note")
	ErrUserRepositoryNotAvailable        = errors.New("user repository not available")
	ErrDomainBlockRepositoryNotAvailable = errors.New("domain block repository not available")
	ErrAccountRepositoryNotAvailable     = errors.New("account repository not available")

	// Permission errors
	ErrCannotUpdateProfileForOtherUser     = errors.New("cannot update profile for another user")
	ErrCannotUpdatePreferencesForOtherUser = errors.New("cannot update preferences for another user")
	ErrCannotPinAccountForOtherUser        = errors.New("cannot pin account for another user")
	ErrCannotUnpinAccountForOtherUser      = errors.New("cannot unpin account for another user")
	ErrCannotSetNoteForOtherUser           = errors.New("cannot set note for another user")
	ErrCannotRemoveFollowerForOtherUser    = errors.New("cannot remove follower for another user")

	// Quote permissions errors
	ErrQuoteRepositoryNotAvailable = errors.New("quote repository not available")
)

Standardized error constants for account operations These align with the constants in pkg/services/errors.go

Functions

This section is empty.

Types

type AccountPinsResult

type AccountPinsResult struct {
	PinnedAccounts []*storage.Account `json:"pinned_accounts"`
	Events         []*streaming.Event `json:"events"`
}

AccountPinsResult contains pinned accounts (endorsements) and events

type AccountResult

type AccountResult struct {
	Account *storage.Account   `json:"account"`
	Events  []*streaming.Event `json:"events"`
}

AccountResult contains an account and associated events that were emitted

type AccountSearchResult

type AccountSearchResult struct {
	Accounts   []*storage.Account                            `json:"accounts"`
	Pagination *interfaces.PaginatedResult[*storage.Account] `json:"pagination"`
	Events     []*streaming.Event                            `json:"events"`
}

AccountSearchResult contains search results and pagination information

type ActivityPubCollectionResult

type ActivityPubCollectionResult struct {
	Collection map[string]any     `json:"collection"`
	Events     []*streaming.Event `json:"events"`
}

ActivityPubCollectionResult contains ActivityPub collection data

type AuthService

type AuthService interface {
	HashPassword(password string) (string, error)
	ValidatePassword(password, username string) error
	PasswordStrength(password string) int
}

AuthService defines the interface for authentication operations

type CreateAuthorizationCodeCommand

type CreateAuthorizationCodeCommand struct {
	AuthCode *storage.AuthorizationCode
}

CreateAuthorizationCodeCommand contains parameters for creating an authorization code

type CreateAuthorizationCodeResult

type CreateAuthorizationCodeResult struct {
	Events []*streaming.Event
}

CreateAuthorizationCodeResult contains the result of creating an authorization code

type CryptoService

type CryptoService interface {
	GenerateRSAKeyPair(bits int) (interface{}, error)
	EncodePublicKeyPEM(publicKey interface{}) ([]byte, error)
	EncodePrivateKeyPEM(privateKey interface{}) ([]byte, error)
}

CryptoService defines the interface for cryptographic operations

type FamiliarFollowersForAccount

type FamiliarFollowersForAccount struct {
	ID       string             `json:"id"`
	Accounts []*storage.Account `json:"accounts"`
}

FamiliarFollowersForAccount represents mutual connections for a specific account

type FamiliarFollowersResult

type FamiliarFollowersResult struct {
	Results []FamiliarFollowersForAccount `json:"results"`
	Events  []*streaming.Event            `json:"events"`
}

FamiliarFollowersResult contains mutual connections grouped by account

type FederationService

type FederationService interface {
	QueueActivity(ctx context.Context, activity *activitypub.Activity) error
}

FederationService defines the interface for federation operations

type FollowersResult

type FollowersResult struct {
	Followers  []*storage.Account                            `json:"followers"`
	Pagination *interfaces.PaginatedResult[*storage.Account] `json:"pagination"`
	Events     []*streaming.Event                            `json:"events"`
}

FollowersResult contains followers list and pagination

type FollowingResult

type FollowingResult struct {
	Following  []*storage.Account                            `json:"following"`
	Pagination *interfaces.PaginatedResult[*storage.Account] `json:"pagination"`
	Events     []*streaming.Event                            `json:"events"`
}

FollowingResult contains following list and pagination

type GetAccountMetadataQuery

type GetAccountMetadataQuery struct {
	Username string `json:"username" validate:"required"`
}

GetAccountMetadataQuery represents a request to get account metadata

type GetAccountMetadataResult

type GetAccountMetadataResult struct {
	Actor    *activitypub.Actor     `json:"actor"`
	Metadata *storage.ActorMetadata `json:"metadata"`
}

GetAccountMetadataResult represents account metadata

type GetAccountNoteQuery

type GetAccountNoteQuery struct {
	CurrentUsername string `json:"current_username" validate:"required"`
	TargetActorID   string `json:"target_actor_id" validate:"required"`
}

GetAccountNoteQuery represents a request to get an account note

type GetAccountNoteResult

type GetAccountNoteResult struct {
	Note   string             `json:"note"`
	Events []*streaming.Event `json:"events"`
}

GetAccountNoteResult contains the note and events

type GetAccountPinsQuery

type GetAccountPinsQuery struct {
	Username string `json:"username" validate:"required"`
}

GetAccountPinsQuery contains data needed to get account pins (endorsed accounts)

type GetAccountQuery

type GetAccountQuery struct {
	Username string `json:"username" validate:"required"`
	ViewerID string `json:"viewer_id"` // User requesting the account (for privacy checks)
}

GetAccountQuery contains parameters for retrieving a single account

type GetActivityPubCollectionQuery

type GetActivityPubCollectionQuery struct {
	Username       string `json:"username" validate:"required"`
	CollectionType string `json:"collection_type" validate:"required,oneof=followers following"`
	ViewerID       string `json:"viewer_id"`
	Page           bool   `json:"page"`
	Cursor         string `json:"cursor"`
	Limit          int    `json:"limit"`
}

GetActivityPubCollectionQuery contains parameters for ActivityPub collection requests

type GetFamiliarFollowersQuery

type GetFamiliarFollowersQuery struct {
	AccountIDs []string `json:"account_ids" validate:"required,min=1"`
	ViewerID   string   `json:"viewer_id" validate:"required"`
}

GetFamiliarFollowersQuery contains parameters for finding mutual connections

type GetFieldVerificationQuery

type GetFieldVerificationQuery struct {
	Username  string `json:"username" validate:"required"`
	FieldName string `json:"field_name" validate:"required"`
}

GetFieldVerificationQuery represents a request to get field verification

type GetFieldVerificationResult

type GetFieldVerificationResult struct {
	Field  *storage.ActorField `json:"field"`
	Events []*streaming.Event  `json:"events"`
}

GetFieldVerificationResult contains the verification status and events

type GetFollowRequestStateQuery

type GetFollowRequestStateQuery struct {
	RequesterID string `json:"requester_id" validate:"required"`
	TargetID    string `json:"target_id" validate:"required"`
}

GetFollowRequestStateQuery represents a request to get follow request state

type GetFollowRequestStateResult

type GetFollowRequestStateResult struct {
	State  string             `json:"state"`
	Events []*streaming.Event `json:"events"`
}

GetFollowRequestStateResult contains the state and events

type GetFollowersQuery

type GetFollowersQuery struct {
	Username   string                       `json:"username" validate:"required"`
	ViewerID   string                       `json:"viewer_id"` // User viewing the followers
	Pagination interfaces.PaginationOptions `json:"pagination"`
}

GetFollowersQuery contains parameters for retrieving account followers

type GetFollowingQuery

type GetFollowingQuery struct {
	Username   string                       `json:"username" validate:"required"`
	ViewerID   string                       `json:"viewer_id"` // User viewing the following
	Pagination interfaces.PaginationOptions `json:"pagination"`
}

GetFollowingQuery contains parameters for retrieving accounts being followed

type GetInstanceStatsQuery

type GetInstanceStatsQuery struct{}

GetInstanceStatsQuery contains parameters for getting instance statistics

type GetInstanceStatsResult

type GetInstanceStatsResult struct {
	TotalUsers     int
	ActiveMonth    int
	ActiveHalfyear int
	LocalPosts     int
	LocalComments  int
	Events         []*streaming.Event
}

GetInstanceStatsResult contains instance statistics

type GetMarkersQuery

type GetMarkersQuery struct {
	Username  string
	Timelines []string // Optional filter for specific timelines
}

GetMarkersQuery contains parameters for getting markers

type GetMarkersResult

type GetMarkersResult struct {
	Markers map[string]*storage.Marker
	Events  []*streaming.Event
}

GetMarkersResult contains the result of getting markers

type GetOAuthAppQuery

type GetOAuthAppQuery struct {
	ClientID string
}

GetOAuthAppQuery contains parameters for getting an OAuth app

type GetOAuthAppResult

type GetOAuthAppResult struct {
	App    *storage.OAuthApp
	Events []*streaming.Event
}

GetOAuthAppResult contains the result of getting an OAuth app

type GetPreferenceQuery

type GetPreferenceQuery struct {
	UserID string `json:"user_id" validate:"required"`
	Key    string `json:"key" validate:"required"`
}

GetPreferenceQuery represents a request to get a user preference

type GetPreferenceResult

type GetPreferenceResult struct {
	Value  string             `json:"value"`
	Events []*streaming.Event `json:"events"`
}

GetPreferenceResult contains the preference value and events

type GetPreferencesQuery

type GetPreferencesQuery struct {
	Username string `json:"username" validate:"required"`
}

GetPreferencesQuery contains parameters for retrieving user preferences

type GetUserAppConsentQuery

type GetUserAppConsentQuery struct {
	Username string
	ClientID string
	Resource string
}

GetUserAppConsentQuery contains parameters for checking user consent

type GetUserAppConsentResult

type GetUserAppConsentResult struct {
	Consent *storage.UserAppConsent
	Events  []*streaming.Event
}

GetUserAppConsentResult contains the result of checking user consent

type GetUserQuery

type GetUserQuery struct {
	Username string `json:"username" validate:"required"`
}

GetUserQuery represents a request to get a user by username

type GetUserResult

type GetUserResult struct {
	User   *storage.User      `json:"user"`
	Events []*streaming.Event `json:"events"`
}

GetUserResult contains the user and events

type IsAccountPinnedQuery

type IsAccountPinnedQuery struct {
	UserID        string `json:"user_id" validate:"required"`
	PinnedActorID string `json:"pinned_actor_id" validate:"required"`
}

IsAccountPinnedQuery represents a request to check if an account is pinned

type IsBlockedDomainQuery

type IsBlockedDomainQuery struct {
	UserID       string `json:"user_id" validate:"required"`
	TargetDomain string `json:"target_domain" validate:"required"`
}

IsBlockedDomainQuery represents a request to check if a domain is blocked

type IsBlockedDomainResult

type IsBlockedDomainResult struct {
	IsBlocked bool               `json:"is_blocked"`
	Events    []*streaming.Event `json:"events"`
}

IsBlockedDomainResult contains the blocked status and events

type LookupAccountQuery

type LookupAccountQuery struct {
	Acct     string `json:"acct" validate:"required"` // username@domain format
	ViewerID string `json:"viewer_id"`                // User performing the lookup
}

LookupAccountQuery contains parameters for looking up an account by username@domain

type PinAccountCommand

type PinAccountCommand struct {
	Username      string `json:"username" validate:"required"`
	TargetAccount string `json:"target_account" validate:"required"`
	PinnerID      string `json:"pinner_id" validate:"required"`
}

PinAccountCommand contains data needed to pin an account to user's profile

type PreferencesResult

type PreferencesResult struct {
	Preferences map[string]interface{} `json:"preferences"`
	Events      []*streaming.Event     `json:"events"`
}

PreferencesResult contains user preferences and any events

type ProfileField

type ProfileField struct {
	Name       string     `json:"name" validate:"required,max=255"`
	Value      string     `json:"value" validate:"required,max=255"`
	VerifiedAt *time.Time `json:"verified_at,omitempty"`
}

ProfileField represents a custom profile field

type RegisterAccountCommand

type RegisterAccountCommand struct {
	Username                 string `json:"username" validate:"required,min=3,max=30"`
	Email                    string `json:"email" validate:"required,email"`
	Password                 string `json:"password"` // Optional for WebAuthn registration
	Locale                   string `json:"locale"`
	Agreement                bool   `json:"agreement" validate:"required"`
	Reason                   string `json:"reason"` // Registration reason (for approval)
	InviteCode               string `json:"invite_code"`
	DefaultPostingVisibility string `json:"default_posting_visibility"`

	// RegistrationChallengeID is a registration-time proof reference (e.g. wallet challenge ID).
	// Successful registration binds that proof to the typed wallet challenge row.
	RegistrationChallengeID string `json:"registration_challenge_id,omitempty"`
}

RegisterAccountCommand contains all data needed to register a new account

type RegisterAccountResult

type RegisterAccountResult struct {
	Account *storage.Account   `json:"account"`
	Actor   *activitypub.Actor `json:"actor"`
	Events  []*streaming.Event `json:"events"`
}

RegisterAccountResult contains the result of account registration

type RelationshipResult

type RelationshipResult struct {
	Relationship map[string]any     `json:"relationship"`
	Events       []*streaming.Event `json:"events"`
}

RelationshipResult contains relationship status between accounts

type RemoveFollowerCommand

type RemoveFollowerCommand struct {
	Username   string `json:"username" validate:"required"`
	FollowerID string `json:"follower_id" validate:"required"`
	RemoverID  string `json:"remover_id" validate:"required"`
}

RemoveFollowerCommand contains data needed to remove a follower

type SaveMarkerCommand

type SaveMarkerCommand struct {
	Username   string
	Timeline   string
	LastReadID string
	Version    int
}

SaveMarkerCommand contains parameters for saving a marker

type SaveMarkerResult

type SaveMarkerResult struct {
	Events []*streaming.Event
}

SaveMarkerResult contains the result of saving a marker

type SearchAccountsQuery

type SearchAccountsQuery struct {
	Query      string                       `json:"query" validate:"required"`
	ViewerID   string                       `json:"viewer_id"` // User performing the search
	Pagination interfaces.PaginationOptions `json:"pagination"`
	Resolve    bool                         `json:"resolve"`   // Resolve remote accounts
	Following  bool                         `json:"following"` // Only search following
	Followers  bool                         `json:"followers"` // Only search followers
}

SearchAccountsQuery contains parameters for searching accounts

type Service

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

Service provides account operations

func NewService

func NewService(
	storage core.RepositoryStorage,
	publisher streaming.Publisher,
	federation FederationService,
	crypto CryptoService,
	auth AuthService,
	logger *zap.Logger,
	domainName string,
) *Service

NewService creates a new Accounts Service with the required dependencies

func (*Service) CreateAuthorizationCode

CreateAuthorizationCode creates a new authorization code

func (*Service) GetAccount

func (s *Service) GetAccount(ctx context.Context, username string) (*storage.Account, error)

GetAccount retrieves a single account with privacy-aware data

func (*Service) GetAccountMetadata

func (s *Service) GetAccountMetadata(ctx context.Context, query *GetAccountMetadataQuery) (*GetAccountMetadataResult, error)

GetAccountMetadata retrieves an account with its metadata

func (*Service) GetAccountNote

func (s *Service) GetAccountNote(ctx context.Context, currentUsername, targetActorID string) (string, error)

GetAccountNote retrieves a private note set on an account

func (*Service) GetAccountPins

func (s *Service) GetAccountPins(ctx context.Context, query *GetAccountPinsQuery) (*AccountPinsResult, error)

GetAccountPins retrieves all accounts pinned by a user (endorsements)

func (*Service) GetActivityPubCollection

func (s *Service) GetActivityPubCollection(ctx context.Context, query *GetActivityPubCollectionQuery) (*ActivityPubCollectionResult, error)

GetActivityPubCollection handles ActivityPub collection requests with proper format

func (*Service) GetAgentGovernanceState added in v1.1.75

func (s *Service) GetAgentGovernanceState(ctx context.Context, username string) (*storage.AgentGovernanceState, error)

GetAgentGovernanceState loads typed governance state for an agent account.

func (*Service) GetAgentGovernanceStatesByUsernames added in v1.1.75

func (s *Service) GetAgentGovernanceStatesByUsernames(ctx context.Context, usernames []string) (map[string]*storage.AgentGovernanceState, error)

GetAgentGovernanceStatesByUsernames batch-loads typed governance state for agent accounts.

func (*Service) GetFamiliarFollowers

func (s *Service) GetFamiliarFollowers(ctx context.Context, query *GetFamiliarFollowersQuery) (*FamiliarFollowersResult, error)

GetFamiliarFollowers returns accounts that the requesting user follows and who also follow the given accounts

func (*Service) GetFieldVerification

func (s *Service) GetFieldVerification(ctx context.Context, username, fieldName string) (*storage.ActorField, error)

GetFieldVerification retrieves field verification information

func (*Service) GetFollowRequestState

func (s *Service) GetFollowRequestState(ctx context.Context, requesterID, targetID string) (string, error)

GetFollowRequestState retrieves the state of a follow request

func (*Service) GetFollowers

func (s *Service) GetFollowers(ctx context.Context, query *GetFollowersQuery) (*FollowersResult, error)

GetFollowers retrieves the list of accounts following the given account

func (*Service) GetFollowing

func (s *Service) GetFollowing(ctx context.Context, query *GetFollowingQuery) (*FollowingResult, error)

GetFollowing retrieves the list of accounts the given account is following

func (*Service) GetInstanceStats

func (s *Service) GetInstanceStats(ctx context.Context, _ *GetInstanceStatsQuery) (*GetInstanceStatsResult, error)

GetInstanceStats retrieves instance-level statistics

func (*Service) GetMarkers

func (s *Service) GetMarkers(ctx context.Context, query *GetMarkersQuery) (*GetMarkersResult, error)

GetMarkers retrieves timeline markers for a user

func (*Service) GetOAuthApp

func (s *Service) GetOAuthApp(ctx context.Context, query *GetOAuthAppQuery) (*GetOAuthAppResult, error)

GetOAuthApp retrieves an OAuth application by client ID

func (*Service) GetPreference

func (s *Service) GetPreference(ctx context.Context, userID, key string) (string, error)

GetPreference retrieves a user preference value

func (*Service) GetPreferences

func (s *Service) GetPreferences(ctx context.Context, query *GetPreferencesQuery) (*PreferencesResult, error)

GetPreferences retrieves user preferences

func (*Service) GetUser

func (s *Service) GetUser(ctx context.Context, username string) (*storage.User, error)

GetUser retrieves a user by username

func (*Service) GetUserAppConsent

func (s *Service) GetUserAppConsent(ctx context.Context, query *GetUserAppConsentQuery) (*GetUserAppConsentResult, error)

GetUserAppConsent retrieves user's consent for an OAuth app

func (*Service) IsAccountPinned

func (s *Service) IsAccountPinned(ctx context.Context, userID, pinnedActorID string) (bool, error)

IsAccountPinned checks if a user has pinned an account

func (*Service) IsBlockedDomain

func (s *Service) IsBlockedDomain(ctx context.Context, userID, targetDomain string) (bool, error)

IsBlockedDomain checks if a domain is blocked for a user

func (*Service) LookupAccount

func (s *Service) LookupAccount(ctx context.Context, query *LookupAccountQuery) (*storage.Account, error)

LookupAccount looks up an account by username@domain format

func (*Service) PinAccount

func (s *Service) PinAccount(ctx context.Context, cmd *PinAccountCommand) (*RelationshipResult, error)

PinAccount pins an account to the user's profile

func (*Service) PutAgentGovernanceState added in v1.1.75

func (s *Service) PutAgentGovernanceState(ctx context.Context, state *storage.AgentGovernanceState) error

PutAgentGovernanceState upserts typed governance state for an agent account.

func (*Service) RegisterAccount

func (s *Service) RegisterAccount(ctx context.Context, cmd *RegisterAccountCommand) (*RegisterAccountResult, error)

RegisterAccount creates a new user account with actor

func (*Service) RemoveFollower

func (s *Service) RemoveFollower(ctx context.Context, cmd *RemoveFollowerCommand) (*RelationshipResult, error)

RemoveFollower removes a follower from the current user's followers list

func (*Service) SaveMarker

func (s *Service) SaveMarker(ctx context.Context, cmd *SaveMarkerCommand) (*SaveMarkerResult, error)

SaveMarker saves a timeline marker for a user

func (*Service) SearchAccounts

func (s *Service) SearchAccounts(ctx context.Context, query *SearchAccountsQuery) (*AccountSearchResult, error)

SearchAccounts searches for accounts with filters and privacy checks

func (*Service) SetAccountNote

func (s *Service) SetAccountNote(ctx context.Context, cmd *SetAccountNoteCommand) (*RelationshipResult, error)

SetAccountNote sets a private note on an account

func (*Service) StoreOAuthState

func (s *Service) StoreOAuthState(ctx context.Context, cmd *StoreOAuthStateCommand) (*StoreOAuthStateResult, error)

StoreOAuthState stores OAuth authorization state

func (*Service) UnpinAccount

func (s *Service) UnpinAccount(ctx context.Context, cmd *UnpinAccountCommand) (*RelationshipResult, error)

UnpinAccount unpins an account from the user's profile

func (*Service) UpdatePreferences

func (s *Service) UpdatePreferences(ctx context.Context, cmd *UpdatePreferencesCommand) (*PreferencesResult, error)

UpdatePreferences updates user preferences and emits events (but not federation)

func (*Service) UpdateProfile

func (s *Service) UpdateProfile(ctx context.Context, cmd *UpdateProfileCommand) (*AccountResult, error)

UpdateProfile updates a user's profile, validates input, stores changes, emits events, and queues federation

type SetAccountNoteCommand

type SetAccountNoteCommand struct {
	Username      string `json:"username" validate:"required"`
	TargetAccount string `json:"target_account" validate:"required"`
	Note          string `json:"note" validate:"max=500"`
	SetterID      string `json:"setter_id" validate:"required"`
}

SetAccountNoteCommand contains data needed to set a private note on an account

type StoreOAuthStateCommand

type StoreOAuthStateCommand struct {
	State      string
	OAuthState *storage.OAuthState
}

StoreOAuthStateCommand contains parameters for storing OAuth state

type StoreOAuthStateResult

type StoreOAuthStateResult struct {
	Events []*streaming.Event
}

StoreOAuthStateResult contains the result of storing OAuth state

type UnpinAccountCommand

type UnpinAccountCommand struct {
	Username      string `json:"username" validate:"required"`
	TargetAccount string `json:"target_account" validate:"required"`
	PinnerID      string `json:"pinner_id" validate:"required"`
}

UnpinAccountCommand contains data needed to unpin an account from user's profile

type UpdatePreferencesCommand

type UpdatePreferencesCommand struct {
	Username                  string          `json:"username" validate:"required"`
	Language                  string          `json:"language"`
	DefaultPostingVisibility  string          `json:"default_posting_visibility" validate:"oneof=public unlisted private direct"`
	DefaultMediaSensitive     bool            `json:"default_media_sensitive"`
	DirectMessagesFrom        string          `json:"direct_messages_from" validate:"oneof=FOLLOWING_ONLY ANYONE"`
	ExpandSpoilers            bool            `json:"expand_spoilers"`
	ExpandMedia               string          `json:"expand_media" validate:"oneof=default show_all hide_all"`
	AutoplayGifs              bool            `json:"autoplay_gifs"`
	ShowFollowCounts          bool            `json:"show_follow_counts"`
	PreferredTimelineOrder    string          `json:"preferred_timeline_order" validate:"oneof=newest oldest"`
	SearchSuggestionsEnabled  bool            `json:"search_suggestions_enabled"`
	PersonalizedSearchEnabled bool            `json:"personalized_search_enabled"`
	ReblogFilters             map[string]bool `json:"reblog_filters"`
	UpdaterID                 string          `json:"updater_id" validate:"required"` // Must be the account owner
}

UpdatePreferencesCommand contains all data needed to update user preferences

type UpdateProfileCommand

type UpdateProfileCommand struct {
	Username     string         `json:"username" validate:"required"`
	DisplayName  string         `json:"display_name" validate:"max=100"`
	Bio          string         `json:"bio" validate:"max=5000"`
	Avatar       string         `json:"avatar"`                         // URL to avatar image
	Header       string         `json:"header"`                         // URL to header image
	Locked       bool           `json:"locked"`                         // Account locked (requires approval for follows)
	Bot          bool           `json:"bot"`                            // Bot account flag
	Fields       []ProfileField `json:"fields"`                         // Custom profile fields
	Discoverable bool           `json:"discoverable"`                   // Show in directory
	NoIndex      bool           `json:"no_index"`                       // Don't index for search
	Sensitive    bool           `json:"sensitive"`                      // Mark media as sensitive by default
	Language     string         `json:"language"`                       // Default language
	UpdaterID    string         `json:"updater_id" validate:"required"` // Must be the account owner
}

UpdateProfileCommand contains all data needed to update a user's profile

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a validation error

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

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