severance

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package severance implements the severed relationships service

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSeveranceNotFound is returned when a severed relationship is not found
	ErrSeveranceNotFound = errors.New("severed relationship not found")
	// ErrInvalidSeveranceID is returned when a severance ID is invalid
	ErrInvalidSeveranceID = errors.New("invalid severance ID")
	// ErrReconnectionFailed is returned when reconnection fails
	ErrReconnectionFailed = errors.New("reconnection failed")
)

Functions

This section is empty.

Types

type AffectedRelationship

type AffectedRelationship struct {
	ActorID          string
	ActorHandle      string
	ActorDomain      string
	RelationshipType string
	EstablishedAt    time.Time
	LastInteraction  *time.Time
}

AffectedRelationship represents the service-level affected relationship

type EventPublisher

type EventPublisher interface {
	PublishEvent(ctx context.Context, event *models.StreamingEvent) error
}

EventPublisher defines the interface for publishing streaming events

type FederationService

type FederationService interface {
	CheckInstanceReachability(ctx context.Context, instance string) (bool, error)
}

FederationService defines the interface for federation operations

type GetSeveredRelationshipsFilters

type GetSeveredRelationshipsFilters struct {
	Instance string
	Status   models.SeveranceStatus
	Reason   models.SeveranceReason
}

GetSeveredRelationshipsFilters defines filters for listing severed relationships

type NotificationService

type NotificationService interface {
	NotifySeverance(ctx context.Context, userID string, severanceID string) error
}

NotificationService defines the interface for notification operations

type ReconnectionResult

type ReconnectionResult struct {
	AttemptID    string
	Success      bool
	SuccessCount int
	FailureCount int
	Errors       []string
	CompletedAt  time.Time
}

ReconnectionResult represents the result of a reconnection attempt

type Repository

type Repository interface {
	CreateSeveredRelationship(ctx context.Context, severance *models.SeveredRelationship) error
	GetSeveredRelationship(ctx context.Context, id string) (*models.SeveredRelationship, error)
	ListSeveredRelationships(ctx context.Context, localInstance string, filters repositories.SeveranceFilters, limit int, cursor string) ([]*models.SeveredRelationship, string, error)
	UpdateSeveranceStatus(ctx context.Context, id string, status models.SeveranceStatus) error
	CreateAffectedRelationship(ctx context.Context, affected *models.AffectedRelationship) error
	GetAffectedRelationships(ctx context.Context, severanceID string, limit int, cursor string) ([]*models.AffectedRelationship, string, error)
	CreateReconnectionAttempt(ctx context.Context, attempt *models.SeveranceReconnectionAttempt) error
	UpdateReconnectionAttempt(ctx context.Context, attempt *models.SeveranceReconnectionAttempt) error
	GetReconnectionAttempt(ctx context.Context, severanceID, attemptID string) (*models.SeveranceReconnectionAttempt, error)
	GetReconnectionAttempts(ctx context.Context, severanceID string) ([]*models.SeveranceReconnectionAttempt, error)
}

Repository defines the storage interface for severance operations

type Service

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

Service provides severed relationship operations

func NewService

func NewService(
	severanceRepo Repository,
	federation FederationService,
	notification NotificationService,
	publisher EventPublisher,
	logger *zap.Logger,
	domainName string,
) *Service

NewService creates a new severance service

func (*Service) AcknowledgeSeverance

func (s *Service) AcknowledgeSeverance(ctx context.Context, severanceID, userID string) (*SeveredRelationship, error)

AcknowledgeSeverance marks a severance as acknowledged by a user

func (*Service) AttemptReconnection

func (s *Service) AttemptReconnection(ctx context.Context, severanceID, userID string) (*ReconnectionResult, error)

AttemptReconnection attempts to restore severed relationships

func (*Service) DetectSeverance

func (s *Service) DetectSeverance(ctx context.Context, remoteInstance string, reason models.SeveranceReason, affectedFollowers, affectedFollowing int, details string) (*SeveredRelationship, error)

DetectSeverance creates a new severance record when federation issues are detected

func (*Service) GetAffectedRelationships

func (s *Service) GetAffectedRelationships(ctx context.Context, severanceID string, limit int, cursor string) ([]*AffectedRelationship, string, error)

GetAffectedRelationships retrieves affected relationships for a severance

func (*Service) GetSeveredRelationship

func (s *Service) GetSeveredRelationship(ctx context.Context, id string) (*SeveredRelationship, error)

GetSeveredRelationship retrieves a single severed relationship by ID

func (*Service) GetSeveredRelationships

func (s *Service) GetSeveredRelationships(ctx context.Context, filters GetSeveredRelationshipsFilters, limit int, cursor string) ([]*SeveredRelationship, string, error)

GetSeveredRelationships retrieves severed relationships with filters and pagination

type SeveredRelationship

type SeveredRelationship struct {
	ID                string
	LocalInstance     string
	RemoteInstance    string
	Reason            models.SeveranceReason
	Status            models.SeveranceStatus
	Severity          string
	AffectedFollowers int
	AffectedFollowing int
	DetectedAt        time.Time
	AcknowledgedAt    *time.Time
	Reversible        bool
	Details           string
	AutoDetected      bool
	AdminNotes        string
}

SeveredRelationship represents the service-level severed relationship

Jump to

Keyboard shortcuts

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