notes

package
v1.2.48 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: AGPL-3.0 Imports: 24 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.

Documentation

Overview

Package notes provides the core Notes Service for the Lesser project's API alignment. This service handles all status/post operations including creation, updates, deletion, and timeline operations. It emits appropriate events for real-time streaming and queues federation delivery for remote followers.

Index

Constants

View Source
const (
	// VisibilityPublic represents public visibility
	VisibilityPublic = "public"
)

Variables

View Source
var (
	// Notes validation errors
	// ErrNotesValidationFailed is returned when notes validation fails
	ErrNotesValidationFailed = errors.NewValidationError("notes", "validation failed")

	// ErrGetAuthorAccount is returned when getting author account fails
	ErrGetAuthorAccount = errors.FailedToGet("author account", stdErrors.New("failed to get author account"))

	// ErrCreateStatus is returned when status creation fails
	ErrCreateStatus = errors.FailedToCreate("status", stdErrors.New("failed to create status"))

	// ErrGetStatus is returned when status retrieval fails
	ErrGetStatus = errors.FailedToGet("status", stdErrors.New("failed to get status"))

	// ErrUpdateStatus is returned when status update fails
	ErrUpdateStatus = errors.FailedToUpdate("status", stdErrors.New("failed to update status"))

	// ErrDeleteStatus is returned when status deletion fails
	ErrDeleteStatus = errors.FailedToDelete("status", stdErrors.New("failed to delete status"))

	// ErrStatusNotFound is returned when status is not found
	ErrStatusNotFound = errors.StatusNotFound("")

	// ErrStatusIDRequired is returned when status ID is required but missing
	ErrStatusIDRequired = errors.RequiredFieldMissing("status_id")

	// ErrStatusRepositoryUnavailable is returned when the status repository dependency is missing
	ErrStatusRepositoryUnavailable = errors.RepositoryNotAvailable("status")

	// ErrCheckViewPermissions is returned when checking view permissions fails
	ErrCheckViewPermissions = errors.ProcessingFailed("view permissions check", stdErrors.New("view permissions check failed"))

	// ErrCheckFollowingRelationship is returned when checking following relationship fails
	ErrCheckFollowingRelationship = errors.ProcessingFailed("following relationship check", stdErrors.New("following relationship check failed"))

	// Timeline errors
	// ErrHomeTimelineRequiresViewerID is returned when home timeline requires viewer_id
	ErrHomeTimelineRequiresViewerID = errors.RequiredFieldMissing("viewer_id")

	// ErrUserTimelineRequiresAuthorID is returned when user timeline requires author_id
	ErrUserTimelineRequiresAuthorID = errors.RequiredFieldMissing("author_id")

	// ErrConversationsTimelineRequiresConversationID is returned when conversations timeline requires conversation_id
	ErrConversationsTimelineRequiresConversationID = errors.RequiredFieldMissing("conversation_id")

	// ErrDirectTimelineRequiresViewerID is returned when direct timeline requires viewer_id
	ErrDirectTimelineRequiresViewerID = errors.RequiredFieldMissing("viewer_id")

	// ErrHashtagTimelineRequiresHashtag is returned when hashtag timeline requires hashtag
	ErrHashtagTimelineRequiresHashtag = errors.RequiredFieldMissing("hashtag")

	// ErrListTimelineRequiresListID is returned when list timeline requires list_id
	ErrListTimelineRequiresListID = errors.RequiredFieldMissing("list_id")

	// ErrUnsupportedTimelineType is returned when timeline type is unsupported
	ErrUnsupportedTimelineType = errors.InvalidValue("timeline_type", []string{"home", "user", "conversation", "direct", "hashtag", "list"}, "")

	// ErrGetTimeline is returned when timeline retrieval fails
	ErrGetTimeline = errors.FailedToGet("timeline", stdErrors.New("failed to get timeline"))

	// Content validation errors
	// ErrStatusContentValidationFailed is returned when status content validation fails
	ErrStatusContentValidationFailed = errors.NewValidationError("status_content", "status content validation failed")

	// ErrVisibilityValidationFailed is returned when visibility validation fails
	ErrVisibilityValidationFailed = errors.StatusInvalidVisibility("")

	// ErrSpoilerTextValidationFailed is returned when spoiler text validation fails
	ErrSpoilerTextValidationFailed = errors.StatusSpoilerTextTooLong(0)

	// ErrInvalidInReplyToID is returned when in_reply_to_id is invalid
	ErrInvalidInReplyToID = errors.IDInvalidFormat("in_reply_to_id")

	// ErrContentCannotBeEmpty is returned when content cannot be empty
	ErrContentCannotBeEmpty = errors.ContentEmpty("status")

	// ErrContentTooLong is returned when content is too long
	ErrContentTooLong = errors.ContentTooLong("status", 5000)

	// ErrContentTooLongShort is returned when content is too long for short form
	ErrContentTooLongShort = errors.ContentTooLong("status", 500)

	// Bookmark errors
	// ErrBookmarkStatus is returned when bookmarking status fails
	ErrBookmarkStatus = errors.FailedToCreate("bookmark", stdErrors.New("failed to create bookmark"))

	// ErrUnbookmarkStatus is returned when unbookmarking status fails
	ErrUnbookmarkStatus = errors.FailedToDelete("bookmark", stdErrors.New("failed to delete bookmark"))

	// ErrGetBookmarks is returned when getting bookmarks fails
	ErrGetBookmarks = errors.FailedToGet("bookmarks", stdErrors.New("failed to get bookmarks"))

	// Likes and reblog errors
	// ErrGetLikers is returned when getting likers fails
	ErrGetLikers = errors.FailedToGet("likers", stdErrors.New("failed to get likers"))

	// ErrGetRebloggerAccount is returned when getting reblogger account fails
	ErrGetRebloggerAccount = errors.FailedToGet("reblogger account", stdErrors.New("failed to get reblogger account"))

	// ErrReblogStatus is returned when reblogging status fails
	ErrReblogStatus = errors.FailedToCreate("reblog", stdErrors.New("failed to create reblog"))

	// ErrGetRebloggers is returned when getting rebloggers fails
	ErrGetRebloggers = errors.FailedToGet("rebloggers", stdErrors.New("failed to get rebloggers"))

	// ErrMuteStatus is returned when muting status fails
	ErrMuteStatus = errors.FailedToUpdate("status mute", stdErrors.New("failed to update status mute"))

	// ErrUnmuteStatus is returned when unmuting status fails
	ErrUnmuteStatus = errors.FailedToUpdate("status unmute", stdErrors.New("failed to update status unmute"))

	// ErrCreateLike is returned when creating like fails
	ErrCreateLike = errors.FailedToCreate("like", stdErrors.New("failed to create like"))

	// ErrDeleteLike is returned when deleting like fails
	ErrDeleteLike = errors.FailedToDelete("like", stdErrors.New("failed to delete like"))

	// ErrGetLikes is returned when getting likes fails
	ErrGetLikes = errors.FailedToGet("likes", stdErrors.New("failed to get likes"))

	// ErrCreateReblog is returned when creating reblog fails
	ErrCreateReblog = errors.FailedToCreate("reblog", stdErrors.New("failed to create reblog"))

	// ErrDeleteReblog is returned when deleting reblog fails
	ErrDeleteReblog = errors.FailedToDelete("reblog", stdErrors.New("failed to delete reblog"))

	// ErrGetAnnounces is returned when getting announces fails
	ErrGetAnnounces = errors.FailedToGet("announces", stdErrors.New("failed to get announces"))

	// Pin errors
	// ErrPinStatus is returned when pinning status fails
	ErrPinStatus = errors.FailedToUpdate("status pin", stdErrors.New("failed to update status pin"))

	// ErrUnpinStatus is returned when unpinning status fails
	ErrUnpinStatus = errors.FailedToUpdate("status unpin", stdErrors.New("failed to update status unpin"))

	// Conversation errors
	// ErrConversationServiceNotAvailable is returned when conversation service is not available
	ErrConversationServiceNotAvailable = errors.ServiceNotAvailable("conversation")

	// ErrMuteConversation is returned when muting conversation fails
	ErrMuteConversation = errors.FailedToUpdate("conversation mute", stdErrors.New("failed to update conversation mute"))

	// ErrUnmuteConversation is returned when unmuting conversation fails
	ErrUnmuteConversation = errors.FailedToUpdate("conversation unmute", stdErrors.New("failed to update conversation unmute"))

	// ErrGetConversations is returned when getting conversations fails
	ErrGetConversations = errors.FailedToGet("conversations", stdErrors.New("failed to get conversations"))

	// Favorited timeline errors
	// ErrViewerIDRequiredForFavoritedTimeline is returned when viewer_id is required for favorited timeline
	ErrViewerIDRequiredForFavoritedTimeline = errors.RequiredFieldMissing("viewer_id")

	// ErrGetViewerAccount is returned when getting viewer account fails
	ErrGetViewerAccount = errors.FailedToGet("viewer account", stdErrors.New("failed to get viewer account"))

	// ErrLikeRepositoryNotAvailable is returned when like repository is not available
	ErrLikeRepositoryNotAvailable = errors.ServiceNotAvailable("like repository")

	// ErrGetLikedObjects is returned when getting liked objects fails
	ErrGetLikedObjects = errors.FailedToGet("liked objects", stdErrors.New("failed to get liked objects"))

	// ErrGetStatuses is returned when getting statuses fails
	ErrGetStatuses = errors.FailedToGet("statuses", stdErrors.New("failed to get statuses"))

	// Scheduled status errors
	// ErrCreateScheduledStatus is returned when creating scheduled status fails
	ErrCreateScheduledStatus = errors.FailedToCreate("scheduled status", stdErrors.New("failed to create scheduled status"))

	// ErrScheduledTimeInPast is returned when scheduled time must be in the future
	ErrScheduledTimeInPast = errors.TimestampInFuture()

	// Search errors
	// ErrGetSearchSuggestions is returned when getting search suggestions fails
	ErrGetSearchSuggestions = errors.FailedToGet("search suggestions", stdErrors.New("failed to get search suggestions"))

	// Community notes errors
	// ErrCreateCommunityNote is returned when creating community note fails
	ErrCreateCommunityNote = errors.FailedToCreate("community note", stdErrors.New("failed to create community note"))

	// ErrGetVisibleCommunityNotes is returned when getting visible community notes fails
	ErrGetVisibleCommunityNotes = errors.FailedToGet("visible community notes", stdErrors.New("failed to get visible community notes"))

	// ErrGetCommunityNote is returned when getting community note fails
	ErrGetCommunityNote = errors.FailedToGet("community note", stdErrors.New("failed to get community note"))

	// ErrCreateCommunityNoteVote is returned when creating community note vote fails
	ErrCreateCommunityNoteVote = errors.FailedToCreate("community note vote", stdErrors.New("failed to create community note vote"))

	// ErrGetCommunityNotesByAuthor is returned when getting community notes by author fails
	ErrGetCommunityNotesByAuthor = errors.FailedToGet("community notes by author", stdErrors.New("failed to get community notes by author"))

	// Stats errors
	// ErrCountStatusesByAuthor is returned when counting statuses by author fails
	ErrCountStatusesByAuthor = errors.ProcessingFailed("status count by author", stdErrors.New("failed to count statuses by author"))

	// ErrGetUserTimeline is returned when getting user timeline fails
	ErrGetUserTimeline = errors.FailedToGet("user timeline", stdErrors.New("failed to get user timeline"))

	// ErrCountReplies is returned when counting replies fails
	ErrCountReplies = errors.ProcessingFailed("replies count", stdErrors.New("failed to count replies"))

	// ErrGetBoostCount is returned when getting boost count fails
	ErrGetBoostCount = errors.ProcessingFailed("boost count", stdErrors.New("failed to get boost count"))

	// ErrGetLikeCount is returned when getting like count fails
	ErrGetLikeCount = errors.ProcessingFailed("like count", stdErrors.New("failed to get like count"))

	// ErrCheckUserHasLiked is returned when checking if user has liked fails
	ErrCheckUserHasLiked = errors.ProcessingFailed("user liked check", stdErrors.New("failed to verify if user liked"))

	// ErrCheckUserHasReblogged is returned when checking if user has reblogged fails
	ErrCheckUserHasReblogged = errors.ProcessingFailed("user reblogged check", stdErrors.New("failed to verify if user reblogged"))

	// ErrCheckUserHasBookmarked is returned when checking if user has bookmarked fails
	ErrCheckUserHasBookmarked = errors.ProcessingFailed("user bookmarked check", stdErrors.New("failed to verify if user bookmarked"))

	// Permission errors
	// ErrCannotUpdatePostOwnedByOther is returned when user cannot update post owned by another user
	ErrCannotUpdatePostOwnedByOther = errors.InsufficientPermissions("update post")

	// ErrCannotDeletePostOwnedByOther is returned when user cannot delete post owned by another user
	ErrCannotDeletePostOwnedByOther = errors.InsufficientPermissions("delete post")

	// ErrCannotPinPostOwnedByOther is returned when user cannot pin/unpin post owned by another user
	ErrCannotPinPostOwnedByOther = errors.InsufficientPermissions("pin/unpin post")

	// Action execution errors
	// ErrExecuteAction is returned when action execution fails
	ErrExecuteAction = errors.ProcessingFailed("action execution", stdErrors.New("action execution failed"))
)

Notes service specific errors - consolidated to use centralized error system

Functions

This section is empty.

Types

type AnalyticsService

type AnalyticsService interface {
	RecordStatusCreation(ctx context.Context, actorID string, timestamp time.Time) error
	RecordHashtagUsage(ctx context.Context, hashtags []string, objectID, actorID string) error
	RecordLinkShare(ctx context.Context, links []string, objectID, actorID string) error
	RecordEngagement(ctx context.Context, objectID, engagementType, actorID string) error
	RecordInstanceActivity(ctx context.Context, activityType string, timestamp time.Time) error
}

AnalyticsService defines the interface for analytics operations needed by the notes service

type BookmarkNoteCommand

type BookmarkNoteCommand struct {
	StatusID     string `json:"status_id" validate:"required"`
	BookmarkerID string `json:"bookmarker_id" validate:"required"`
}

BookmarkNoteCommand represents a request to bookmark a status

type BookmarkResult

type BookmarkResult struct {
	Status *models.Status     `json:"status"`
	Events []*streaming.Event `json:"events"`
}

BookmarkResult represents the result of a bookmark operation

type CountNotesByAuthorQuery

type CountNotesByAuthorQuery struct {
	AuthorID string `json:"author_id" validate:"required"`
}

CountNotesByAuthorQuery represents a request to count notes by an author

type CountRepliesQuery

type CountRepliesQuery struct {
	StatusID string `json:"status_id" validate:"required"`
}

CountRepliesQuery represents a request to count replies to a status

type CreateCommunityNoteCommand

type CreateCommunityNoteCommand struct {
	Note *storage.CommunityNote `json:"note" validate:"required"`
}

CreateCommunityNoteCommand represents a request to create a community note

type CreateCommunityNoteResult

type CreateCommunityNoteResult struct {
	Note *storage.CommunityNote `json:"note"`
}

CreateCommunityNoteResult represents the result of creating a community note

type CreateCommunityNoteVoteCommand

type CreateCommunityNoteVoteCommand struct {
	Vote *storage.CommunityNoteVote `json:"vote" validate:"required"`
}

CreateCommunityNoteVoteCommand represents a request to vote on a community note

type CreateCommunityNoteVoteResult

type CreateCommunityNoteVoteResult struct {
	Vote *storage.CommunityNoteVote `json:"vote"`
}

CreateCommunityNoteVoteResult represents the result of voting on a community note

type CreateNoteCommand

type CreateNoteCommand struct {
	AuthorID            string   `json:"author_id" validate:"required"`
	Content             string   `json:"content" validate:"required,max=5000"`
	Visibility          string   `json:"visibility" validate:"required,oneof=public unlisted private direct"`
	Sensitive           bool     `json:"sensitive"`
	SpoilerText         string   `json:"spoiler_text"`
	Language            string   `json:"language"`
	InReplyToID         string   `json:"in_reply_to_id"`
	ConversationID      string   `json:"conversation_id"`
	MediaIDs            []string `json:"media_ids"`
	PollOptions         []string `json:"poll_options"`
	PollExpiresIn       int      `json:"poll_expires_in"`  // Duration in seconds
	PollMultiple        bool     `json:"poll_multiple"`    // Allow multiple choices
	PollHideTotals      bool     `json:"poll_hide_totals"` // Hide vote counts until poll ends
	ToRecipients        []string `json:"to_recipients"`
	CcRecipients        []string `json:"cc_recipients"`
	BtoRecipients       []string `json:"bto_recipients"`
	BccRecipients       []string `json:"bcc_recipients"`
	QuoteTargetStatusID string   `json:"quote_target_status_id"`
	QuoteTargetAuthorID string   `json:"quote_target_author_id"`

	// Lesser extension: per-status agent transparency metadata (stored on the underlying Note).
	AgentAttribution *activitypub.AgentPostAttribution `json:"agent_attribution,omitempty"`
}

CreateNoteCommand contains all data needed to create a new note

type CreateScheduledNoteCommand

type CreateScheduledNoteCommand struct {
	AuthorID    string    `json:"author_id" validate:"required"`
	Content     string    `json:"content" validate:"required,max=500"`
	Visibility  string    `json:"visibility" validate:"oneof=public unlisted private direct"`
	Sensitive   bool      `json:"sensitive"`
	Language    string    `json:"language"`
	InReplyToID string    `json:"in_reply_to_id"`
	MediaIDs    []string  `json:"media_ids"`
	ScheduledAt time.Time `json:"scheduled_at" validate:"required"`
}

CreateScheduledNoteCommand contains all data needed to create a scheduled note

type DeleteNoteCommand

type DeleteNoteCommand struct {
	StatusID  string `json:"status_id" validate:"required"`
	DeleterID string `json:"deleter_id" validate:"required"` // Must be author or admin
	Reason    string `json:"reason"`                         // Optional reason for admin deletions
}

DeleteNoteCommand contains data needed to delete a note

type FederationService

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

FederationService defines the interface for federation operations

type GetBookmarksQuery

type GetBookmarksQuery struct {
	UserID     string                       `json:"user_id" validate:"required"`
	Pagination interfaces.PaginationOptions `json:"pagination"`
}

GetBookmarksQuery represents a request to get user's bookmarked statuses

type GetBoostCountQuery

type GetBoostCountQuery struct {
	StatusID string `json:"status_id" validate:"required"`
}

GetBoostCountQuery represents a request to get boost count

type GetCommunityNoteQuery

type GetCommunityNoteQuery struct {
	NoteID string `json:"note_id" validate:"required"`
}

GetCommunityNoteQuery represents a request to get a specific community note

type GetCommunityNoteResult

type GetCommunityNoteResult struct {
	Note *storage.CommunityNote `json:"note"`
}

GetCommunityNoteResult represents a community note

type GetCommunityNotesByAuthorQuery

type GetCommunityNotesByAuthorQuery struct {
	AuthorID string `json:"author_id" validate:"required"`
	Limit    int    `json:"limit" validate:"min=1,max=100"`
	Cursor   string `json:"cursor"`
}

GetCommunityNotesByAuthorQuery represents a request to get community notes by author

type GetCommunityNotesByAuthorResult

type GetCommunityNotesByAuthorResult struct {
	Notes      []*storage.CommunityNote `json:"notes"`
	NextCursor string                   `json:"next_cursor,omitempty"`
}

GetCommunityNotesByAuthorResult represents community notes by an author

type GetLikeCountQuery

type GetLikeCountQuery struct {
	StatusID string `json:"status_id" validate:"required"`
}

GetLikeCountQuery represents a request to get like count

type GetLikersQuery

type GetLikersQuery struct {
	StatusID   string                       `json:"status_id" validate:"required"`
	Pagination interfaces.PaginationOptions `json:"pagination"`
}

GetLikersQuery represents a request to get users who liked a status

type GetNoteQuery

type GetNoteQuery struct {
	StatusID string `json:"status_id" validate:"required"`
	ViewerID string `json:"viewer_id"` // User requesting the note (for privacy checks)
}

GetNoteQuery contains parameters for retrieving a single note

type GetRebloggersQuery

type GetRebloggersQuery struct {
	StatusID   string                       `json:"status_id" validate:"required"`
	Pagination interfaces.PaginationOptions `json:"pagination"`
}

GetRebloggersQuery represents a request to get users who reblogged a status

type GetSearchSuggestionsQuery

type GetSearchSuggestionsQuery struct {
	Prefix string `json:"prefix" validate:"required,min=2"`
	Limit  int    `json:"limit" validate:"min=1,max=50"`
}

GetSearchSuggestionsQuery represents a request to get search suggestions

type GetSearchSuggestionsResult

type GetSearchSuggestionsResult struct {
	Suggestions []*storage.SearchSuggestion `json:"suggestions"`
}

GetSearchSuggestionsResult represents search suggestions

type GetTimelineQuery

type GetTimelineQuery struct {
	UserID   string `json:"user_id" validate:"required"`
	Timeline string `json:"timeline" validate:"required,oneof=home public direct list hashtag"` // Type of timeline
	ListID   string `json:"list_id,omitempty"`                                                  // For list timeline
	Hashtag  string `json:"hashtag,omitempty"`                                                  // For hashtag timeline
	Limit    int    `json:"limit,omitempty"`                                                    // Max number of items
	SinceID  string `json:"since_id,omitempty"`                                                 // Get items newer than this ID
	MaxID    string `json:"max_id,omitempty"`                                                   // Get items older than this ID
	MinID    string `json:"min_id,omitempty"`                                                   // Get items immediately newer than this ID
}

GetTimelineQuery represents a request to get a timeline

type GetUpdateHistoryQuery

type GetUpdateHistoryQuery struct {
	StatusID string
	Limit    int
}

GetUpdateHistoryQuery contains parameters for getting update history

type GetUpdateHistoryResult

type GetUpdateHistoryResult struct {
	History []*storage.UpdateHistory
	Events  []*streaming.Event
}

GetUpdateHistoryResult contains the update history for a status

type GetUserTimelineQuery

type GetUserTimelineQuery struct {
	ActorID    string                       `json:"actor_id" validate:"required"`
	Pagination interfaces.PaginationOptions `json:"pagination"`
}

GetUserTimelineQuery represents a request to get a user's timeline

type GetUserTimelineResult

type GetUserTimelineResult struct {
	Items      []*models.Status `json:"items"`
	NextCursor string           `json:"next_cursor,omitempty"`
}

GetUserTimelineResult represents a user's timeline

type GetVisibleCommunityNotesQuery

type GetVisibleCommunityNotesQuery struct {
	ObjectID string `json:"object_id" validate:"required"`
}

GetVisibleCommunityNotesQuery represents a request to get visible community notes

type GetVisibleCommunityNotesResult

type GetVisibleCommunityNotesResult struct {
	Notes []*storage.CommunityNote `json:"notes"`
}

GetVisibleCommunityNotesResult represents visible community notes

type HasLikedQuery

type HasLikedQuery struct {
	UserID   string `json:"user_id" validate:"required"`
	StatusID string `json:"status_id" validate:"required"`
}

HasLikedQuery represents a request to check if a user has liked a status

type HasRebloggedQuery

type HasRebloggedQuery struct {
	UserID   string `json:"user_id" validate:"required"`
	StatusID string `json:"status_id" validate:"required"`
}

HasRebloggedQuery represents a request to check if a user has reblogged a status

type IsBookmarkedQuery

type IsBookmarkedQuery struct {
	UserID   string `json:"user_id" validate:"required"`
	StatusID string `json:"status_id" validate:"required"`
}

IsBookmarkedQuery represents a request to check if a user has bookmarked a status

type LikeNoteCommand

type LikeNoteCommand struct {
	StatusID string `json:"status_id" validate:"required"`
	LikerID  string `json:"liker_id" validate:"required"`
}

LikeNoteCommand represents a request to like a status

type LikeResult

type LikeResult struct {
	Status   *models.Status
	Events   []*streaming.Event
	Announce *storage.Announce
}

LikeResult represents the result of a like operation

type ListNotesQuery

type ListNotesQuery struct {
	ViewerID       string                       `json:"viewer_id"` // User requesting the timeline
	TimelineType   string                       `json:"timeline_type" validate:"required,oneof=home public local conversations hashtag user direct list"`
	AuthorID       string                       `json:"author_id"`       // For user timelines
	Hashtag        string                       `json:"hashtag"`         // For hashtag timelines
	ConversationID string                       `json:"conversation_id"` // For conversation threads
	ParentID       string                       `json:"parent_id"`       // For reply threads
	ListID         string                       `json:"list_id"`         // For list timelines
	Pagination     interfaces.PaginationOptions `json:"pagination"`
	OnlyMedia      bool                         `json:"only_media"`
	ExcludeReplies bool                         `json:"exclude_replies"`
	ExcludeReblogs bool                         `json:"exclude_reblogs"`
	PinnedOnly     bool                         `json:"pinned_only"`
	SinceID        string                       `json:"since_id"` // Get items newer than this ID
	MinID          string                       `json:"min_id"`   // Get items immediately newer than this ID
}

ListNotesQuery contains parameters for listing notes with various filters

type MuteNoteCommand

type MuteNoteCommand struct {
	StatusID        string `json:"status_id" validate:"required"`
	MuterID         string `json:"muter_id" validate:"required"`
	DurationSeconds int    `json:"duration_seconds"`
}

MuteNoteCommand represents a request to mute a status

type NoteResult

type NoteResult struct {
	Note                   *models.Status       `json:"note"`
	Events                 []*streaming.Event   `json:"events"`
	ReplyParentAcquisition *ResolvedReplyParent `json:"reply_parent_acquisition,omitempty"`
}

NoteResult contains a note and associated events that were emitted

type PinNoteCommand

type PinNoteCommand struct {
	StatusID string `json:"status_id" validate:"required"`
	PinnerID string `json:"pinner_id" validate:"required"`
}

PinNoteCommand represents a request to pin a status

type ReblogNoteCommand

type ReblogNoteCommand struct {
	StatusID    string `json:"status_id" validate:"required"`
	RebloggerID string `json:"reblogger_id" validate:"required"`
}

ReblogNoteCommand represents a request to reblog a status

type ReplyParentResolver added in v1.2.43

type ReplyParentResolver interface {
	ResolveReplyParent(ctx context.Context, author *storage.Account, rawInReplyTo string, requestedVisibility string) (*ResolvedReplyParent, error)
}

ReplyParentResolver resolves and materializes reply parents for note creation.

type ResolvedReplyParent added in v1.2.43

type ResolvedReplyParent struct {
	Status             *models.Status `json:"status,omitempty"`
	CanonicalObjectURL string         `json:"canonical_object_url,omitempty"`
	CanonicalStatusID  string         `json:"canonical_status_id,omitempty"`
	Visibility         string         `json:"visibility,omitempty"`
	Fetched            bool           `json:"fetched"`
	Remote             bool           `json:"remote"`
}

ResolvedReplyParent describes a reply parent resolved for a single create-note request.

type Result

type Result struct {
	Notes      []*models.Status                            `json:"notes"`
	Pagination *interfaces.PaginatedResult[*models.Status] `json:"pagination"`
	Events     []*streaming.Event                          `json:"events"`
}

Result contains multiple notes and pagination information

type ScheduledNoteResult

type ScheduledNoteResult struct {
	ScheduledStatus *storage.ScheduledStatus `json:"scheduled_status"`
	Events          []*streaming.Event       `json:"events"`
}

ScheduledNoteResult contains the result of scheduled note operations

type ScheduledStatusRepository

type ScheduledStatusRepository interface {
	CreateScheduledStatus(ctx context.Context, scheduled *storage.ScheduledStatus) error
	GetScheduledStatus(ctx context.Context, id string) (*storage.ScheduledStatus, error)
	GetScheduledStatuses(ctx context.Context, username string, limit int, cursor string) ([]*storage.ScheduledStatus, string, error)
	UpdateScheduledStatus(ctx context.Context, scheduled *storage.ScheduledStatus) error
	DeleteScheduledStatus(ctx context.Context, id string) error
}

ScheduledStatusRepository defines the interface for scheduled status operations

type Service

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

Service provides notes/status operations

func NewService

func NewService(
	noteRepo interfaces.StatusRepository,
	accountRepo interfaces.AccountRepository,
	bookmarkRepo *repositories.BookmarkRepository,
	relationshipRepo interfaces.ConcreteRelationshipRepository,
	mediaRepo interfaces.MediaRepository,
	likeRepo *repositories.LikeRepository,
	socialRepo interfaces.SocialRepository,
	conversationRepo interfaces.ConversationRepository,
	objectRepo interfaces.ObjectRepository,
	searchRepo *repositories.SearchRepository,
	communityNoteRepo *repositories.CommunityNoteRepository,
	userRepo interfaces.UserRepository,
	pollRepo *repositories.PollRepository,
	publisher streaming.Publisher,
	analytics AnalyticsService,
	federation FederationService,
	replyParents ReplyParentResolver,
	notifier notificationsService,
	logger *zap.Logger,
	domainName string,
) *Service

NewService creates a new Notes Service with the required dependencies

func (*Service) BookmarkNote

func (s *Service) BookmarkNote(ctx context.Context, cmd *BookmarkNoteCommand) (*BookmarkResult, error)

BookmarkNote adds a status to user's bookmarks

func (*Service) CountNotesByAuthor

func (s *Service) CountNotesByAuthor(ctx context.Context, authorID string) (int64, error)

CountNotesByAuthor counts the number of notes by an author

func (*Service) CountReplies

func (s *Service) CountReplies(ctx context.Context, statusID string) (int, error)

CountReplies counts the number of replies to a status

func (*Service) CreateCommunityNote

func (s *Service) CreateCommunityNote(ctx context.Context, cmd *CreateCommunityNoteCommand) (*CreateCommunityNoteResult, error)

CreateCommunityNote creates a new community note

func (*Service) CreateCommunityNoteVote

CreateCommunityNoteVote creates a vote for a community note

func (*Service) CreateNote

func (s *Service) CreateNote(ctx context.Context, cmd *CreateNoteCommand) (*NoteResult, error)

CreateNote creates a new note, validates input, stores it, emits events, and queues federation

func (*Service) CreateScheduledNote

func (s *Service) CreateScheduledNote(ctx context.Context, cmd *CreateScheduledNoteCommand) (*ScheduledNoteResult, error)

CreateScheduledNote creates a scheduled note to be published later

func (*Service) DeleteNote

func (s *Service) DeleteNote(ctx context.Context, cmd *DeleteNoteCommand) error

DeleteNote performs a soft delete on a note, emits events, and queues federation tombstone

func (*Service) GetBookmarks

func (s *Service) GetBookmarks(ctx context.Context, query *GetBookmarksQuery) (*Result, error)

GetBookmarks retrieves user's bookmarked statuses

func (*Service) GetBoostCount

func (s *Service) GetBoostCount(ctx context.Context, statusID string) (int64, error)

GetBoostCount gets the number of boosts for a status

func (*Service) GetCommunityNote

func (s *Service) GetCommunityNote(ctx context.Context, query *GetCommunityNoteQuery) (*GetCommunityNoteResult, error)

GetCommunityNote retrieves a specific community note

func (*Service) GetCommunityNotesByAuthor

func (s *Service) GetCommunityNotesByAuthor(ctx context.Context, query *GetCommunityNotesByAuthorQuery) (*GetCommunityNotesByAuthorResult, error)

GetCommunityNotesByAuthor retrieves community notes by a specific author

func (*Service) GetFavoritedNotes

func (s *Service) GetFavoritedNotes(ctx context.Context, query *ListNotesQuery) (*Result, error)

GetFavoritedNotes returns the favorited/liked statuses for a user

func (*Service) GetLikeCount

func (s *Service) GetLikeCount(ctx context.Context, statusID string) (int64, error)

GetLikeCount gets the number of likes for a status

func (*Service) GetLikers

func (s *Service) GetLikers(ctx context.Context, query *GetLikersQuery) (*UsersResult, error)

GetLikers retrieves users who liked a status

func (*Service) GetNote

func (s *Service) GetNote(ctx context.Context, statusID string) (*models.Status, error)

GetNote retrieves a single note for public contexts.

It enforces visibility as if the viewer is unauthenticated (public/unlisted only). Use GetNoteWithViewer for viewer-aware access to private/direct content.

func (*Service) GetNoteWithViewer

func (s *Service) GetNoteWithViewer(ctx context.Context, query *GetNoteQuery) (*models.Status, error)

GetNoteWithViewer retrieves a note with viewer context for privacy checking

func (*Service) GetRebloggers

func (s *Service) GetRebloggers(ctx context.Context, query *GetRebloggersQuery) (*UsersResult, error)

GetRebloggers retrieves users who reblogged a status

func (*Service) GetSearchSuggestions

func (s *Service) GetSearchSuggestions(ctx context.Context, query *GetSearchSuggestionsQuery) (*GetSearchSuggestionsResult, error)

GetSearchSuggestions retrieves search suggestions based on a prefix

func (*Service) GetTimeline

func (s *Service) GetTimeline(ctx context.Context, query *GetTimelineQuery) (*Result, error)

GetTimeline retrieves a specific timeline for the user

func (*Service) GetUpdateHistory

func (s *Service) GetUpdateHistory(ctx context.Context, query *GetUpdateHistoryQuery) (*GetUpdateHistoryResult, error)

GetUpdateHistory retrieves the edit history for a status

func (*Service) GetUserTimeline

func (s *Service) GetUserTimeline(ctx context.Context, actorID string, opts interfaces.PaginationOptions) (*GetUserTimelineResult, error)

GetUserTimeline retrieves a user's timeline

func (*Service) GetVisibleCommunityNotes

func (s *Service) GetVisibleCommunityNotes(ctx context.Context, query *GetVisibleCommunityNotesQuery) (*GetVisibleCommunityNotesResult, error)

GetVisibleCommunityNotes retrieves visible community notes for an object

func (*Service) HasLiked

func (s *Service) HasLiked(ctx context.Context, userID, statusID string) (bool, error)

HasLiked checks if a user has liked a status

func (*Service) HasReblogged

func (s *Service) HasReblogged(ctx context.Context, userID, statusID string) (bool, error)

HasReblogged checks if a user has reblogged a status

func (*Service) IsBookmarked

func (s *Service) IsBookmarked(ctx context.Context, userID, statusID string) (bool, error)

IsBookmarked checks if a user has bookmarked a status

func (*Service) LikeNote

func (s *Service) LikeNote(ctx context.Context, cmd *LikeNoteCommand) (*LikeResult, error)

LikeNote adds a like to a status

func (*Service) ListNotes

func (s *Service) ListNotes(ctx context.Context, query *ListNotesQuery) (*Result, error)

ListNotes retrieves notes based on various timeline types and filters

func (*Service) MuteNote

func (s *Service) MuteNote(ctx context.Context, cmd *MuteNoteCommand) (*LikeResult, error)

MuteNote mutes a status for a user

func (*Service) PinNote

func (s *Service) PinNote(ctx context.Context, cmd *PinNoteCommand) (*LikeResult, error)

PinNote pins a status to user's profile

func (*Service) ReblogNote

func (s *Service) ReblogNote(ctx context.Context, cmd *ReblogNoteCommand) (*LikeResult, error)

ReblogNote creates a reblog/announce of a status

func (*Service) UnbookmarkNote

func (s *Service) UnbookmarkNote(ctx context.Context, cmd *UnbookmarkNoteCommand) (*BookmarkResult, error)

UnbookmarkNote removes a status from user's bookmarks

func (*Service) UnlikeNote

func (s *Service) UnlikeNote(ctx context.Context, cmd *UnlikeNoteCommand) (*LikeResult, error)

UnlikeNote removes a like from a status

func (*Service) UnmuteNote

func (s *Service) UnmuteNote(ctx context.Context, cmd *UnmuteNoteCommand) (*LikeResult, error)

UnmuteNote unmutes a status for a user

func (*Service) UnpinNote

func (s *Service) UnpinNote(ctx context.Context, cmd *UnpinNoteCommand) (*LikeResult, error)

UnpinNote unpins a status from user's profile

func (*Service) UnreblogNote

func (s *Service) UnreblogNote(ctx context.Context, cmd *UnreblogNoteCommand) (*LikeResult, error)

UnreblogNote removes a reblog/announce of a status

func (*Service) UpdateNote

func (s *Service) UpdateNote(ctx context.Context, cmd *UpdateNoteCommand) (*NoteResult, error)

UpdateNote updates an existing note, validates permission, stores changes, and emits events

type UnbookmarkNoteCommand

type UnbookmarkNoteCommand struct {
	StatusID       string `json:"status_id" validate:"required"`
	UnbookmarkerID string `json:"unbookmarker_id" validate:"required"`
}

UnbookmarkNoteCommand represents a request to unbookmark a status

type UnlikeNoteCommand

type UnlikeNoteCommand struct {
	StatusID  string `json:"status_id" validate:"required"`
	UnlikerID string `json:"unliker_id" validate:"required"`
}

UnlikeNoteCommand represents a request to unlike a status

type UnmuteNoteCommand

type UnmuteNoteCommand struct {
	StatusID string `json:"status_id" validate:"required"`
	MuterID  string `json:"muter_id" validate:"required"`
}

UnmuteNoteCommand represents a request to unmute a status

type UnpinNoteCommand

type UnpinNoteCommand struct {
	StatusID string `json:"status_id" validate:"required"`
	PinnerID string `json:"pinner_id" validate:"required"`
}

UnpinNoteCommand represents a request to unpin a status

type UnreblogNoteCommand

type UnreblogNoteCommand struct {
	StatusID      string `json:"status_id" validate:"required"`
	UnrebloggerID string `json:"unreblogger_id" validate:"required"`
}

UnreblogNoteCommand represents a request to unreblog a status

type UpdateNoteCommand

type UpdateNoteCommand struct {
	StatusID    string   `json:"status_id" validate:"required"`
	Content     string   `json:"content" validate:"required,max=5000"`
	Sensitive   bool     `json:"sensitive"`
	SpoilerText string   `json:"spoiler_text"`
	Language    string   `json:"language"`
	MediaIDs    []string `json:"media_ids"`
	UpdaterID   string   `json:"updater_id" validate:"required"` // Must be author
}

UpdateNoteCommand contains all data needed to update an existing note

type UsersResult

type UsersResult struct {
	Users      []*storage.Account                            `json:"users"`
	Pagination *interfaces.PaginatedResult[*storage.Account] `json:"pagination"`
}

UsersResult represents a list of users (for likers, rebloggers, etc.)

Jump to

Keyboard shortcuts

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