Documentation ¶
Index ¶
- Constants
- Variables
- func ToNamedValues(args []driver.Value) []driver.NamedValue
- type Account
- type Admin
- type Application
- type Basic
- type DB
- type Domain
- type Emoji
- type Filter
- type HeaderFilter
- type Instance
- type List
- type Marker
- type Media
- type Mention
- type Move
- type Notification
- type Poll
- type Relationship
- type Report
- type Rule
- type Search
- type Session
- type Status
- type StatusBookmark
- type StatusFave
- type Tag
- type Thread
- type Timeline
- type Tombstone
- type User
- type Where
Constants ¶
const ( // DBTypePostgres represents an underlying POSTGRES database type. DBTypePostgres string = "POSTGRES" )
const EmojiAllDomains string = "all"
EmojiAllDomains can be used as the `domain` value in a GetEmojis query to indicate that emojis from all domains should be returned.
Variables ¶
var ( // ErrNoEntries is a direct ptr to sql.ErrNoRows since that is returned regardless // of DB dialect. It is returned when no rows (entries) can be found for a query. ErrNoEntries = sql.ErrNoRows // ErrAlreadyExists is returned when a conflict was encountered in the db when doing an insert. ErrAlreadyExists = errors.New("already exists") )
Functions ¶
func ToNamedValues ¶ added in v0.16.0
func ToNamedValues(args []driver.Value) []driver.NamedValue
ToNamedValues converts older driver.Value types to driver.NamedValue types.
Types ¶
type Account ¶
type Account interface { // GetAccountByID returns one account with the given ID, or an error if something goes wrong. GetAccountByID(ctx context.Context, id string) (*gtsmodel.Account, error) // GetAccountsByIDs returns accounts corresponding to given IDs. GetAccountsByIDs(ctx context.Context, ids []string) ([]*gtsmodel.Account, error) // GetAccountByURI returns one account with the given URI, or an error if something goes wrong. GetAccountByURI(ctx context.Context, uri string) (*gtsmodel.Account, error) // GetAccountByURL returns one account with the given URL, or an error if something goes wrong. GetAccountByURL(ctx context.Context, uri string) (*gtsmodel.Account, error) // GetAccountByUsernameDomain returns one account with the given username and domain, or an error if something goes wrong. GetAccountByUsernameDomain(ctx context.Context, username string, domain string) (*gtsmodel.Account, error) // GetAccountByPubkeyID returns one account with the given public key URI (ID), or an error if something goes wrong. GetAccountByPubkeyID(ctx context.Context, id string) (*gtsmodel.Account, error) // GetAccountByInboxURI returns one account with the given inbox_uri, or an error if something goes wrong. GetAccountByInboxURI(ctx context.Context, uri string) (*gtsmodel.Account, error) // GetAccountByOutboxURI returns one account with the given outbox_uri, or an error if something goes wrong. GetAccountByOutboxURI(ctx context.Context, uri string) (*gtsmodel.Account, error) // GetAccountByFollowingURI returns one account with the given following_uri, or an error if something goes wrong. GetAccountByFollowingURI(ctx context.Context, uri string) (*gtsmodel.Account, error) // GetAccountByFollowersURI returns one account with the given followers_uri, or an error if something goes wrong. GetAccountByFollowersURI(ctx context.Context, uri string) (*gtsmodel.Account, error) // GetAccounts returns accounts // with the given parameters. GetAccounts( ctx context.Context, origin string, status string, mods bool, invitedBy string, username string, displayName string, domain string, email string, ip netip.Addr, page *paging.Page, ) ( []*gtsmodel.Account, error, ) // PopulateAccount ensures that all sub-models of an account are populated (e.g. avatar, header etc). PopulateAccount(ctx context.Context, account *gtsmodel.Account) error // PutAccount puts one account in the database. PutAccount(ctx context.Context, account *gtsmodel.Account) error // UpdateAccount updates one account by ID. UpdateAccount(ctx context.Context, account *gtsmodel.Account, columns ...string) error // DeleteAccount deletes one account from the database by its ID. // DO NOT USE THIS WHEN SUSPENDING ACCOUNTS! In that case you should mark the // account as suspended instead, rather than deleting from the db entirely. DeleteAccount(ctx context.Context, id string) error // GetAccountCustomCSSByUsername returns the custom css of an account on this instance with the given username. GetAccountCustomCSSByUsername(ctx context.Context, username string) (string, error) // GetAccountFaves fetches faves/likes created by the target accountID. GetAccountFaves(ctx context.Context, accountID string) ([]*gtsmodel.StatusFave, error) // GetAccountsUsingEmoji fetches all account models using emoji with given ID stored in their 'emojis' column. GetAccountsUsingEmoji(ctx context.Context, emojiID string) ([]*gtsmodel.Account, error) // GetAccountStatuses is a shortcut for getting the most recent statuses. accountID is optional, if not provided // then all statuses will be returned. If limit is set to 0, the size of the returned slice will not be limited. This can // be very memory intensive so you probably shouldn't do this! // // In the case of no statuses, this function will return db.ErrNoEntries. GetAccountStatuses(ctx context.Context, accountID string, limit int, excludeReplies bool, excludeReblogs bool, maxID string, minID string, mediaOnly bool, publicOnly bool) ([]*gtsmodel.Status, error) // GetAccountPinnedStatuses returns ONLY statuses owned by the give accountID for which a corresponding StatusPin // exists in the database. Statuses which are not pinned will not be returned by this function. // // Statuses will be returned in the order in which they were pinned, from latest pinned to oldest pinned (descending). // // In the case of no statuses, this function will return db.ErrNoEntries. GetAccountPinnedStatuses(ctx context.Context, accountID string) ([]*gtsmodel.Status, error) // GetAccountWebStatuses is similar to GetAccountStatuses, but it's specifically for returning statuses that // should be visible via the web view of an account. So, only public, federated statuses that aren't boosts // or replies. // // In the case of no statuses, this function will return db.ErrNoEntries. GetAccountWebStatuses(ctx context.Context, accountID string, limit int, maxID string) ([]*gtsmodel.Status, error) // SetAccountHeaderOrAvatar sets the header or avatar for the given accountID to the given media attachment. SetAccountHeaderOrAvatar(ctx context.Context, mediaAttachment *gtsmodel.MediaAttachment, accountID string) error // GetInstanceAccount returns the instance account for the given domain. // If domain is empty, this instance account will be returned. GetInstanceAccount(ctx context.Context, domain string) (*gtsmodel.Account, error) // Get local account settings with the given ID. GetAccountSettings(ctx context.Context, id string) (*gtsmodel.AccountSettings, error) // Store local account settings. PutAccountSettings(ctx context.Context, settings *gtsmodel.AccountSettings) error // Update local account settings. UpdateAccountSettings(ctx context.Context, settings *gtsmodel.AccountSettings, columns ...string) error // PopulateAccountStats gets (or creates and gets) account stats for // the given account, and attaches them to the account model. PopulateAccountStats(ctx context.Context, account *gtsmodel.Account) error // RegenerateAccountStats creates, upserts, and returns stats // for the given account, and attaches them to the account model. // // Unlike GetAccountStats, it will always get the database stats fresh. // This can be used to "refresh" stats. // // Because this involves database calls that can be expensive (on Postgres // specifically), callers should prefer GetAccountStats in 99% of cases. RegenerateAccountStats(ctx context.Context, account *gtsmodel.Account) error // Update account stats. UpdateAccountStats(ctx context.Context, stats *gtsmodel.AccountStats, columns ...string) error // DeleteAccountStats deletes the accountStats entry for the given accountID. DeleteAccountStats(ctx context.Context, accountID string) error }
Account contains functions related to account getting/setting/creation.
type Admin ¶
type Admin interface { // IsUsernameAvailable checks whether a given username is available on our domain. // Returns an error if the username is already taken, or something went wrong in the db. IsUsernameAvailable(ctx context.Context, username string) (bool, error) // IsEmailAvailable checks whether a given email address for a new account is available to be used on our domain. // Return an error if: // A) the email is already associated with an account // B) we block signups from this email domain // C) something went wrong in the db IsEmailAvailable(ctx context.Context, email string) (bool, error) // NewSignup creates a new user + account in the database with the given parameters. // By the time this function is called, it should be assumed that all the parameters have passed validation! NewSignup(ctx context.Context, newSignup gtsmodel.NewSignup) (*gtsmodel.User, error) // CreateInstanceAccount creates an account in the database with the same username as the instance host value. // Ie., if the instance is hosted at 'example.org' the instance user will have a username of 'example.org'. // This is needed for things like serving files that belong to the instance and not an individual user/account. CreateInstanceAccount(ctx context.Context) error // CreateInstanceInstance creates an instance in the database with the same domain as the instance host value. // Ie., if the instance is hosted at 'example.org' the instance will have a domain of 'example.org'. // This is needed for things like serving instance information through /api/v1/instance CreateInstanceInstance(ctx context.Context) error // CreateInstanceApplication creates an application in the database // for use in processing signups etc through the sign-up form. CreateInstanceApplication(ctx context.Context) error // GetInstanceApplication gets the instance application // (ie., the application owned by the instance account). GetInstanceApplication(ctx context.Context) (*gtsmodel.Application, error) // CountApprovedSignupsSince counts the number of new account // sign-ups approved on this instance since the given time. CountApprovedSignupsSince(ctx context.Context, since time.Time) (int, error) // CountUnhandledSignups counts the number of account sign-ups // that have not yet been approved or denied. In other words, // the number of pending sign-ups sitting in the backlog. CountUnhandledSignups(ctx context.Context) (int, error) // GetAdminAction returns the admin action with the given ID. GetAdminAction(ctx context.Context, id string) (*gtsmodel.AdminAction, error) // GetAdminActions gets all admin actions from the database. GetAdminActions(ctx context.Context) ([]*gtsmodel.AdminAction, error) // PutAdminAction puts one admin action in the database. PutAdminAction(ctx context.Context, action *gtsmodel.AdminAction) error // UpdateAdminAction updates one admin action by its ID. UpdateAdminAction(ctx context.Context, action *gtsmodel.AdminAction, columns ...string) error // DeleteAdminAction deletes admin action with the given ID. DeleteAdminAction(ctx context.Context, id string) error }
Admin contains functions related to instance administration (new signups etc).
type Application ¶ added in v0.11.0
type Application interface { // GetApplicationByID fetches the application from the database with corresponding ID value. GetApplicationByID(ctx context.Context, id string) (*gtsmodel.Application, error) // GetApplicationByClientID fetches the application from the database with corresponding client_id value. GetApplicationByClientID(ctx context.Context, clientID string) (*gtsmodel.Application, error) // PutApplication places the new application in the database, erroring on non-unique ID or client_id. PutApplication(ctx context.Context, app *gtsmodel.Application) error // DeleteApplicationByClientID deletes the application with corresponding client_id value from the database. DeleteApplicationByClientID(ctx context.Context, clientID string) error // GetClientByID ... GetClientByID(ctx context.Context, id string) (*gtsmodel.Client, error) // PutClient ... PutClient(ctx context.Context, client *gtsmodel.Client) error // DeleteClientByID ... DeleteClientByID(ctx context.Context, id string) error // GetAllTokens ... GetAllTokens(ctx context.Context) ([]*gtsmodel.Token, error) // GetTokenByCode ... GetTokenByCode(ctx context.Context, code string) (*gtsmodel.Token, error) // GetTokenByAccess ... GetTokenByAccess(ctx context.Context, access string) (*gtsmodel.Token, error) // GetTokenByRefresh ... GetTokenByRefresh(ctx context.Context, refresh string) (*gtsmodel.Token, error) // PutToken ... PutToken(ctx context.Context, token *gtsmodel.Token) error // DeleteTokenByID ... DeleteTokenByID(ctx context.Context, id string) error // DeleteTokenByCode ... DeleteTokenByCode(ctx context.Context, code string) error // DeleteTokenByAccess ... DeleteTokenByAccess(ctx context.Context, access string) error // DeleteTokenByRefresh ... DeleteTokenByRefresh(ctx context.Context, refresh string) error }
type Basic ¶
type Basic interface { // CreateTable creates a table for the given interface. // For implementations that don't use tables, this can just return nil. CreateTable(ctx context.Context, i interface{}) error // DropTable drops the table for the given interface. // For implementations that don't use tables, this can just return nil. DropTable(ctx context.Context, i interface{}) error // Close should stop and close the database connection cleanly, returning an error if this is not possible. // If the database implementation doesn't need to be stopped, this can just return nil. Close() error // Ready returns nil if the database connection is ready, or an error if not. Ready(ctx context.Context) error // GetByID gets one entry by its id. In a database like postgres, this might be the 'id' field of the entry, // for other implementations (for example, in-memory) it might just be the key of a map. // The given interface i will be set to the result of the query, whatever it is. Use a pointer or a slice. // In case of no entries, a 'no entries' error will be returned GetByID(ctx context.Context, id string, i interface{}) error // GetWhere gets one entry where key = value. This is similar to GetByID but allows the caller to specify the // name of the key to select from. // The given interface i will be set to the result of the query, whatever it is. Use a pointer or a slice. // In case of no entries, a 'no entries' error will be returned GetWhere(ctx context.Context, where []Where, i interface{}) error // GetAll will try to get all entries of type i. // The given interface i will be set to the result of the query, whatever it is. Use a pointer or a slice. // In case of no entries, a 'no entries' error will be returned GetAll(ctx context.Context, i interface{}) error // Put simply stores i. It is up to the implementation to figure out how to store it, and using what key. // The given interface i will be set to the result of the query, whatever it is. Use a pointer or a slice. Put(ctx context.Context, i interface{}) error // UpdateByID updates values of i based on its id. // If any columns are specified, these will be updated exclusively. // Otherwise, the whole model will be updated. // The given interface i will be set to the result of the query, whatever it is. Use a pointer or a slice. UpdateByID(ctx context.Context, i interface{}, id string, columns ...string) error // UpdateWhere updates column key of interface i with the given value, where the given parameters apply. UpdateWhere(ctx context.Context, where []Where, key string, value interface{}, i interface{}) error // DeleteByID removes i with id id. // If i didn't exist anyway, then no error should be returned. DeleteByID(ctx context.Context, id string, i interface{}) error // DeleteWhere deletes i where key = value // If i didn't exist anyway, then no error should be returned. DeleteWhere(ctx context.Context, where []Where, i interface{}) error }
Basic wraps basic database functionality.
type DB ¶
type DB interface { Account Admin Application Basic Domain Emoji HeaderFilter Instance Filter List Marker Media Mention Move Notification Poll Relationship Report Rule Search Session Status StatusBookmark StatusFave Tag Thread Timeline User Tombstone }
DB provides methods for interacting with an underlying database or other storage mechanism.
type Domain ¶
type Domain interface { // CreateDomainAllow puts the given instance-level domain allow into the database. CreateDomainAllow(ctx context.Context, allow *gtsmodel.DomainAllow) error // GetDomainAllow returns one instance-level domain allow with the given domain, if it exists. GetDomainAllow(ctx context.Context, domain string) (*gtsmodel.DomainAllow, error) // GetDomainAllowByID returns one instance-level domain allow with the given id, if it exists. GetDomainAllowByID(ctx context.Context, id string) (*gtsmodel.DomainAllow, error) // GetDomainAllows returns all instance-level domain allows currently enforced by this instance. GetDomainAllows(ctx context.Context) ([]*gtsmodel.DomainAllow, error) // DeleteDomainAllow deletes an instance-level domain allow with the given domain, if it exists. DeleteDomainAllow(ctx context.Context, domain string) error // CreateDomainBlock puts the given instance-level domain block into the database. CreateDomainBlock(ctx context.Context, block *gtsmodel.DomainBlock) error // GetDomainBlock returns one instance-level domain block with the given domain, if it exists. GetDomainBlock(ctx context.Context, domain string) (*gtsmodel.DomainBlock, error) // GetDomainBlockByID returns one instance-level domain block with the given id, if it exists. GetDomainBlockByID(ctx context.Context, id string) (*gtsmodel.DomainBlock, error) // GetDomainBlocks returns all instance-level domain blocks currently enforced by this instance. GetDomainBlocks(ctx context.Context) ([]*gtsmodel.DomainBlock, error) // DeleteDomainBlock deletes an instance-level domain block with the given domain, if it exists. DeleteDomainBlock(ctx context.Context, domain string) error // IsDomainBlocked checks if domain is blocked, accounting for both explicit allows and blocks. // Will check allows first, so an allowed domain will always return false, even if it's also blocked. IsDomainBlocked(ctx context.Context, domain string) (bool, error) // AreDomainsBlocked calls IsDomainBlocked for each domain. // Will return true if even one of the given domains is blocked. AreDomainsBlocked(ctx context.Context, domains []string) (bool, error) // IsURIBlocked calls IsDomainBlocked for the host of the given URI. IsURIBlocked(ctx context.Context, uri *url.URL) (bool, error) // AreURIsBlocked calls IsURIBlocked for each URI. // Will return true if even one of the given URIs is blocked. AreURIsBlocked(ctx context.Context, uris []*url.URL) (bool, error) }
Domain contains DB functions related to domains and domain blocks.
type Emoji ¶ added in v0.3.4
type Emoji interface { // PutEmoji puts one emoji in the database. PutEmoji(ctx context.Context, emoji *gtsmodel.Emoji) error // UpdateEmoji updates the given columns of one emoji. // If no columns are specified, every column is updated. UpdateEmoji(ctx context.Context, emoji *gtsmodel.Emoji, columns ...string) error // DeleteEmojiByID deletes one emoji by its database ID. DeleteEmojiByID(ctx context.Context, id string) error // GetEmojisByIDs gets emojis for the given IDs. GetEmojisByIDs(ctx context.Context, ids []string) ([]*gtsmodel.Emoji, error) // GetUseableEmojis gets all emojis which are useable by accounts on this instance. GetUseableEmojis(ctx context.Context) ([]*gtsmodel.Emoji, error) // GetEmojis fetches all emojis with IDs less than 'maxID', up to a maximum of 'limit' emojis. GetEmojis(ctx context.Context, page *paging.Page) ([]*gtsmodel.Emoji, error) // GetRemoteEmojis fetches all remote emojis with IDs less than 'maxID', up to a maximum of 'limit' emojis. GetRemoteEmojis(ctx context.Context, page *paging.Page) ([]*gtsmodel.Emoji, error) // GetCachedEmojisOlderThan fetches all cached remote emojis with 'updated_at' greater than 'olderThan', up to a maximum of 'limit' emojis. GetCachedEmojisOlderThan(ctx context.Context, olderThan time.Time, limit int) ([]*gtsmodel.Emoji, error) // GetEmojisBy gets emojis based on given parameters. Useful for admin actions. GetEmojisBy(ctx context.Context, domain string, includeDisabled bool, includeEnabled bool, shortcode string, maxShortcodeDomain string, minShortcodeDomain string, limit int) ([]*gtsmodel.Emoji, error) // GetEmojiByID gets a specific emoji by its database ID. GetEmojiByID(ctx context.Context, id string) (*gtsmodel.Emoji, error) // PopulateEmoji populates the struct pointers on the given emoji. PopulateEmoji(ctx context.Context, emoji *gtsmodel.Emoji) error // GetEmojiByShortcodeDomain gets an emoji based on its shortcode and domain. // For local emoji, domain should be an empty string. GetEmojiByShortcodeDomain(ctx context.Context, shortcode string, domain string) (*gtsmodel.Emoji, error) // GetEmojiByURI returns one emoji based on its ActivityPub URI. GetEmojiByURI(ctx context.Context, uri string) (*gtsmodel.Emoji, error) // GetEmojiByStaticURL gets an emoji using the URL of the static version of the emoji image. GetEmojiByStaticURL(ctx context.Context, imageStaticURL string) (*gtsmodel.Emoji, error) // PutEmojiCategory puts one new emoji category in the database. PutEmojiCategory(ctx context.Context, emojiCategory *gtsmodel.EmojiCategory) error // GetEmojiCategoriesByIDs gets emoji categories for given IDs. GetEmojiCategoriesByIDs(ctx context.Context, ids []string) ([]*gtsmodel.EmojiCategory, error) // GetEmojiCategories gets a slice of the names of all existing emoji categories. GetEmojiCategories(ctx context.Context) ([]*gtsmodel.EmojiCategory, error) // GetEmojiCategory gets one emoji category by its id. GetEmojiCategory(ctx context.Context, id string) (*gtsmodel.EmojiCategory, error) // GetEmojiCategoryByName gets one emoji category by its name. GetEmojiCategoryByName(ctx context.Context, name string) (*gtsmodel.EmojiCategory, error) }
Emoji contains functions for getting emoji in the database.
type Filter ¶ added in v0.15.0
type Filter interface { // GetFilterByID gets one filter with the given id. GetFilterByID(ctx context.Context, id string) (*gtsmodel.Filter, error) // GetFiltersForAccountID gets all filters owned by the given accountID. GetFiltersForAccountID(ctx context.Context, accountID string) ([]*gtsmodel.Filter, error) // PutFilter puts a new filter in the database, adding any attached keywords or statuses. // It uses a transaction to ensure no partial updates. PutFilter(ctx context.Context, filter *gtsmodel.Filter) error // UpdateFilter updates the given filter, // upserts any attached keywords and inserts any new statuses (existing statuses cannot be updated), // and deletes indicated filter keywords and statuses by ID. // It uses a transaction to ensure no partial updates. // The column lists are optional; if not specified, all columns will be updated. // The filter keyword columns list is *per keyword*. // To update all keyword columns, provide a list where every element is an empty list. UpdateFilter( ctx context.Context, filter *gtsmodel.Filter, filterColumns []string, filterKeywordColumns [][]string, deleteFilterKeywordIDs []string, deleteFilterStatusIDs []string, ) error // DeleteFilterByID deletes one filter with the given ID. // It uses a transaction to ensure no partial updates. DeleteFilterByID(ctx context.Context, id string) error // GetFilterKeywordByID gets one filter keyword with the given ID. GetFilterKeywordByID(ctx context.Context, id string) (*gtsmodel.FilterKeyword, error) // GetFilterKeywordsForFilterID gets filter keywords from the given filterID. GetFilterKeywordsForFilterID(ctx context.Context, filterID string) ([]*gtsmodel.FilterKeyword, error) // GetFilterKeywordsForAccountID gets filter keywords from the given accountID. GetFilterKeywordsForAccountID(ctx context.Context, accountID string) ([]*gtsmodel.FilterKeyword, error) // PutFilterKeyword inserts a single filter keyword into the database. PutFilterKeyword(ctx context.Context, filterKeyword *gtsmodel.FilterKeyword) error // UpdateFilterKeyword updates the given filter keyword. // Columns is optional, if not specified all will be updated. UpdateFilterKeyword(ctx context.Context, filterKeyword *gtsmodel.FilterKeyword, columns ...string) error // DeleteFilterKeywordByID deletes one filter keyword with the given id. DeleteFilterKeywordByID(ctx context.Context, id string) error // GetFilterStatusByID gets one filter status with the given ID. GetFilterStatusByID(ctx context.Context, id string) (*gtsmodel.FilterStatus, error) // GetFilterStatusesForFilterID gets filter statuses from the given filterID. GetFilterStatusesForFilterID(ctx context.Context, filterID string) ([]*gtsmodel.FilterStatus, error) // GetFilterStatusesForAccountID gets filter keywords from the given accountID. GetFilterStatusesForAccountID(ctx context.Context, accountID string) ([]*gtsmodel.FilterStatus, error) // PutFilterStatus inserts a single filter status into the database. PutFilterStatus(ctx context.Context, filterStatus *gtsmodel.FilterStatus) error // DeleteFilterStatusByID deletes one filter status with the given id. DeleteFilterStatusByID(ctx context.Context, id string) error }
Filter contains methods for creating, reading, updating, and deleting filters and their keyword and status entries.
type HeaderFilter ¶ added in v0.14.0
type HeaderFilter interface { // AllowHeaderRegularMatch performs an headerfilter.Filter.RegularMatch() on cached allow header filters. // (Note: the actual matching code can be found under ./internal/headerfilter/ ). AllowHeaderRegularMatch(ctx context.Context, hdr http.Header) (string, string, error) // AllowHeaderInverseMatch performs an headerfilter.Filter.InverseMatch() on cached allow header filters. // (Note: the actual matching code can be found under ./internal/headerfilter/ ). AllowHeaderInverseMatch(ctx context.Context, hdr http.Header) (string, string, error) // BlockHeaderRegularMatch performs an headerfilter.Filter.RegularMatch() on cached block header filters. // (Note: the actual matching code can be found under ./internal/headerfilter/ ). BlockHeaderRegularMatch(ctx context.Context, hdr http.Header) (string, string, error) // BlockHeaderInverseMatch performs an headerfilter.Filter.InverseMatch() on cached block header filters. // (Note: the actual matching code can be found under ./internal/headerfilter/ ). BlockHeaderInverseMatch(ctx context.Context, hdr http.Header) (string, string, error) // GetAllowHeaderFilter fetches the allow header filter with ID from the database. GetAllowHeaderFilter(ctx context.Context, id string) (*gtsmodel.HeaderFilter, error) // GetBlockHeaderFilter fetches the block header filter with ID from the database. GetBlockHeaderFilter(ctx context.Context, id string) (*gtsmodel.HeaderFilter, error) // GetAllowHeaderFilters fetches all allow header filters from the database. GetAllowHeaderFilters(ctx context.Context) ([]*gtsmodel.HeaderFilter, error) // GetBlockHeaderFilters fetches all block header filters from the database. GetBlockHeaderFilters(ctx context.Context) ([]*gtsmodel.HeaderFilter, error) // PutAllowHeaderFilter inserts the given allow header filter into the database. PutAllowHeaderFilter(ctx context.Context, filter *gtsmodel.HeaderFilter) error // PutBlockHeaderFilter inserts the given block header filter into the database. PutBlockHeaderFilter(ctx context.Context, filter *gtsmodel.HeaderFilter) error // UpdateAllowHeaderFilter updates the given allow header filter in the database, only updating given columns if provided. UpdateAllowHeaderFilter(ctx context.Context, filter *gtsmodel.HeaderFilter, cols ...string) error // UpdateBlockHeaderFilter updates the given block header filter in the database, only updating given columns if provided. UpdateBlockHeaderFilter(ctx context.Context, filter *gtsmodel.HeaderFilter, cols ...string) error // DeleteAllowHeaderFilter deletes the allow header filter with ID from the database. DeleteAllowHeaderFilter(ctx context.Context, id string) error // DeleteBlockHeaderFilter deletes the block header filter with ID from the database. DeleteBlockHeaderFilter(ctx context.Context, id string) error }
type Instance ¶
type Instance interface { // CountInstanceUsers returns the number of known accounts registered with the given domain. CountInstanceUsers(ctx context.Context, domain string) (int, error) // CountInstanceStatuses returns the number of known statuses posted from the given domain. CountInstanceStatuses(ctx context.Context, domain string) (int, error) // CountInstanceDomains returns the number of known instances known that the given domain federates with. CountInstanceDomains(ctx context.Context, domain string) (int, error) // GetInstance returns the instance entry for the given domain, if it exists. GetInstance(ctx context.Context, domain string) (*gtsmodel.Instance, error) // GetInstanceByID returns the instance entry corresponding to the given id, if it exists. GetInstanceByID(ctx context.Context, id string) (*gtsmodel.Instance, error) // PopulateInstance populates the struct pointers on the given instance. PopulateInstance(ctx context.Context, instance *gtsmodel.Instance) error // PutInstance inserts the given instance into the database. PutInstance(ctx context.Context, instance *gtsmodel.Instance) error // UpdateInstance updates the given instance entry. UpdateInstance(ctx context.Context, instance *gtsmodel.Instance, columns ...string) error // GetInstanceAccounts returns a slice of accounts from the given instance, arranged by ID. GetInstanceAccounts(ctx context.Context, domain string, maxID string, limit int) ([]*gtsmodel.Account, error) // GetInstancePeers returns a slice of instances that the host instance knows about. GetInstancePeers(ctx context.Context, includeSuspended bool) ([]*gtsmodel.Instance, error) // GetInstanceModeratorAddresses returns a slice of email addresses belonging to active // (as in, not suspended) moderators + admins on this instance. GetInstanceModeratorAddresses(ctx context.Context) ([]string, error) // GetInstanceModerators returns a slice of accounts belonging to active // (as in, non suspended) moderators + admins on this instance. GetInstanceModerators(ctx context.Context) ([]*gtsmodel.Account, error) }
Instance contains functions for instance-level actions (counting instance users etc.).
type List ¶ added in v0.10.0
type List interface { // GetListByID gets one list with the given id. GetListByID(ctx context.Context, id string) (*gtsmodel.List, error) // GetListsByIDs fetches all lists with the provided IDs. GetListsByIDs(ctx context.Context, ids []string) ([]*gtsmodel.List, error) // GetListsForAccountID gets all lists owned by the given accountID. GetListsForAccountID(ctx context.Context, accountID string) ([]*gtsmodel.List, error) // PopulateList ensures that the list's struct fields are populated. PopulateList(ctx context.Context, list *gtsmodel.List) error // PutList puts a new list in the database. PutList(ctx context.Context, list *gtsmodel.List) error // UpdateList updates the given list. // Columns is optional, if not specified all will be updated. UpdateList(ctx context.Context, list *gtsmodel.List, columns ...string) error // DeleteListByID deletes one list with the given ID. DeleteListByID(ctx context.Context, id string) error // GetListEntryByID gets one list entry with the given ID. GetListEntryByID(ctx context.Context, id string) (*gtsmodel.ListEntry, error) // GetListEntriesyIDs fetches all list entries with the provided IDs. GetListEntriesByIDs(ctx context.Context, ids []string) ([]*gtsmodel.ListEntry, error) // GetListEntries gets list entries from the given listID, using the given parameters. GetListEntries(ctx context.Context, listID string, maxID string, sinceID string, minID string, limit int) ([]*gtsmodel.ListEntry, error) // GetListEntriesForFollowID returns all listEntries that pertain to the given followID. GetListEntriesForFollowID(ctx context.Context, followID string) ([]*gtsmodel.ListEntry, error) // PopulateListEntry ensures that the listEntry's struct fields are populated. PopulateListEntry(ctx context.Context, listEntry *gtsmodel.ListEntry) error // PutListEntries inserts a slice of listEntries into the database. // It uses a transaction to ensure no partial updates. PutListEntries(ctx context.Context, listEntries []*gtsmodel.ListEntry) error // DeleteListEntry deletes one list entry with the given id. DeleteListEntry(ctx context.Context, id string) error // DeleteListEntryForFollowID deletes all list entries with the given followID. DeleteListEntriesForFollowID(ctx context.Context, followID string) error // ListIncludesAccount returns true if the given listID includes the given accountID. ListIncludesAccount(ctx context.Context, listID string, accountID string) (bool, error) }
type Media ¶
type Media interface { // GetAttachmentByID gets a single attachment by its ID. GetAttachmentByID(ctx context.Context, id string) (*gtsmodel.MediaAttachment, error) // GetAttachmentsByIDs fetches a list of media attachments for given IDs. GetAttachmentsByIDs(ctx context.Context, ids []string) ([]*gtsmodel.MediaAttachment, error) // PutAttachment inserts the given attachment into the database. PutAttachment(ctx context.Context, media *gtsmodel.MediaAttachment) error // UpdateAttachment will update the given attachment in the database. UpdateAttachment(ctx context.Context, media *gtsmodel.MediaAttachment, columns ...string) error // DeleteAttachment deletes the attachment with given ID from the database. DeleteAttachment(ctx context.Context, id string) error // GetAttachments fetches media attachments up to a given max ID, and at most limit. GetAttachments(ctx context.Context, page *paging.Page) ([]*gtsmodel.MediaAttachment, error) // GetRemoteAttachments fetches media attachments with a non-empty domain, up to a given max ID, and at most limit. GetRemoteAttachments(ctx context.Context, page *paging.Page) ([]*gtsmodel.MediaAttachment, error) // GetCachedAttachmentsOlderThan gets limit n remote attachments (including avatars and headers) older than // the given time. These will be returned in order of attachment.created_at descending (i.e. newest to oldest). GetCachedAttachmentsOlderThan(ctx context.Context, olderThan time.Time, limit int) ([]*gtsmodel.MediaAttachment, error) }
Media contains functions related to creating/getting/removing media attachments.
type Mention ¶
type Mention interface { // GetMention gets a single mention by ID GetMention(ctx context.Context, id string) (*gtsmodel.Mention, error) // GetMentions gets multiple mentions. GetMentions(ctx context.Context, ids []string) ([]*gtsmodel.Mention, error) // PopulateMention ensures that all sub-models of a mention are populated (e.g. accounts). PopulateMention(ctx context.Context, mention *gtsmodel.Mention) error // PutMention will insert the given mention into the database. PutMention(ctx context.Context, mention *gtsmodel.Mention) error // DeleteMentionByID will delete mention with given ID from the database. DeleteMentionByID(ctx context.Context, id string) error }
Mention contains functions for getting/creating mentions in the database.
type Move ¶ added in v0.15.0
type Move interface { // GetMoveByID gets one Move with the given internal ID. GetMoveByID(ctx context.Context, id string) (*gtsmodel.Move, error) // GetMoveByURI gets one Move with the given AP URI. GetMoveByURI(ctx context.Context, uri string) (*gtsmodel.Move, error) // GetMoveByOriginTarget gets one move with the given originURI and targetURI. GetMoveByOriginTarget(ctx context.Context, originURI string, targetURI string) (*gtsmodel.Move, error) // PopulateMove parses out the origin and target URIs on the move. PopulateMove(ctx context.Context, move *gtsmodel.Move) error // GetLatestMoveSuccessInvolvingURIs gets the time of // the latest successfully-processed Move that includes // either uri1 or uri2 in target or origin positions. GetLatestMoveSuccessInvolvingURIs(ctx context.Context, uri1 string, uri2 string) (time.Time, error) // GetLatestMoveAttemptInvolvingURIs gets the time // of the latest Move attempt that includes either // uri1 or uri2 in target or origin positions. GetLatestMoveAttemptInvolvingURIs(ctx context.Context, uri1 string, uri2 string) (time.Time, error) // PutMove puts the given Move in the database. PutMove(ctx context.Context, move *gtsmodel.Move) error // UpdateMove updates the given Move by primary key. // Updates specific columns if provided, all columns if not. UpdateMove(ctx context.Context, move *gtsmodel.Move, columns ...string) error // DeleteMoveByID deletes a move with the given internal ID. DeleteMoveByID(ctx context.Context, id string) error }
type Notification ¶
type Notification interface { // GetNotifications returns a slice of notifications that pertain to the given accountID. // // Returned notifications will be ordered ID descending (ie., highest/newest to lowest/oldest). GetAccountNotifications(ctx context.Context, accountID string, maxID string, sinceID string, minID string, limit int, excludeTypes []string) ([]*gtsmodel.Notification, error) // GetNotification returns one notification according to its id. GetNotificationByID(ctx context.Context, id string) (*gtsmodel.Notification, error) // GetNotificationsByIDs returns a slice of notifications of the the provided IDs. GetNotificationsByIDs(ctx context.Context, ids []string) ([]*gtsmodel.Notification, error) // GetNotification gets one notification according to the provided parameters, if it exists. // Since not all notifications are about a status, statusID can be an empty string. GetNotification(ctx context.Context, notificationType gtsmodel.NotificationType, targetAccountID string, originAccountID string, statusID string) (*gtsmodel.Notification, error) // PopulateNotification ensures that the notification's struct fields are populated. PopulateNotification(ctx context.Context, notif *gtsmodel.Notification) error // PutNotification will insert the given notification into the database. PutNotification(ctx context.Context, notif *gtsmodel.Notification) error // DeleteNotificationByID deletes one notification according to its id, // and removes that notification from the in-memory cache. DeleteNotificationByID(ctx context.Context, id string) error // DeleteNotifications mass deletes notifications targeting targetAccountID // and/or originating from originAccountID. // // If targetAccountID is set and originAccountID isn't, all notifications // that target the given account will be deleted. // // If originAccountID is set and targetAccountID isn't, all notifications // originating from the given account will be deleted. // // If both are set, then notifications that target targetAccountID and // originate from originAccountID will be deleted. // // At least one parameter must not be an empty string. DeleteNotifications(ctx context.Context, types []string, targetAccountID string, originAccountID string) error // DeleteNotificationsForStatus deletes all notifications that relate to // the given statusID. This function is useful when a status has been deleted, // and so notifications relating to that status must also be deleted. DeleteNotificationsForStatus(ctx context.Context, statusID string) error }
Notification contains functions for creating and getting notifications.
type Poll ¶ added in v0.13.0
type Poll interface { // GetPollByID fetches the Poll with given ID from the database. GetPollByID(ctx context.Context, id string) (*gtsmodel.Poll, error) // GetOpenPolls fetches all local Polls in the database with an unset `closed_at` column. GetOpenPolls(ctx context.Context) ([]*gtsmodel.Poll, error) // PopulatePoll ensures the given Poll is fully populated with all other related database models. PopulatePoll(ctx context.Context, poll *gtsmodel.Poll) error // PutPoll puts the given Poll in the database. PutPoll(ctx context.Context, poll *gtsmodel.Poll) error // UpdatePoll updates the Poll in the database, only on selected columns if provided (else, all). UpdatePoll(ctx context.Context, poll *gtsmodel.Poll, cols ...string) error // DeletePollByID deletes the Poll with given ID from the database. DeletePollByID(ctx context.Context, id string) error // GetPollVoteByID gets the PollVote with given ID from the database. GetPollVoteByID(ctx context.Context, id string) (*gtsmodel.PollVote, error) // GetPollVotesBy fetches the PollVote in Poll with ID, by account ID, from the database. GetPollVoteBy(ctx context.Context, pollID string, accountID string) (*gtsmodel.PollVote, error) // GetPollVotes fetches all PollVotes in Poll with ID, from the database. GetPollVotes(ctx context.Context, pollID string) ([]*gtsmodel.PollVote, error) // PopulatePollVote ensures the given PollVote is fully populated with all other related database models. PopulatePollVote(ctx context.Context, votes *gtsmodel.PollVote) error // PutPollVote puts the given PollVote in the database. PutPollVote(ctx context.Context, vote *gtsmodel.PollVote) error // DeletePollVotes deletes all PollVotes in Poll with given ID from the database. DeletePollVotes(ctx context.Context, pollID string) error // DeletePollVoteBy deletes the PollVote in Poll with ID, by account ID, from the database. DeletePollVoteBy(ctx context.Context, pollID string, accountID string) error // DeletePollVotesByAccountID deletes all PollVotes in all Polls, by account ID, from the database. DeletePollVotesByAccountID(ctx context.Context, accountID string) error }
type Relationship ¶
type Relationship interface { // IsBlocked checks whether source account has a block in place against target. IsBlocked(ctx context.Context, sourceAccountID string, targetAccountID string) (bool, error) // IsEitherBlocked checks whether there is a block in place between either of account1 and account2. IsEitherBlocked(ctx context.Context, accountID1 string, accountID2 string) (bool, error) // GetBlockByID fetches block with given ID from the database. GetBlockByID(ctx context.Context, id string) (*gtsmodel.Block, error) // GetBlockByURI fetches block with given AP URI from the database. GetBlockByURI(ctx context.Context, uri string) (*gtsmodel.Block, error) // GetBlock returns the block from account1 targeting account2, if it exists, or an error if it doesn't. GetBlock(ctx context.Context, account1 string, account2 string) (*gtsmodel.Block, error) // PopulateBlock populates the struct pointers on the given block. PopulateBlock(ctx context.Context, block *gtsmodel.Block) error // PutBlock attempts to place the given account block in the database. PutBlock(ctx context.Context, block *gtsmodel.Block) error // DeleteBlockByID removes block with given ID from the database. DeleteBlockByID(ctx context.Context, id string) error // DeleteBlockByURI removes block with given AP URI from the database. DeleteBlockByURI(ctx context.Context, uri string) error // DeleteAccountBlocks will delete all database blocks to / from the given account ID. DeleteAccountBlocks(ctx context.Context, accountID string) error // GetRelationship retrieves the relationship of the targetAccount to the requestingAccount. GetRelationship(ctx context.Context, requestingAccount string, targetAccount string) (*gtsmodel.Relationship, error) // GetFollowByID fetches follow with given ID from the database. GetFollowByID(ctx context.Context, id string) (*gtsmodel.Follow, error) // GetFollowByURI fetches follow with given AP URI from the database. GetFollowByURI(ctx context.Context, uri string) (*gtsmodel.Follow, error) // GetFollow retrieves a follow if it exists between source and target accounts. GetFollow(ctx context.Context, sourceAccountID string, targetAccountID string) (*gtsmodel.Follow, error) // PopulateFollow populates the struct pointers on the given follow. PopulateFollow(ctx context.Context, follow *gtsmodel.Follow) error // GetFollowRequestByID fetches follow request with given ID from the database. GetFollowRequestByID(ctx context.Context, id string) (*gtsmodel.FollowRequest, error) // GetFollowRequestByURI fetches follow request with given AP URI from the database. GetFollowRequestByURI(ctx context.Context, uri string) (*gtsmodel.FollowRequest, error) // GetFollowRequest retrieves a follow request if it exists between source and target accounts. GetFollowRequest(ctx context.Context, sourceAccountID string, targetAccountID string) (*gtsmodel.FollowRequest, error) // PopulateFollowRequest populates the struct pointers on the given follow request. PopulateFollowRequest(ctx context.Context, follow *gtsmodel.FollowRequest) error // IsFollowing returns true if sourceAccount follows target account, or an error if something goes wrong while finding out. IsFollowing(ctx context.Context, sourceAccountID string, targetAccountID string) (bool, error) // IsMutualFollowing returns true if account1 and account2 both follow each other, or an error if something goes wrong while finding out. IsMutualFollowing(ctx context.Context, sourceAccountID string, targetAccountID string) (bool, error) // IsFollowRequested returns true if sourceAccount has requested to follow target account, or an error if something goes wrong while finding out. IsFollowRequested(ctx context.Context, sourceAccountID string, targetAccountID string) (bool, error) // PutFollow attempts to place the given account follow in the database. PutFollow(ctx context.Context, follow *gtsmodel.Follow) error // UpdateFollow updates one follow by ID. UpdateFollow(ctx context.Context, follow *gtsmodel.Follow, columns ...string) error // PutFollowRequest attempts to place the given account follow request in the database. PutFollowRequest(ctx context.Context, follow *gtsmodel.FollowRequest) error // UpdateFollowRequest updates one follow request by ID. UpdateFollowRequest(ctx context.Context, followRequest *gtsmodel.FollowRequest, columns ...string) error // DeleteFollow deletes a follow if it exists between source and target accounts. DeleteFollow(ctx context.Context, sourceAccountID string, targetAccountID string) error // DeleteFollowByID deletes a follow from the database with the given ID. DeleteFollowByID(ctx context.Context, id string) error // DeleteFollowByURI deletes a follow from the database with the given URI. DeleteFollowByURI(ctx context.Context, uri string) error // DeleteFollowRequest deletes a follow request if it exists between source and target accounts. DeleteFollowRequest(ctx context.Context, sourceAccountID string, targetAccountID string) error // DeleteFollowRequestByID deletes a follow request from the database with the given ID. DeleteFollowRequestByID(ctx context.Context, id string) error // DeleteFollowRequestByURI deletes a follow request from the database with the given URI. DeleteFollowRequestByURI(ctx context.Context, uri string) error // DeleteAccountFollows will delete all database follows to / from the given account ID. DeleteAccountFollows(ctx context.Context, accountID string) error // DeleteAccountFollowRequests will delete all database follow requests to / from the given account ID. DeleteAccountFollowRequests(ctx context.Context, accountID string) error // AcceptFollowRequest moves a follow request in the database from the follow_requests table to the follows table. // In other words, it should create the follow, and delete the existing follow request. // // It will return the newly created follow for further processing. AcceptFollowRequest(ctx context.Context, originAccountID string, targetAccountID string) (*gtsmodel.Follow, error) // RejectFollowRequest fetches a follow request from the database, and then deletes it. RejectFollowRequest(ctx context.Context, originAccountID string, targetAccountID string) error // GetAccountFollows returns a slice of follows owned by the given accountID. GetAccountFollows(ctx context.Context, accountID string, page *paging.Page) ([]*gtsmodel.Follow, error) // GetAccountFollowIDs is like GetAccountFollows, but returns just IDs. GetAccountFollowIDs(ctx context.Context, accountID string, page *paging.Page) ([]string, error) // GetAccountLocalFollows returns a slice of follows owned by the given accountID, only including follows from this instance. GetAccountLocalFollows(ctx context.Context, accountID string) ([]*gtsmodel.Follow, error) // GetAccountLocalFollowIDs is like GetAccountLocalFollows, but returns just IDs. GetAccountLocalFollowIDs(ctx context.Context, accountID string) ([]string, error) // GetAccountFollowers fetches follows that target given accountID. GetAccountFollowers(ctx context.Context, accountID string, page *paging.Page) ([]*gtsmodel.Follow, error) // GetAccountFollowerIDs is like GetAccountFollowers, but returns just IDs. GetAccountFollowerIDs(ctx context.Context, accountID string, page *paging.Page) ([]string, error) // GetAccountLocalFollowers fetches follows that target given accountID, only including follows from this instance. GetAccountLocalFollowers(ctx context.Context, accountID string) ([]*gtsmodel.Follow, error) // GetAccountLocalFollowerIDs is like GetAccountLocalFollowers, but returns just IDs. GetAccountLocalFollowerIDs(ctx context.Context, accountID string) ([]string, error) // GetAccountFollowRequests returns all follow requests targeting the given account. GetAccountFollowRequests(ctx context.Context, accountID string, page *paging.Page) ([]*gtsmodel.FollowRequest, error) // GetAccountFollowRequestIDs is like GetAccountFollowRequests, but returns just IDs. GetAccountFollowRequestIDs(ctx context.Context, accountID string, page *paging.Page) ([]string, error) // GetAccountFollowRequesting returns all follow requests originating from the given account. GetAccountFollowRequesting(ctx context.Context, accountID string, page *paging.Page) ([]*gtsmodel.FollowRequest, error) // GetAccountFollowRequestingIDs is like GetAccountFollowRequesting, but returns just IDs. GetAccountFollowRequestingIDs(ctx context.Context, accountID string, page *paging.Page) ([]string, error) // GetAccountBlocks returns all blocks originating from the given account, with given optional paging parameters. GetAccountBlocks(ctx context.Context, accountID string, paging *paging.Page) ([]*gtsmodel.Block, error) // GetAccountBlockIDs is like GetAccountBlocks, but returns just IDs. GetAccountBlockIDs(ctx context.Context, accountID string, page *paging.Page) ([]string, error) // GetNote gets a private note from a source account on a target account, if it exists. GetNote(ctx context.Context, sourceAccountID string, targetAccountID string) (*gtsmodel.AccountNote, error) // PutNote creates or updates a private note. PutNote(ctx context.Context, note *gtsmodel.AccountNote) error // PopulateNote populates the struct pointers on the given note. PopulateNote(ctx context.Context, note *gtsmodel.AccountNote) error // IsMuted checks whether source account has a mute in place against target. IsMuted(ctx context.Context, sourceAccountID string, targetAccountID string) (bool, error) // GetMuteByID fetches mute with given ID from the database. GetMuteByID(ctx context.Context, id string) (*gtsmodel.UserMute, error) // GetMute returns the mute from account1 targeting account2, if it exists, or an error if it doesn't. GetMute(ctx context.Context, account1 string, account2 string) (*gtsmodel.UserMute, error) // PutMute attempts to insert or update the given account mute in the database. PutMute(ctx context.Context, mute *gtsmodel.UserMute) error // DeleteMuteByID removes mute with given ID from the database. DeleteMuteByID(ctx context.Context, id string) error // DeleteAccountMutes will delete all database mutes to / from the given account ID. DeleteAccountMutes(ctx context.Context, accountID string) error // GetAccountMutes returns all mutes originating from the given account, with given optional paging parameters. GetAccountMutes(ctx context.Context, accountID string, paging *paging.Page) ([]*gtsmodel.UserMute, error) }
Relationship contains functions for getting or modifying the relationship between two accounts.
type Report ¶ added in v0.7.0
type Report interface { // GetReportByID gets one report by its db id GetReportByID(ctx context.Context, id string) (*gtsmodel.Report, error) // GetReports gets limit n reports using the given parameters. // Parameters that are empty / zero are ignored. GetReports(ctx context.Context, resolved *bool, accountID string, targetAccountID string, maxID string, sinceID string, minID string, limit int) ([]*gtsmodel.Report, error) // PopulateReport populates the struct pointers on the given report. PopulateReport(ctx context.Context, report *gtsmodel.Report) error // PutReport puts the given report in the database. PutReport(ctx context.Context, report *gtsmodel.Report) error // UpdateReport updates one report by its db id. // The given columns will be updated; if no columns are // provided, then all columns will be updated. // updated_at will also be updated, no need to pass this // as a specific column. UpdateReport(ctx context.Context, report *gtsmodel.Report, columns ...string) (*gtsmodel.Report, error) // DeleteReportByID deletes report with the given id. DeleteReportByID(ctx context.Context, id string) error }
Report handles getting/creation/deletion/updating of user reports/flags.
type Rule ¶ added in v0.12.0
type Rule interface { // GetRuleByID gets one rule by its db id. GetRuleByID(ctx context.Context, id string) (*gtsmodel.Rule, error) // GetRulesByIDs gets multiple rules by their db idd. GetRulesByIDs(ctx context.Context, ids []string) ([]*gtsmodel.Rule, error) // GetRules gets all active (not deleted) rules. GetActiveRules(ctx context.Context) ([]gtsmodel.Rule, error) // PutRule puts the given rule in the database. PutRule(ctx context.Context, rule *gtsmodel.Rule) error // UpdateRule updates one rule by its db id. UpdateRule(ctx context.Context, rule *gtsmodel.Rule) (*gtsmodel.Rule, error) }
Rule handles getting/creation/deletion/updating of instance rules.
type Search ¶ added in v0.10.0
type Search interface { // SearchForAccounts uses the given query text to search for accounts that accountID follows. SearchForAccounts(ctx context.Context, accountID string, query string, maxID string, minID string, limit int, following bool, offset int) ([]*gtsmodel.Account, error) // SearchForStatuses uses the given query text to search for statuses created by requestingAccountID, or in reply to requestingAccountID. // If fromAccountID is used, the results are restricted to statuses created by fromAccountID. SearchForStatuses(ctx context.Context, requestingAccountID string, query string, fromAccountID string, maxID string, minID string, limit int, offset int) ([]*gtsmodel.Status, error) // SearchForTags searches for tags that start with the given query text (case insensitive). SearchForTags(ctx context.Context, query string, maxID string, minID string, limit int, offset int) ([]*gtsmodel.Tag, error) }
type Session ¶
type Session interface {
GetSession(ctx context.Context) (*gtsmodel.RouterSession, error)
}
Session handles getting/creation of router sessions.
type Status ¶
type Status interface { // GetStatusByID fetches the status from the database with matching id column. GetStatusByID(ctx context.Context, id string) (*gtsmodel.Status, error) // GetStatusByURI fetches the status from the database with matching uri column. GetStatusByURI(ctx context.Context, uri string) (*gtsmodel.Status, error) // GetStatusByURL fetches the status from the database with matching url column. GetStatusByURL(ctx context.Context, uri string) (*gtsmodel.Status, error) // GetStatusByPollID fetches the status from the database with matching poll_id column. GetStatusByPollID(ctx context.Context, pollID string) (*gtsmodel.Status, error) // GetStatusBoost fetches the status whose boost_of_id column refers to boostOfID, authored by given account ID. GetStatusBoost(ctx context.Context, boostOfID string, byAccountID string) (*gtsmodel.Status, error) // PopulateStatus ensures that all sub-models of a status are populated (e.g. mentions, attachments, etc). PopulateStatus(ctx context.Context, status *gtsmodel.Status) error // PutStatus stores one status in the database. PutStatus(ctx context.Context, status *gtsmodel.Status) error // UpdateStatus updates one status in the database. UpdateStatus(ctx context.Context, status *gtsmodel.Status, columns ...string) error // DeleteStatusByID deletes one status from the database. DeleteStatusByID(ctx context.Context, id string) error // GetStatuses gets a slice of statuses corresponding to the given status IDs. GetStatusesByIDs(ctx context.Context, ids []string) ([]*gtsmodel.Status, error) // GetStatusesUsingEmoji fetches all status models using emoji with given ID stored in their 'emojis' column. GetStatusesUsingEmoji(ctx context.Context, emojiID string) ([]*gtsmodel.Status, error) // GetStatusReplies returns the *direct* (i.e. in_reply_to_id column) replies to this status ID, ordered DESC by ID. GetStatusReplies(ctx context.Context, statusID string) ([]*gtsmodel.Status, error) // CountStatusReplies returns the number of stored *direct* (i.e. in_reply_to_id column) replies to this status ID. CountStatusReplies(ctx context.Context, statusID string) (int, error) // GetStatusBoosts returns all statuses whose boost_of_id column refer to given status ID. GetStatusBoosts(ctx context.Context, statusID string) ([]*gtsmodel.Status, error) // CountStatusBoosts returns the number of stored boosts for status ID. CountStatusBoosts(ctx context.Context, statusID string) (int, error) // IsStatusBoostedBy checks whether the given status ID is boosted by account ID. IsStatusBoostedBy(ctx context.Context, statusID string, accountID string) (bool, error) // GetStatusParents gets the parent statuses of a given status. GetStatusParents(ctx context.Context, status *gtsmodel.Status) ([]*gtsmodel.Status, error) // GetStatusChildren gets the child statuses of a given status. GetStatusChildren(ctx context.Context, statusID string) ([]*gtsmodel.Status, error) }
Status contains functions for getting statuses, creating statuses, and checking various other fields on statuses.
type StatusBookmark ¶ added in v0.8.0
type StatusBookmark interface { // GetStatusBookmark gets one status bookmark with the given ID. GetStatusBookmarkByID(ctx context.Context, id string) (*gtsmodel.StatusBookmark, error) // GetStatusBookmark fetches a status bookmark by the given account ID on the given status ID, if it exists. GetStatusBookmark(ctx context.Context, accountID string, statusID string) (*gtsmodel.StatusBookmark, error) // IsStatusBookmarked returns whether status has been bookmarked by any account. IsStatusBookmarked(ctx context.Context, statusID string) (bool, error) // IsStatusBookmarkedBy returns whether status ID is bookmarked by the given account ID. IsStatusBookmarkedBy(ctx context.Context, accountID string, statusID string) (bool, error) // GetStatusBookmarks retrieves status bookmarks created by the given accountID, // and using the provided parameters. If limit is < 0 then no limit will be set. // // This function is primarily useful for paging through bookmarks in a sort of // timeline view. GetStatusBookmarks(ctx context.Context, accountID string, limit int, maxID string, minID string) ([]*gtsmodel.StatusBookmark, error) // PutStatusBookmark inserts the given statusBookmark into the database. PutStatusBookmark(ctx context.Context, statusBookmark *gtsmodel.StatusBookmark) error // DeleteStatusBookmark deletes one status bookmark with the given ID. DeleteStatusBookmarkByID(ctx context.Context, id string) error // DeleteStatusBookmarks mass deletes status bookmarks targeting targetAccountID // and/or originating from originAccountID and/or bookmarking statusID. // // If targetAccountID is set and originAccountID isn't, all status bookmarks // that target the given account will be deleted. // // If originAccountID is set and targetAccountID isn't, all status bookmarks // originating from the given account will be deleted. // // If both are set, then status bookmarks that target targetAccountID and // originate from originAccountID will be deleted. // // At least one parameter must not be an empty string. DeleteStatusBookmarks(ctx context.Context, targetAccountID string, originAccountID string) error // DeleteStatusBookmarksForStatus deletes all status bookmarks that target the // given status ID. This is useful when a status has been deleted, and you need // to clean up after it. DeleteStatusBookmarksForStatus(ctx context.Context, statusID string) error }
type StatusFave ¶ added in v0.8.0
type StatusFave interface { // GetStatusFaveByAccountID gets one status fave created by the given accountID, targeting the given statusID. GetStatusFave(ctx context.Context, accountID string, statusID string) (*gtsmodel.StatusFave, error) // GetStatusFave returns one status fave with the given id. GetStatusFaveByID(ctx context.Context, id string) (*gtsmodel.StatusFave, error) // GetStatusFaves returns a slice of faves/likes of the status with given ID. // This slice will be unfiltered, not taking account of blocks and whatnot, so filter it before serving it back to a user. GetStatusFaves(ctx context.Context, statusID string) ([]*gtsmodel.StatusFave, error) // PopulateStatusFave ensures that all sub-models of a fave are populated (account, status, etc). PopulateStatusFave(ctx context.Context, statusFave *gtsmodel.StatusFave) error // PutStatusFave inserts the given statusFave into the database. PutStatusFave(ctx context.Context, statusFave *gtsmodel.StatusFave) error // DeleteStatusFave deletes one status fave with the given id. DeleteStatusFaveByID(ctx context.Context, id string) error // DeleteStatusFaves mass deletes status faves targeting targetAccountID // and/or originating from originAccountID and/or faving statusID. // // If targetAccountID is set and originAccountID isn't, all status faves // that target the given account will be deleted. // // If originAccountID is set and targetAccountID isn't, all status faves // originating from the given account will be deleted. // // If both are set, then status faves that target targetAccountID and // originate from originAccountID will be deleted. // // At least one parameter must not be an empty string. DeleteStatusFaves(ctx context.Context, targetAccountID string, originAccountID string) error // DeleteStatusFavesForStatus deletes all status faves that target the given status ID. // This is useful when a status has been deleted, and you need to clean up after it. DeleteStatusFavesForStatus(ctx context.Context, statusID string) error // CountStatusFaves returns the number of status favourites registered for status with ID. CountStatusFaves(ctx context.Context, statusID string) (int, error) // IsStatusFavedBy returns whether the status with ID has been favourited by account with ID. IsStatusFavedBy(ctx context.Context, statusID string, accountID string) (bool, error) }
type Tag ¶ added in v0.11.0
type Tag interface { // GetTag gets a single tag by ID GetTag(ctx context.Context, id string) (*gtsmodel.Tag, error) // GetTagByName gets a single tag using the given name. GetTagByName(ctx context.Context, name string) (*gtsmodel.Tag, error) // PutTag inserts the given tag in the database. PutTag(ctx context.Context, tag *gtsmodel.Tag) error // GetTags gets multiple tags. GetTags(ctx context.Context, ids []string) ([]*gtsmodel.Tag, error) }
Tag contains functions for getting/creating tags in the database.
type Thread ¶ added in v0.13.0
type Thread interface { // PutThread inserts a new thread. PutThread(ctx context.Context, thread *gtsmodel.Thread) error // GetThreadMute gets a single threadMute by its ID. GetThreadMute(ctx context.Context, id string) (*gtsmodel.ThreadMute, error) // GetThreadMutedByAccount gets a threadMute targeting the // given thread, created by the given accountID, if it exists. GetThreadMutedByAccount(ctx context.Context, threadID string, accountID string) (*gtsmodel.ThreadMute, error) // IsThreadMutedByAccount returns true if threadID is muted // by given account. Empty thread ID will return false early. IsThreadMutedByAccount(ctx context.Context, threadID string, accountID string) (bool, error) // PutThreadMute inserts a new threadMute. PutThreadMute(ctx context.Context, threadMute *gtsmodel.ThreadMute) error // DeleteThreadMute deletes threadMute with the given ID. DeleteThreadMute(ctx context.Context, id string) error }
Thread contains functions for getting/creating status threads and thread mutes in the database.
type Timeline ¶
type Timeline interface { // GetHomeTimeline returns a slice of statuses from accounts that are followed by the given account id. // // Statuses should be returned in descending order of when they were created (newest first). GetHomeTimeline(ctx context.Context, accountID string, maxID string, sinceID string, minID string, limit int, local bool) ([]*gtsmodel.Status, error) // GetPublicTimeline fetches the account's PUBLIC timeline -- ie., posts and replies that are public. // It will use the given filters and try to return as many statuses as possible up to the limit. // // Statuses should be returned in descending order of when they were created (newest first). GetPublicTimeline(ctx context.Context, maxID string, sinceID string, minID string, limit int, local bool) ([]*gtsmodel.Status, error) // GetFavedTimeline fetches the account's FAVED timeline -- ie., posts and replies that the requesting account has faved. // It will use the given filters and try to return as many statuses as possible up to the limit. // // Note that unlike the other GetTimeline functions, the returned statuses will be arranged by their FAVE id, not the STATUS id. // In other words, they'll be returned in descending order of when they were faved by the requesting user, not when they were created. // // Also note the extra return values, which correspond to the nextMaxID and prevMinID for building Link headers. GetFavedTimeline(ctx context.Context, accountID string, maxID string, minID string, limit int) ([]*gtsmodel.Status, string, string, error) // GetListTimeline returns a slice of statuses from followed accounts collected within the list with the given listID. // Statuses should be returned in descending order of when they were created (newest first). GetListTimeline(ctx context.Context, listID string, maxID string, sinceID string, minID string, limit int) ([]*gtsmodel.Status, error) // GetTagTimeline returns a slice of public-visibility statuses that use the given tagID. // Statuses should be returned in descending order of when they were created (newest first). GetTagTimeline(ctx context.Context, tagID string, maxID string, sinceID string, minID string, limit int) ([]*gtsmodel.Status, error) }
Timeline contains functionality for retrieving home/public/faved etc timelines for an account.
type Tombstone ¶ added in v0.6.0
type Tombstone interface { // GetTombstoneByURI attempts to fetch a tombstone by the given URI. GetTombstoneByURI(ctx context.Context, uri string) (*gtsmodel.Tombstone, error) // TombstoneExistsWithURI returns true if a tombstone with the given URI exists. TombstoneExistsWithURI(ctx context.Context, uri string) (bool, error) // PutTombstone creates a new tombstone in the database. PutTombstone(ctx context.Context, tombstone *gtsmodel.Tombstone) error // DeleteTombstone deletes a tombstone with the given ID. DeleteTombstone(ctx context.Context, id string) error }
Tombstone contains functionality for storing + retrieving tombstones for remote AP Activities + Objects.
type User ¶ added in v0.6.0
type User interface { // GetAllUsers returns all local user accounts, or an error if something goes wrong. GetAllUsers(ctx context.Context) ([]*gtsmodel.User, error) // GetUserByID returns one user with the given ID, or an error if something goes wrong. GetUserByID(ctx context.Context, id string) (*gtsmodel.User, error) // GetUserByAccountID returns one user by its account ID, or an error if something goes wrong. GetUserByAccountID(ctx context.Context, accountID string) (*gtsmodel.User, error) // GetUserByID returns one user with the given email address, or an error if something goes wrong. GetUserByEmailAddress(ctx context.Context, emailAddress string) (*gtsmodel.User, error) // GetUserByExternalID returns one user with the given external id, or an error if something goes wrong. GetUserByExternalID(ctx context.Context, id string) (*gtsmodel.User, error) // GetUserByConfirmationToken returns one user by its confirmation token, or an error if something goes wrong. GetUserByConfirmationToken(ctx context.Context, confirmationToken string) (*gtsmodel.User, error) // PopulateUser populates the struct pointers on the given user. PopulateUser(ctx context.Context, user *gtsmodel.User) error // PutUser will attempt to place user in the database PutUser(ctx context.Context, user *gtsmodel.User) error // UpdateUser updates one user by its primary key, updating either only the specified columns, or all of them. UpdateUser(ctx context.Context, user *gtsmodel.User, columns ...string) error // DeleteUserByID deletes one user by its ID. DeleteUserByID(ctx context.Context, userID string) error // PutDeniedUser inserts the given deniedUser into the db. PutDeniedUser(ctx context.Context, deniedUser *gtsmodel.DeniedUser) error // GetDeniedUserByID returns one denied user with the given ID. GetDeniedUserByID(ctx context.Context, id string) (*gtsmodel.DeniedUser, error) }
User contains functions related to user getting/setting/creation.
type Where ¶
type Where struct { // The table to search on. Key string // The value to match. Value interface{} // If set, reverse the where. // `WHERE k = v` becomes `WHERE k != v`. // `WHERE k IS NULL` becomes `WHERE k IS NOT NULL` Not bool }
Where allows the caller of the DB to specify Where parameters.
Source Files ¶
- account.go
- admin.go
- application.go
- basic.go
- db.go
- domain.go
- emoji.go
- error.go
- filter.go
- headerfilter.go
- instance.go
- list.go
- marker.go
- media.go
- mention.go
- move.go
- notification.go
- params.go
- poll.go
- relationship.go
- report.go
- rule.go
- search.go
- session.go
- status.go
- statusbookmark.go
- statusfave.go
- tag.go
- thread.go
- timeline.go
- tombstone.go
- user.go
- util.go
Directories ¶
Path | Synopsis |
---|---|
migrations/20211113114307_init
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database.
|
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database. |
migrations/20220214175650_media_cleanup
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database.
|
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database. |
migrations/20220315160814_admin_account_actions
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database.
|
Package gtsmodel contains types used *internally* by GoToSocial and added/removed/selected from the database. |