db

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is the database struct.

func GetDB

func GetDB() *DB

func (*DB) AcceptFollowByURI

func (db *DB) AcceptFollowByURI(uri string) error

func (*DB) BanAccount added in v1.6.0

func (db *DB) BanAccount(accountId uuid.UUID) error

BanAccount sets the banned flag on an account and creates a ban record

func (*DB) CleanupExpiredIPBans added in v1.6.0

func (db *DB) CleanupExpiredIPBans() (int64, error)

CleanupExpiredIPBans clears IP addresses from bans older than 60 days The ban record is kept (for public key blocking) but the IP is cleared

func (*DB) CleanupExpiredUploadTokens added in v1.5.0

func (db *DB) CleanupExpiredUploadTokens() error

CleanupExpiredUploadTokens removes all expired tokens

func (*DB) CleanupOrphanedFollows added in v1.2.4

func (db *DB) CleanupOrphanedFollows() error

CleanupOrphanedFollows removes follow records that point to deleted remote accounts

func (*DB) CountAccounts added in v1.1.0

func (db *DB) CountAccounts() (int, error)

CountAccounts returns the total number of accounts in the database

func (*DB) CountActiveUsersHalfYear added in v1.2.2

func (db *DB) CountActiveUsersHalfYear() (int, error)

CountActiveUsersHalfYear returns the number of users who posted in the last 180 days

func (*DB) CountActiveUsersMonth added in v1.2.2

func (db *DB) CountActiveUsersMonth() (int, error)

CountActiveUsersMonth returns the number of users who posted in the last 30 days

func (*DB) CountActivitiesByInReplyTo added in v1.4.0

func (db *DB) CountActivitiesByInReplyTo(parentURI string) (int, error)

CountActivitiesByInReplyTo counts Create activities that are replies to the given URI

func (*DB) CountGlobalTimelinePosts added in v1.6.0

func (db *DB) CountGlobalTimelinePosts() (int, error)

CountGlobalTimelinePosts returns the total count of posts in the global timeline

func (*DB) CountLikesByNoteId added in v1.4.1

func (db *DB) CountLikesByNoteId(noteId uuid.UUID) (int, error)

CountLikesByNoteId returns the number of likes for a given note

func (*DB) CountLocalPosts added in v1.2.2

func (db *DB) CountLocalPosts() (int, error)

CountLocalPosts returns the total number of local posts (notes) in the database

func (*DB) CountNotesByHashtag added in v1.4.0

func (db *DB) CountNotesByHashtag(tag string) (int, error)

CountNotesByHashtag returns the total count of notes with a specific hashtag

func (*DB) CountRepliesByNoteId added in v1.4.0

func (db *DB) CountRepliesByNoteId(noteId uuid.UUID) (int, error)

CountRepliesByNoteId counts the number of direct replies to a local note

func (*DB) CountRepliesByURI added in v1.4.0

func (db *DB) CountRepliesByURI(objectURI string) (int, error)

CountRepliesByURI counts the number of direct replies to a note by URI

func (*DB) CountTotalRepliesByNoteId added in v1.4.0

func (db *DB) CountTotalRepliesByNoteId(noteId uuid.UUID) (int, error)

CountTotalRepliesByNoteId counts all replies (recursively) to a local note This includes direct replies and all nested replies in the thread

func (*DB) CountTotalRepliesByURI added in v1.4.0

func (db *DB) CountTotalRepliesByURI(objectURI string) (int, error)

CountTotalRepliesByURI counts all replies (recursively) to a note by URI This includes direct replies, remote replies, and all nested replies

func (*DB) CreateAccByUsername

func (db *DB) CreateAccByUsername(s ssh.Session, username string, webKeyPair *util.RsaKeyPair) error

func (*DB) CreateAccount

func (db *DB) CreateAccount(s ssh.Session, username string) (error, bool)

func (*DB) CreateActivity

func (db *DB) CreateActivity(activity *domain.Activity) error

func (*DB) CreateBan added in v1.6.0

func (db *DB) CreateBan(id, username, ipAddress, publicKeyHash, reason string) error

CreateBan adds a new ban record with IP address and public key hash

func (*DB) CreateBoost added in v1.4.1

func (db *DB) CreateBoost(boost *domain.Boost) error

CreateBoost creates a new boost record

func (*DB) CreateBoostByObjectURI added in v1.6.0

func (db *DB) CreateBoostByObjectURI(boost *domain.Boost, objectURI string) error

CreateBoostByObjectURI creates a boost for a remote post using object URI

func (*DB) CreateBoostFromRemote added in v1.6.0

func (db *DB) CreateBoostFromRemote(boost *domain.Boost) error

CreateBoostFromRemote creates a boost record with remote_account_id set (for boosts from followed remote users)

func (*DB) CreateDB

func (db *DB) CreateDB() error

CreateDB creates the database.

func (*DB) CreateFollow

func (db *DB) CreateFollow(follow *domain.Follow) error

func (*DB) CreateInfoBox added in v1.5.0

func (db *DB) CreateInfoBox(box *domain.InfoBox) error

CreateInfoBox creates a new info box

func (*DB) CreateLike added in v1.4.1

func (db *DB) CreateLike(like *domain.Like) error

CreateLike creates a new like record

func (*DB) CreateLikeByObjectURI added in v1.4.1

func (db *DB) CreateLikeByObjectURI(like *domain.Like, objectURI string) error

CreateLikeByObjectURI creates a like for a remote post using object URI

func (*DB) CreateLocalFollow

func (db *DB) CreateLocalFollow(followerAccountId, targetAccountId uuid.UUID) error

CreateLocalFollow creates a local-only follow relationship

func (*DB) CreateNote

func (db *DB) CreateNote(userId uuid.UUID, message string) (uuid.UUID, error)

func (*DB) CreateNoteMention added in v1.4.0

func (db *DB) CreateNoteMention(mention *domain.NoteMention) error

CreateNoteMention creates a new mention record for a note

func (*DB) CreateNoteWithReply added in v1.4.0

func (db *DB) CreateNoteWithReply(userId uuid.UUID, message string, inReplyToURI string) (uuid.UUID, error)

CreateNoteWithReply creates a note with an optional inReplyToURI for replies

func (*DB) CreateNotification added in v1.4.3

func (db *DB) CreateNotification(notification *domain.Notification) error

CreateNotification creates a new notification

func (*DB) CreateOrUpdateHashtag added in v1.4.0

func (db *DB) CreateOrUpdateHashtag(name string) (int64, error)

CreateOrUpdateHashtag creates a new hashtag or increments usage count if it exists Returns the hashtag ID

func (*DB) CreateRelay added in v1.4.2

func (db *DB) CreateRelay(relay *domain.Relay) error

CreateRelay creates a new relay subscription

func (*DB) CreateRemoteAccount

func (db *DB) CreateRemoteAccount(acc *domain.RemoteAccount) error

func (*DB) CreateUploadToken added in v1.5.0

func (db *DB) CreateUploadToken(accountId uuid.UUID, token string, tokenType string, expiresIn time.Duration) error

CreateUploadToken creates a new one-time upload token

func (*DB) DecrementBoostCountByNoteId added in v1.4.1

func (db *DB) DecrementBoostCountByNoteId(noteId uuid.UUID) error

DecrementBoostCountByNoteId decrements the boost_count for a note

func (*DB) DecrementBoostCountByObjectURI added in v1.6.0

func (db *DB) DecrementBoostCountByObjectURI(objectURI string) error

DecrementBoostCountByObjectURI decrements the boost_count for an activity by object URI

func (*DB) DecrementLikeCountByNoteId added in v1.4.1

func (db *DB) DecrementLikeCountByNoteId(noteId uuid.UUID) error

DecrementLikeCountByNoteId decrements the like_count for a note

func (*DB) DecrementLikeCountByObjectURI added in v1.4.1

func (db *DB) DecrementLikeCountByObjectURI(objectURI string) error

DecrementLikeCountByObjectURI decrements the like_count for an activity by object URI

func (*DB) DeleteAccount added in v1.1.0

func (db *DB) DeleteAccount(accountId uuid.UUID) error

DeleteAccount deletes a local account and all associated data (notes, follows, activities)

func (*DB) DeleteActivity

func (db *DB) DeleteActivity(id uuid.UUID) error

DeleteActivity deletes an activity by ID

func (*DB) DeleteAllNotifications added in v1.4.3

func (db *DB) DeleteAllNotifications(accountId uuid.UUID) error

DeleteAllNotifications deletes all notifications for an account

func (*DB) DeleteBan added in v1.6.0

func (db *DB) DeleteBan(id string) error

DeleteBan removes a ban record by ID

func (*DB) DeleteBoostByAccountAndNote added in v1.4.1

func (db *DB) DeleteBoostByAccountAndNote(accountId, noteId uuid.UUID) error

DeleteBoostByAccountAndNote removes a boost by the account and note IDs

func (*DB) DeleteBoostByAccountAndObjectURI added in v1.6.0

func (db *DB) DeleteBoostByAccountAndObjectURI(accountId uuid.UUID, objectURI string) error

DeleteBoostByAccountAndObjectURI removes a boost by account ID and object URI

func (*DB) DeleteBoostByRemoteAccountAndObjectURI added in v1.6.0

func (db *DB) DeleteBoostByRemoteAccountAndObjectURI(remoteAccountId uuid.UUID, objectURI string) error

DeleteBoostByRemoteAccountAndObjectURI removes a boost by remote account ID and object URI

func (*DB) DeleteDelivery

func (db *DB) DeleteDelivery(id uuid.UUID) error

func (*DB) DeleteFollowByAccountIds added in v1.1.0

func (db *DB) DeleteFollowByAccountIds(accountId, targetAccountId uuid.UUID) error

func (*DB) DeleteFollowByURI

func (db *DB) DeleteFollowByURI(uri string) error

func (*DB) DeleteFollowsByRemoteAccountId

func (db *DB) DeleteFollowsByRemoteAccountId(remoteAccountId uuid.UUID) error

DeleteFollowsByRemoteAccountId deletes all follows to/from a remote account

func (*DB) DeleteFromFTS added in v1.7.1

func (db *DB) DeleteFromFTS(sourceID string)

DeleteFromFTS removes a post from the FTS index by source_id. Uses the lookup table to find the FTS rowid, then deletes by rowid.

func (*DB) DeleteInfoBox added in v1.5.0

func (db *DB) DeleteInfoBox(id uuid.UUID) error

DeleteInfoBox deletes an info box

func (*DB) DeleteLikeByAccountAndNote added in v1.4.1

func (db *DB) DeleteLikeByAccountAndNote(accountId, noteId uuid.UUID) error

DeleteLikeByAccountAndNote removes a like by the account and note IDs

func (*DB) DeleteLikeByAccountAndObjectURI added in v1.4.1

func (db *DB) DeleteLikeByAccountAndObjectURI(accountId uuid.UUID, objectURI string) error

DeleteLikeByAccountAndObjectURI removes a like by account ID and object URI

func (*DB) DeleteLikeByURI added in v1.4.1

func (db *DB) DeleteLikeByURI(uri string) error

DeleteLikeByURI removes a like by its activity URI

func (*DB) DeleteLocalFollow

func (db *DB) DeleteLocalFollow(followerAccountId, targetAccountId uuid.UUID) error

DeleteLocalFollow removes a local follow relationship

func (*DB) DeleteMentionsByNoteId added in v1.4.0

func (db *DB) DeleteMentionsByNoteId(noteId uuid.UUID) error

DeleteMentionsByNoteId removes all mentions for a specific note

func (*DB) DeleteNoteById

func (db *DB) DeleteNoteById(noteId uuid.UUID) error

func (*DB) DeleteNotification added in v1.4.3

func (db *DB) DeleteNotification(notificationId uuid.UUID) error

DeleteNotification deletes a notification

func (*DB) DeleteRelay added in v1.4.2

func (db *DB) DeleteRelay(id uuid.UUID) error

DeleteRelay deletes a relay subscription

func (*DB) DeleteRelayActivities added in v1.4.2

func (db *DB) DeleteRelayActivities() (int64, error)

DeleteRelayActivities deletes all activities that were forwarded by relays (from_relay=1)

func (*DB) DeleteRelayActivitiesFTS added in v1.7.1

func (db *DB) DeleteRelayActivitiesFTS()

DeleteRelayActivitiesFTS removes all relay-forwarded activities from the FTS index

func (*DB) DeleteRemoteAccount

func (db *DB) DeleteRemoteAccount(id uuid.UUID) error

DeleteRemoteAccount deletes a remote account by ID

func (*DB) DeleteUploadToken added in v1.5.0

func (db *DB) DeleteUploadToken(token string) error

DeleteUploadToken removes a used or expired token

func (*DB) EnqueueDelivery

func (db *DB) EnqueueDelivery(item *domain.DeliveryQueueItem) error

func (*DB) GetCurrentTermsAndConditions added in v1.6.3

func (db *DB) GetCurrentTermsAndConditions() (error, *domain.TermsAndConditions)

GetCurrentTermsAndConditions returns the current terms and conditions

func (*DB) GetExistingUploadToken added in v1.5.0

func (db *DB) GetExistingUploadToken(accountId uuid.UUID, tokenType string) (string, time.Time, error)

GetExistingUploadToken returns an existing valid token for an account, or empty string if none exists

func (*DB) GetUserTermsAcceptance added in v1.6.3

func (db *DB) GetUserTermsAcceptance(userId uuid.UUID) (error, *domain.UserTermsAcceptance)

GetUserTermsAcceptance returns the terms acceptance record for a user

func (*DB) HasBoost added in v1.4.1

func (db *DB) HasBoost(accountId, noteId uuid.UUID) (bool, error)

HasBoost checks if a boost already exists for this account and note

func (*DB) HasBoostByObjectURI added in v1.6.0

func (db *DB) HasBoostByObjectURI(accountId uuid.UUID, objectURI string) (bool, error)

HasBoostByObjectURI checks if an account has boosted a post by its object URI

func (*DB) HasBoostFromRemote added in v1.6.0

func (db *DB) HasBoostFromRemote(remoteAccountId uuid.UUID, objectURI string) (bool, error)

HasBoostFromRemote checks if a boost already exists from a remote account for a given object URI

func (*DB) HasLike added in v1.4.1

func (db *DB) HasLike(accountId, noteId uuid.UUID) (bool, error)

HasLike checks if a like already exists for this account and note

func (*DB) HasLikeByObjectURI added in v1.4.1

func (db *DB) HasLikeByObjectURI(accountId uuid.UUID, objectURI string) (bool, error)

HasLikeByObjectURI checks if an account has liked a post by its object URI

func (*DB) HasLikeByURI added in v1.4.1

func (db *DB) HasLikeByURI(uri string) (bool, error)

HasLikeByURI checks if a like already exists by its activity URI

func (*DB) IncrementBoostCountByNoteId added in v1.4.1

func (db *DB) IncrementBoostCountByNoteId(noteId uuid.UUID) error

IncrementBoostCountByNoteId increments the boost_count for a note

func (*DB) IncrementBoostCountByObjectURI added in v1.6.0

func (db *DB) IncrementBoostCountByObjectURI(objectURI string) error

IncrementBoostCountByObjectURI increments the boost_count for an activity by object URI

func (*DB) IncrementLikeCountByNoteId added in v1.4.1

func (db *DB) IncrementLikeCountByNoteId(noteId uuid.UUID) error

IncrementLikeCountByNoteId increments the like_count for a note and returns new count

func (*DB) IncrementLikeCountByObjectURI added in v1.4.1

func (db *DB) IncrementLikeCountByObjectURI(objectURI string) error

IncrementLikeCountByObjectURI increments the like_count for an activity by object URI

func (*DB) IncrementReplyCountByURI added in v1.4.0

func (db *DB) IncrementReplyCountByURI(parentURI string) error

IncrementReplyCountByURI increments the reply_count on a note or activity by URI This is used when receiving remote replies via ActivityPub inbox

func (*DB) InsertActivityFTS added in v1.7.1

func (db *DB) InsertActivityFTS(activityId uuid.UUID, actorURI, rawJSON, createdAt, objectURI, objectURL string)

InsertActivityFTS adds a remote activity to the FTS index

func (*DB) InsertNoteFTS added in v1.7.1

func (db *DB) InsertNoteFTS(noteId uuid.UUID, author, message, createdAt, objectURI string)

InsertNoteFTS adds a local note to the FTS index

func (*DB) IsFollowingLocal

func (db *DB) IsFollowingLocal(followerAccountId, targetAccountId uuid.UUID) (bool, error)

IsFollowingLocal checks if a user is following another local user

func (*DB) IsIPBanned added in v1.6.0

func (db *DB) IsIPBanned(ipAddress string) bool

IsIPBanned checks if an IP address is banned

func (*DB) IsPublicKeyBanned added in v1.6.0

func (db *DB) IsPublicKeyBanned(publicKeyHash string) bool

IsPublicKeyBanned checks if a public key hash is banned

func (*DB) IsRemoteAccountFollowed added in v1.6.0

func (db *DB) IsRemoteAccountFollowed(remoteAccountId uuid.UUID) (bool, error)

IsRemoteAccountFollowed checks if any local user follows the given remote account

func (*DB) LinkNoteHashtags added in v1.4.0

func (db *DB) LinkNoteHashtags(noteId uuid.UUID, hashtagIds []int64) error

LinkNoteHashtags creates links between a note and multiple hashtags

func (*DB) LinkNoteMentions added in v1.4.0

func (db *DB) LinkNoteMentions(noteId uuid.UUID, mentions []domain.NoteMention) error

LinkNoteMentions creates mention records for all mentions in a note

func (*DB) MarkAllNotificationsRead added in v1.4.3

func (db *DB) MarkAllNotificationsRead(accountId uuid.UUID) error

MarkAllNotificationsRead marks all notifications for an account as read

func (*DB) MarkNotificationRead added in v1.4.3

func (db *DB) MarkNotificationRead(notificationId uuid.UUID) error

MarkNotificationRead marks a notification as read

func (*DB) MigrateDuplicateFollows added in v1.2.2

func (db *DB) MigrateDuplicateFollows() error

MigrateDuplicateFollows removes duplicate follow relationships and adds UNIQUE constraint This is a one-time migration to fix the issue where multiple Follow activities from the same actor could create duplicate entries

func (*DB) MigrateFTS5Search added in v1.7.1

func (db *DB) MigrateFTS5Search() error

MigrateFTS5Search creates the FTS5 virtual table for full-text search and backfills existing data. The FTS5 table only stores content and author (the searchable columns). Metadata (source_type, created_at) lives in the lookup table. object_uri/object_url are loaded from notes/activities at query time.

func (*DB) MigrateKeysToPKCS8 added in v1.2.2

func (db *DB) MigrateKeysToPKCS8() error

MigrateKeysToPKCS8 converts all existing PKCS#1 keys to PKCS#8 format This is a one-time migration that preserves the cryptographic key material

func (*DB) MigrateLocalReplyCounts added in v1.4.2

func (db *DB) MigrateLocalReplyCounts() error

MigrateLocalReplyCounts recalculates reply_count for notes with local replies This fixes the issue where local-only replies (with "local:" prefix URIs) weren't being counted, causing threads not to open in the TUI

func (*DB) MigrateOrphanActivities added in v1.6.0

func (db *DB) MigrateOrphanActivities() error

MigrateOrphanActivities removes Create activities that were incorrectly stored because the inbox handler stored them before checking if the user follows the actor. This is a one-time cleanup migration for the bug fix in handleCreateActivityWithDeps.

func (*DB) MigratePerformanceIndexes added in v1.4.2

func (db *DB) MigratePerformanceIndexes() error

MigratePerformanceIndexes adds performance-critical indexes that were missing These indexes speed up threading queries and relay content filtering

func (*DB) MuteUser added in v1.1.0

func (db *DB) MuteUser(accountId uuid.UUID) error

MuteUser mutes a user and deletes all their posts

func (*DB) ReadAccById

func (db *DB) ReadAccById(id uuid.UUID) (error, *domain.Account)

func (*DB) ReadAccByPkHash

func (db *DB) ReadAccByPkHash(pkHash string) (error, *domain.Account)

func (*DB) ReadAccBySession

func (db *DB) ReadAccBySession(s ssh.Session) (error, *domain.Account)

func (*DB) ReadAccByUsername

func (db *DB) ReadAccByUsername(username string) (error, *domain.Account)

func (*DB) ReadActiveRelays added in v1.4.2

func (db *DB) ReadActiveRelays() (error, *[]domain.Relay)

ReadActiveRelays returns all relay subscriptions with status='active'

func (*DB) ReadActiveUnpausedRelays added in v1.4.2

func (db *DB) ReadActiveUnpausedRelays() (error, *[]domain.Relay)

ReadActiveUnpausedRelays returns all relay subscriptions with status='active' and paused=0

func (*DB) ReadActivitiesByActorURI added in v1.7.0

func (db *DB) ReadActivitiesByActorURI(actorURI string, limit int) (error, *[]domain.Activity)

ReadActivitiesByActorURI returns top-level posts (Create activities) from a specific remote actor Used to display posts on a remote user's profile

func (*DB) ReadActivitiesByInReplyTo added in v1.4.0

func (db *DB) ReadActivitiesByInReplyTo(parentURI string) (error, *[]domain.Activity)

ReadActivitiesByInReplyTo finds all Create activities that are replies to the given URI This searches the raw_json field for "inReplyTo":"<uri>" patterns It supports both exact URI matches and partial matches (for notes without stored object_uri)

func (*DB) ReadActivityById added in v1.7.0

func (db *DB) ReadActivityById(id uuid.UUID) (error, *domain.Activity)

ReadActivityById reads an activity by its UUID

func (*DB) ReadActivityByObjectURI

func (db *DB) ReadActivityByObjectURI(objectURI string) (error, *domain.Activity)

ReadActivityByObjectURI reads an activity by the object URI First tries exact match on object_uri column, falls back to searching raw_json for older activities

func (*DB) ReadActivityByURI

func (db *DB) ReadActivityByURI(uri string) (error, *domain.Activity)

func (*DB) ReadAllAccounts

func (db *DB) ReadAllAccounts() (error, *[]domain.Account)

ReadAllAccounts returns all local user accounts (excluding first-time login users)

func (*DB) ReadAllAccountsAdmin added in v1.1.0

func (db *DB) ReadAllAccountsAdmin() (error, *[]domain.Account)

ReadAllAccountsAdmin returns all local user accounts including first-time login users (for admin panel)

func (*DB) ReadAllBans added in v1.6.0

func (db *DB) ReadAllBans() (error, *[]domain.Ban)

ReadAllBans returns all ban records

func (*DB) ReadAllInfoBoxes added in v1.5.0

func (db *DB) ReadAllInfoBoxes() (error, *[]domain.InfoBox)

ReadAllInfoBoxes returns all info boxes ordered by order_num

func (*DB) ReadAllNotes

func (db *DB) ReadAllNotes() (error, *[]domain.Note)

func (*DB) ReadAllRelays added in v1.4.2

func (db *DB) ReadAllRelays() (error, *[]domain.Relay)

ReadAllRelays returns all relay subscriptions

func (*DB) ReadAllRemoteAccounts added in v1.4.0

func (db *DB) ReadAllRemoteAccounts() (error, []domain.RemoteAccount)

ReadAllRemoteAccounts returns all cached remote accounts for autocomplete

func (*DB) ReadBoostByAccountAndNote added in v1.6.0

func (db *DB) ReadBoostByAccountAndNote(accountId, noteId uuid.UUID) (error, *domain.Boost)

ReadBoostByAccountAndNote finds a boost by account ID and note ID

func (*DB) ReadBoostByAccountAndObjectURI added in v1.6.0

func (db *DB) ReadBoostByAccountAndObjectURI(accountId uuid.UUID, objectURI string) (error, *domain.Boost)

ReadBoostByAccountAndObjectURI finds a boost by account ID and object URI

func (*DB) ReadBoostersInfoByNoteId added in v1.5.0

func (db *DB) ReadBoostersInfoByNoteId(noteId uuid.UUID) ([]string, error)

ReadBoostersInfoByNoteId returns a list of usernames who boosted a local note (local and remote users)

func (*DB) ReadBoostersInfoByObjectURI added in v1.5.0

func (db *DB) ReadBoostersInfoByObjectURI(objectURI string) ([]string, error)

ReadBoostersInfoByObjectURI returns a list of usernames who boosted a remote post (local and remote users)

func (*DB) ReadEnabledInfoBoxes added in v1.5.0

func (db *DB) ReadEnabledInfoBoxes() (error, *[]domain.InfoBox)

ReadEnabledInfoBoxes returns only enabled info boxes ordered by order_num

func (*DB) ReadFederatedActivities

func (db *DB) ReadFederatedActivities(accountId uuid.UUID, limit int) (error, *[]domain.Activity)

func (*DB) ReadFollowByAccountIds added in v1.1.0

func (db *DB) ReadFollowByAccountIds(accountId, targetAccountId uuid.UUID) (error, *domain.Follow)

func (*DB) ReadFollowByURI

func (db *DB) ReadFollowByURI(uri string) (error, *domain.Follow)

func (*DB) ReadFollowersByAccountId

func (db *DB) ReadFollowersByAccountId(accountId uuid.UUID) (error, *[]domain.Follow)

func (*DB) ReadFollowingByAccountId

func (db *DB) ReadFollowingByAccountId(accountId uuid.UUID) (error, *[]domain.Follow)

ReadFollowingByAccountId returns all accounts that the given account is following (remote accounts)

func (*DB) ReadGlobalTimelinePosts added in v1.6.0

func (db *DB) ReadGlobalTimelinePosts(limit, offset int) (error, *[]domain.GlobalTimelinePost)

ReadGlobalTimelinePosts returns posts for the global timeline (local notes + remote activities) excluding replies. Uses UNION ALL for efficient SQL-level sorting and pagination.

func (*DB) ReadHashtagsByNoteId added in v1.4.0

func (db *DB) ReadHashtagsByNoteId(noteId uuid.UUID) (error, []string)

ReadHashtagsByNoteId returns all hashtag names for a given note

func (*DB) ReadHomeTimelinePosts added in v1.4.0

func (db *DB) ReadHomeTimelinePosts(accountId uuid.UUID, limit int) (error, *[]domain.HomePost)

ReadHomeTimelinePosts returns a unified home timeline combining local and remote posts. Uses 2 UNION ALL queries (non-boost + boost) for efficient SQL-level sorting.

func (*DB) ReadInfoBoxById added in v1.5.0

func (db *DB) ReadInfoBoxById(id uuid.UUID) (error, *domain.InfoBox)

ReadInfoBoxById returns a single info box by ID

func (*DB) ReadLikeByAccountAndNote added in v1.4.1

func (db *DB) ReadLikeByAccountAndNote(accountId, noteId uuid.UUID) (error, *domain.Like)

ReadLikeByAccountAndNote finds a like by the account that created it and the note it's on

func (*DB) ReadLikeByAccountAndObjectURI added in v1.4.1

func (db *DB) ReadLikeByAccountAndObjectURI(accountId uuid.UUID, objectURI string) (error, *domain.Like)

ReadLikeByAccountAndObjectURI finds a like by account ID and object URI

func (*DB) ReadLikersInfoByNoteId added in v1.5.0

func (db *DB) ReadLikersInfoByNoteId(noteId uuid.UUID) ([]string, error)

ReadLikersInfoByNoteId returns a list of usernames who liked a local note (local and remote users)

func (*DB) ReadLikersInfoByObjectURI added in v1.5.0

func (db *DB) ReadLikersInfoByObjectURI(objectURI string) ([]string, error)

ReadLikersInfoByObjectURI returns a list of usernames who liked a remote post (local and remote users)

func (*DB) ReadLikesByNoteId added in v1.4.1

func (db *DB) ReadLikesByNoteId(noteId uuid.UUID) (error, []domain.Like)

ReadLikesByNoteId returns all likes for a given note

func (*DB) ReadLocalFollowsByAccountId

func (db *DB) ReadLocalFollowsByAccountId(accountId uuid.UUID) (error, *[]domain.Follow)

ReadLocalFollowsByAccountId returns all local users that an account is following

func (*DB) ReadLocalTimelineNotes

func (db *DB) ReadLocalTimelineNotes(accountId uuid.UUID, limit int) (error, *[]domain.Note)

ReadLocalTimelineNotes returns recent notes from local users that the given account follows (plus their own posts)

func (*DB) ReadMentionsByNoteId added in v1.4.0

func (db *DB) ReadMentionsByNoteId(noteId uuid.UUID) (error, []domain.NoteMention)

ReadMentionsByNoteId returns all mentions for a given note

func (*DB) ReadNoteByURI added in v1.4.0

func (db *DB) ReadNoteByURI(objectURI string) (error, *domain.Note)

ReadNoteByURI finds a local note by its ActivityPub object_uri It first tries an exact match on the object_uri column, then falls back to extracting the UUID from the URI pattern /notes/{uuid}

func (*DB) ReadNoteId

func (db *DB) ReadNoteId(id uuid.UUID) (error, *domain.Note)

func (*DB) ReadNoteIdWithReplyInfo added in v1.4.0

func (db *DB) ReadNoteIdWithReplyInfo(id uuid.UUID) (error, *domain.Note)

ReadNoteIdWithReplyInfo returns a note with full reply information

func (*DB) ReadNotesByHashtag added in v1.4.0

func (db *DB) ReadNotesByHashtag(tag string, limit, offset int) (error, *[]domain.Note)

ReadNotesByHashtag returns notes that contain a specific hashtag with pagination

func (*DB) ReadNotesByUserId

func (db *DB) ReadNotesByUserId(userId uuid.UUID) (error, *[]domain.Note)

func (*DB) ReadNotesByUsername

func (db *DB) ReadNotesByUsername(username string) (error, *[]domain.Note)

func (*DB) ReadNotificationsByAccountId added in v1.4.3

func (db *DB) ReadNotificationsByAccountId(accountId uuid.UUID, limit int) (error, *[]domain.Notification)

ReadNotificationsByAccountId retrieves notifications for an account

func (*DB) ReadPendingDeliveries

func (db *DB) ReadPendingDeliveries(limit int) (error, *[]domain.DeliveryQueueItem)

func (*DB) ReadPublicNotesByUsername added in v1.1.0

func (db *DB) ReadPublicNotesByUsername(username string, limit, offset int) (error, *[]domain.Note)

ReadPublicNotesByUsername returns public notes for a user's ActivityPub outbox with pagination Returns notes with full metadata including object_uri for ActivityPub compatibility

func (*DB) ReadRelayByActorURI added in v1.4.2

func (db *DB) ReadRelayByActorURI(actorURI string) (error, *domain.Relay)

ReadRelayByActorURI returns a relay by its actor URI

func (*DB) ReadRelayById added in v1.4.2

func (db *DB) ReadRelayById(id uuid.UUID) (error, *domain.Relay)

ReadRelayById returns a relay by its ID

func (*DB) ReadRemoteAccountByActorURI

func (db *DB) ReadRemoteAccountByActorURI(actorURI string) (error, *domain.RemoteAccount)

ReadRemoteAccountByActorURI reads a remote account by its ActivityPub actor URI

func (*DB) ReadRemoteAccountById

func (db *DB) ReadRemoteAccountById(id uuid.UUID) (error, *domain.RemoteAccount)

func (*DB) ReadRemoteAccountByURI

func (db *DB) ReadRemoteAccountByURI(uri string) (error, *domain.RemoteAccount)

func (*DB) ReadRepliesByNoteId added in v1.4.0

func (db *DB) ReadRepliesByNoteId(noteId uuid.UUID) (error, *[]domain.Note)

ReadRepliesByNoteId returns all direct replies to a local note by its UUID

func (*DB) ReadRepliesByURI added in v1.4.0

func (db *DB) ReadRepliesByURI(objectURI string) (error, *[]domain.Note)

ReadRepliesByURI returns all direct replies to a note by its ActivityPub URI

func (*DB) ReadServerMessage added in v1.5.2

func (db *DB) ReadServerMessage() (error, *domain.ServerMessage)

ReadServerMessage returns the current server message (single row)

func (*DB) ReadUnreadNotificationCount added in v1.4.3

func (db *DB) ReadUnreadNotificationCount(accountId uuid.UUID) (int, error)

ReadUnreadNotificationCount returns the count of unread notifications for an account

func (*DB) RecordUserTermsAcceptance added in v1.6.3

func (db *DB) RecordUserTermsAcceptance(userId uuid.UUID) error

RecordUserTermsAcceptance records that a user has accepted the terms and conditions

func (*DB) RunActivityPubMigrations

func (db *DB) RunActivityPubMigrations() error

RunActivityPubMigrations runs ActivityPub-specific migrations

func (*DB) RunMigrations

func (db *DB) RunMigrations() error

RunMigrations executes all database migrations

func (*DB) SearchPosts added in v1.7.1

func (db *DB) SearchPosts(query string, maxResults int) (error, []domain.SearchResult)

SearchPosts searches the FTS5 index for posts matching the query. The FTS5 table only stores content+author. Metadata comes from the lookup table, and object_uri/object_url are loaded from the source tables (notes/activities).

func (*DB) ToggleInfoBoxEnabled added in v1.5.0

func (db *DB) ToggleInfoBoxEnabled(id uuid.UUID) error

ToggleInfoBoxEnabled toggles the enabled status of an info box

func (*DB) UnbanAccount added in v1.6.0

func (db *DB) UnbanAccount(accountId uuid.UUID) error

UnbanAccount clears the banned flag on an account

func (*DB) UnmuteUser added in v1.1.0

func (db *DB) UnmuteUser(accountId uuid.UUID) error

UnmuteUser unmutes a user

func (*DB) UpdateAccountAvatar added in v1.5.0

func (db *DB) UpdateAccountAvatar(accountId uuid.UUID, avatarURL string) error

UpdateAccountAvatar updates only the avatar URL for an account

func (*DB) UpdateAccountDisplayName added in v1.5.0

func (db *DB) UpdateAccountDisplayName(accountId uuid.UUID, displayName string) error

UpdateAccountDisplayName updates only the display name for an account

func (*DB) UpdateAccountLastIP added in v1.6.0

func (db *DB) UpdateAccountLastIP(accountId uuid.UUID, ipAddress string) error

UpdateAccountLastIP updates the last_ip field for an account

func (*DB) UpdateAccountLastIPByPkHash added in v1.6.0

func (db *DB) UpdateAccountLastIPByPkHash(pkHash string, ipAddress string) error

UpdateAccountLastIPByPkHash updates the last_ip field for an account by public key hash

func (*DB) UpdateAccountSummary added in v1.5.0

func (db *DB) UpdateAccountSummary(accountId uuid.UUID, summary string) error

UpdateAccountSummary updates only the bio/summary for an account

func (*DB) UpdateActivity

func (db *DB) UpdateActivity(activity *domain.Activity) error

func (*DB) UpdateDeliveryAttempt

func (db *DB) UpdateDeliveryAttempt(id uuid.UUID, attempts int, nextRetry time.Time) error

func (*DB) UpdateInfoBox added in v1.5.0

func (db *DB) UpdateInfoBox(box *domain.InfoBox) error

UpdateInfoBox updates an existing info box

func (*DB) UpdateLoginById

func (db *DB) UpdateLoginById(username string, displayName string, summary string, id uuid.UUID) error

func (*DB) UpdateLoginByPkHash

func (db *DB) UpdateLoginByPkHash(username string, displayName string, summary string, pkHash string) error

func (*DB) UpdateNote

func (db *DB) UpdateNote(noteId uuid.UUID, message string) error

func (*DB) UpdateNoteFTS added in v1.7.1

func (db *DB) UpdateNoteFTS(noteId uuid.UUID, author, message, createdAt, objectURI string)

UpdateNoteFTS updates a note in the FTS index (delete + re-insert)

func (*DB) UpdateNoteLikeCount added in v1.4.1

func (db *DB) UpdateNoteLikeCount(noteId uuid.UUID, count int) error

UpdateNoteLikeCount updates the like_count for a specific note

func (*DB) UpdateRelayPaused added in v1.4.2

func (db *DB) UpdateRelayPaused(id uuid.UUID, paused bool) error

UpdateRelayPaused updates a relay's paused status

func (*DB) UpdateRelayStatus added in v1.4.2

func (db *DB) UpdateRelayStatus(id uuid.UUID, status string, acceptedAt *time.Time) error

UpdateRelayStatus updates a relay's status and optionally sets accepted_at

func (*DB) UpdateRemoteAccount

func (db *DB) UpdateRemoteAccount(acc *domain.RemoteAccount) error

func (*DB) UpdateServerMessage added in v1.5.2

func (db *DB) UpdateServerMessage(message string, enabled bool, webEnabled bool) error

UpdateServerMessage updates the server message (creates if doesn't exist)

func (*DB) UpdateTermsAndConditions added in v1.6.3

func (db *DB) UpdateTermsAndConditions(content string) error

UpdateTermsAndConditions updates the terms and conditions

func (*DB) UserNeedsToAcceptTerms added in v1.6.3

func (db *DB) UserNeedsToAcceptTerms(userId uuid.UUID) (bool, error)

UserNeedsToAcceptTerms checks if a user needs to accept terms and conditions. Returns true if: - Terms exist and user has never accepted them - Terms were updated after user's last acceptance

func (*DB) ValidateUploadToken added in v1.5.0

func (db *DB) ValidateUploadToken(token string) (uuid.UUID, string, error)

ValidateUploadToken validates a token and returns the account ID if valid

Jump to

Keyboard shortcuts

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