2021-03-02 17:26:30 +00:00
|
|
|
/*
|
|
|
|
GoToSocial
|
|
|
|
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
2021-03-02 21:52:31 +00:00
|
|
|
"context"
|
2021-04-01 18:46:45 +00:00
|
|
|
"net"
|
2021-03-02 17:26:30 +00:00
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
2021-03-02 17:26:30 +00:00
|
|
|
)
|
|
|
|
|
2021-05-15 09:58:11 +00:00
|
|
|
const (
|
|
|
|
// DBTypePostgres represents an underlying POSTGRES database type.
|
|
|
|
DBTypePostgres string = "POSTGRES"
|
|
|
|
)
|
2021-03-02 17:26:30 +00:00
|
|
|
|
2021-03-22 21:26:54 +00:00
|
|
|
// DB provides methods for interacting with an underlying database or other storage mechanism (for now, just postgres).
|
2021-04-01 18:46:45 +00:00
|
|
|
// Note that in all of the functions below, the passed interface should be a pointer or a slice, which will then be populated
|
|
|
|
// by whatever is returned from the database.
|
2021-03-04 13:38:18 +00:00
|
|
|
type DB interface {
|
2021-04-01 18:46:45 +00:00
|
|
|
/*
|
|
|
|
BASIC DB FUNCTIONALITY
|
|
|
|
*/
|
|
|
|
|
|
|
|
// CreateTable creates a table for the given interface.
|
|
|
|
// For implementations that don't use tables, this can just return nil.
|
2021-03-22 21:26:54 +00:00
|
|
|
CreateTable(i interface{}) error
|
2021-03-05 17:31:12 +00:00
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// DropTable drops the table for the given interface.
|
|
|
|
// For implementations that don't use tables, this can just return nil.
|
2021-03-22 21:26:54 +00:00
|
|
|
DropTable(i interface{}) error
|
2021-03-05 17:31:12 +00:00
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// Stop 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.
|
2021-03-22 21:26:54 +00:00
|
|
|
Stop(ctx context.Context) error
|
2021-03-05 17:31:12 +00:00
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// IsHealthy should return nil if the database connection is healthy, or an error if not.
|
2021-03-22 21:26:54 +00:00
|
|
|
IsHealthy(ctx context.Context) error
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// 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
|
2021-03-22 21:26:54 +00:00
|
|
|
GetByID(id string, i interface{}) error
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// 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
|
2021-05-21 13:48:26 +00:00
|
|
|
GetWhere(where []Where, i interface{}) error
|
2021-03-22 21:26:54 +00:00
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// 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
|
2021-03-22 21:26:54 +00:00
|
|
|
GetAll(i interface{}) error
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// 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.
|
2021-03-22 21:26:54 +00:00
|
|
|
Put(i interface{}) error
|
|
|
|
|
2021-04-19 17:42:19 +00:00
|
|
|
// Upsert stores or updates i based on the given conflict column, as in https://www.postgresqltutorial.com/postgresql-upsert/
|
|
|
|
// 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.
|
|
|
|
Upsert(i interface{}, conflictColumn string) error
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// UpdateByID updates i with id id.
|
|
|
|
// The given interface i will be set to the result of the query, whatever it is. Use a pointer or a slice.
|
2021-03-22 21:26:54 +00:00
|
|
|
UpdateByID(id string, i interface{}) error
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// UpdateOneByID updates interface i with database the given database id. It will update one field of key key and value value.
|
|
|
|
UpdateOneByID(id string, key string, value interface{}, i interface{}) error
|
|
|
|
|
2021-07-06 11:29:11 +00:00
|
|
|
// UpdateWhere updates column key of interface i with the given value, where the given parameters apply.
|
|
|
|
UpdateWhere(where []Where, key string, value interface{}, i interface{}) error
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// DeleteByID removes i with id id.
|
|
|
|
// If i didn't exist anyway, then no error should be returned.
|
2021-03-22 21:26:54 +00:00
|
|
|
DeleteByID(id string, i interface{}) error
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// DeleteWhere deletes i where key = value
|
|
|
|
// If i didn't exist anyway, then no error should be returned.
|
2021-05-21 13:48:26 +00:00
|
|
|
DeleteWhere(where []Where, i interface{}) error
|
2021-04-01 18:46:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
HANDY SHORTCUTS
|
|
|
|
*/
|
|
|
|
|
2021-05-15 09:58:11 +00:00
|
|
|
// 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.
|
2021-05-21 13:48:26 +00:00
|
|
|
//
|
|
|
|
// It will return the newly created follow for further processing.
|
|
|
|
AcceptFollowRequest(originAccountID string, targetAccountID string) (*gtsmodel.Follow, error)
|
2021-05-15 09:58:11 +00:00
|
|
|
|
2021-04-19 17:42:19 +00:00
|
|
|
// 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() error
|
|
|
|
|
2021-05-09 12:06:06 +00:00
|
|
|
// 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() error
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// GetAccountByUserID is a shortcut for the common action of fetching an account corresponding to a user ID.
|
|
|
|
// The given account pointer will be set to the result of the query, whatever it is.
|
|
|
|
// In case of no entries, a 'no entries' error will be returned
|
2021-04-19 17:42:19 +00:00
|
|
|
GetAccountByUserID(userID string, account *gtsmodel.Account) error
|
2021-04-01 18:46:45 +00:00
|
|
|
|
2021-05-08 12:25:55 +00:00
|
|
|
// GetLocalAccountByUsername is a shortcut for the common action of fetching an account ON THIS INSTANCE
|
|
|
|
// according to its username, which should be unique.
|
|
|
|
// The given account pointer will be set to the result of the query, whatever it is.
|
|
|
|
// In case of no entries, a 'no entries' error will be returned
|
|
|
|
GetLocalAccountByUsername(username string, account *gtsmodel.Account) error
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// GetFollowRequestsForAccountID is a shortcut for the common action of fetching a list of follow requests targeting the given account ID.
|
|
|
|
// The given slice 'followRequests' will be set to the result of the query, whatever it is.
|
|
|
|
// In case of no entries, a 'no entries' error will be returned
|
2021-04-19 17:42:19 +00:00
|
|
|
GetFollowRequestsForAccountID(accountID string, followRequests *[]gtsmodel.FollowRequest) error
|
2021-04-01 18:46:45 +00:00
|
|
|
|
|
|
|
// GetFollowingByAccountID is a shortcut for the common action of fetching a list of accounts that accountID is following.
|
|
|
|
// The given slice 'following' will be set to the result of the query, whatever it is.
|
|
|
|
// In case of no entries, a 'no entries' error will be returned
|
2021-04-19 17:42:19 +00:00
|
|
|
GetFollowingByAccountID(accountID string, following *[]gtsmodel.Follow) error
|
2021-04-01 18:46:45 +00:00
|
|
|
|
|
|
|
// GetFollowersByAccountID is a shortcut for the common action of fetching a list of accounts that accountID is followed by.
|
|
|
|
// The given slice 'followers' will be set to the result of the query, whatever it is.
|
|
|
|
// In case of no entries, a 'no entries' error will be returned
|
2021-06-13 16:42:28 +00:00
|
|
|
//
|
|
|
|
// If localOnly is set to true, then only followers from *this instance* will be returned.
|
|
|
|
GetFollowersByAccountID(accountID string, followers *[]gtsmodel.Follow, localOnly bool) error
|
2021-04-01 18:46:45 +00:00
|
|
|
|
2021-05-15 09:58:11 +00:00
|
|
|
// GetFavesByAccountID is a shortcut for the common action of fetching a list of faves made by the given accountID.
|
|
|
|
// The given slice 'faves' will be set to the result of the query, whatever it is.
|
|
|
|
// In case of no entries, a 'no entries' error will be returned
|
|
|
|
GetFavesByAccountID(accountID string, faves *[]gtsmodel.StatusFave) error
|
|
|
|
|
2021-05-17 17:06:58 +00:00
|
|
|
// CountStatusesByAccountID is a shortcut for the common action of counting statuses produced by accountID.
|
|
|
|
CountStatusesByAccountID(accountID string) (int, error)
|
2021-04-01 18:46:45 +00:00
|
|
|
|
2021-07-05 11:23:03 +00:00
|
|
|
// GetStatusesForAccount is a shortcut for getting the most recent statuses. accountID is optional, if not provided
|
2021-04-01 18:46:45 +00:00
|
|
|
// 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 case of no entries, a 'no entries' error will be returned
|
2021-07-05 11:23:03 +00:00
|
|
|
GetStatusesForAccount(accountID string, limit int, excludeReplies bool, maxID string, pinnedOnly bool, mediaOnly bool) ([]*gtsmodel.Status, error)
|
2021-04-01 18:46:45 +00:00
|
|
|
|
2021-07-11 14:22:21 +00:00
|
|
|
GetBlocksForAccount(accountID string, maxID string, sinceID string, limit int) ([]*gtsmodel.Account, string, string, error)
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
// GetLastStatusForAccountID simply gets the most recent status by the given account.
|
|
|
|
// The given slice 'status' pointer will be set to the result of the query, whatever it is.
|
|
|
|
// In case of no entries, a 'no entries' error will be returned
|
2021-04-19 17:42:19 +00:00
|
|
|
GetLastStatusForAccountID(accountID string, status *gtsmodel.Status) error
|
2021-04-01 18:46:45 +00:00
|
|
|
|
|
|
|
// 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(username string) 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(email string) error
|
|
|
|
|
2021-07-23 08:36:28 +00:00
|
|
|
// NewSignup creates a new user in the database with the given parameters.
|
2021-04-01 18:46:45 +00:00
|
|
|
// By the time this function is called, it should be assumed that all the parameters have passed validation!
|
2021-07-23 08:36:28 +00:00
|
|
|
NewSignup(username string, reason string, requireApproval bool, email string, password string, signUpIP net.IP, locale string, appID string, emailVerified bool, admin bool) (*gtsmodel.User, error)
|
2021-04-01 18:46:45 +00:00
|
|
|
|
|
|
|
// SetHeaderOrAvatarForAccountID sets the header or avatar for the given accountID to the given media attachment.
|
2021-04-19 17:42:19 +00:00
|
|
|
SetHeaderOrAvatarForAccountID(mediaAttachment *gtsmodel.MediaAttachment, accountID string) error
|
2021-04-01 18:46:45 +00:00
|
|
|
|
|
|
|
// GetHeaderAvatarForAccountID gets the current avatar for the given account ID.
|
|
|
|
// The passed mediaAttachment pointer will be populated with the value of the avatar, if it exists.
|
2021-04-19 17:42:19 +00:00
|
|
|
GetAvatarForAccountID(avatar *gtsmodel.MediaAttachment, accountID string) error
|
2021-04-01 18:46:45 +00:00
|
|
|
|
|
|
|
// GetHeaderForAccountID gets the current header for the given account ID.
|
|
|
|
// The passed mediaAttachment pointer will be populated with the value of the header, if it exists.
|
2021-04-19 17:42:19 +00:00
|
|
|
GetHeaderForAccountID(header *gtsmodel.MediaAttachment, accountID string) error
|
|
|
|
|
|
|
|
// Blocked checks whether a block exists in eiher direction between two accounts.
|
|
|
|
// That is, it returns true if account1 blocks account2, OR if account2 blocks account1.
|
|
|
|
Blocked(account1 string, account2 string) (bool, error)
|
|
|
|
|
2021-05-21 13:48:26 +00:00
|
|
|
// GetRelationship retrieves the relationship of the targetAccount to the requestingAccount.
|
|
|
|
GetRelationship(requestingAccount string, targetAccount string) (*gtsmodel.Relationship, error)
|
|
|
|
|
2021-04-19 17:42:19 +00:00
|
|
|
// Follows returns true if sourceAccount follows target account, or an error if something goes wrong while finding out.
|
|
|
|
Follows(sourceAccount *gtsmodel.Account, targetAccount *gtsmodel.Account) (bool, error)
|
|
|
|
|
2021-05-21 13:48:26 +00:00
|
|
|
// FollowRequested returns true if sourceAccount has requested to follow target account, or an error if something goes wrong while finding out.
|
|
|
|
FollowRequested(sourceAccount *gtsmodel.Account, targetAccount *gtsmodel.Account) (bool, error)
|
|
|
|
|
2021-04-19 17:42:19 +00:00
|
|
|
// Mutuals returns true if account1 and account2 both follow each other, or an error if something goes wrong while finding out.
|
|
|
|
Mutuals(account1 *gtsmodel.Account, account2 *gtsmodel.Account) (bool, error)
|
|
|
|
|
|
|
|
// GetReplyCountForStatus returns the amount of replies recorded for a status, or an error if something goes wrong
|
|
|
|
GetReplyCountForStatus(status *gtsmodel.Status) (int, error)
|
|
|
|
|
|
|
|
// GetReblogCountForStatus returns the amount of reblogs/boosts recorded for a status, or an error if something goes wrong
|
|
|
|
GetReblogCountForStatus(status *gtsmodel.Status) (int, error)
|
|
|
|
|
|
|
|
// GetFaveCountForStatus returns the amount of faves/likes recorded for a status, or an error if something goes wrong
|
|
|
|
GetFaveCountForStatus(status *gtsmodel.Status) (int, error)
|
|
|
|
|
2021-06-17 16:02:33 +00:00
|
|
|
// StatusParents get the parent statuses of a given status.
|
2021-08-10 11:32:39 +00:00
|
|
|
//
|
|
|
|
// If onlyDirect is true, only the immediate parent will be returned.
|
|
|
|
StatusParents(status *gtsmodel.Status, onlyDirect bool) ([]*gtsmodel.Status, error)
|
2021-06-17 16:02:33 +00:00
|
|
|
|
|
|
|
// StatusChildren gets the child statuses of a given status.
|
2021-08-10 11:32:39 +00:00
|
|
|
//
|
|
|
|
// If onlyDirect is true, only the immediate children will be returned.
|
|
|
|
StatusChildren(status *gtsmodel.Status, onlyDirect bool, minID string) ([]*gtsmodel.Status, error)
|
2021-06-17 16:02:33 +00:00
|
|
|
|
2021-04-19 17:42:19 +00:00
|
|
|
// StatusFavedBy checks if a given status has been faved by a given account ID
|
|
|
|
StatusFavedBy(status *gtsmodel.Status, accountID string) (bool, error)
|
|
|
|
|
|
|
|
// StatusRebloggedBy checks if a given status has been reblogged/boosted by a given account ID
|
|
|
|
StatusRebloggedBy(status *gtsmodel.Status, accountID string) (bool, error)
|
|
|
|
|
|
|
|
// StatusMutedBy checks if a given status has been muted by a given account ID
|
|
|
|
StatusMutedBy(status *gtsmodel.Status, accountID string) (bool, error)
|
|
|
|
|
|
|
|
// StatusBookmarkedBy checks if a given status has been bookmarked by a given account ID
|
|
|
|
StatusBookmarkedBy(status *gtsmodel.Status, accountID string) (bool, error)
|
|
|
|
|
|
|
|
// WhoFavedStatus returns a slice of accounts who faved the given status.
|
|
|
|
// This slice will be unfiltered, not taking account of blocks and whatnot, so filter it before serving it back to a user.
|
|
|
|
WhoFavedStatus(status *gtsmodel.Status) ([]*gtsmodel.Account, error)
|
2021-04-01 18:46:45 +00:00
|
|
|
|
2021-05-31 15:36:35 +00:00
|
|
|
// WhoBoostedStatus returns a slice of accounts who boosted the given status.
|
|
|
|
// This slice will be unfiltered, not taking account of blocks and whatnot, so filter it before serving it back to a user.
|
|
|
|
WhoBoostedStatus(status *gtsmodel.Status) ([]*gtsmodel.Account, error)
|
|
|
|
|
2021-07-09 16:32:48 +00:00
|
|
|
// GetHomeTimelineForAccount 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).
|
|
|
|
GetHomeTimelineForAccount(accountID string, maxID string, sinceID string, minID string, limit int, local bool) ([]*gtsmodel.Status, error)
|
2021-05-21 21:04:59 +00:00
|
|
|
|
2021-07-09 16:32:48 +00:00
|
|
|
// GetPublicTimelineForAccount fetches the account's PUBLIC timeline -- ie., posts and replies that are public.
|
2021-05-31 15:36:35 +00:00
|
|
|
// It will use the given filters and try to return as many statuses as possible up to the limit.
|
2021-07-09 16:32:48 +00:00
|
|
|
//
|
|
|
|
// Statuses should be returned in descending order of when they were created (newest first).
|
2021-05-31 15:36:35 +00:00
|
|
|
GetPublicTimelineForAccount(accountID string, maxID string, sinceID string, minID string, limit int, local bool) ([]*gtsmodel.Status, error)
|
|
|
|
|
2021-07-09 16:32:48 +00:00
|
|
|
// GetFavedTimelineForAccount 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.
|
|
|
|
GetFavedTimelineForAccount(accountID string, maxID string, minID string, limit int) ([]*gtsmodel.Status, string, string, error)
|
|
|
|
|
2021-05-30 11:12:00 +00:00
|
|
|
// GetNotificationsForAccount returns a list of notifications that pertain to the given accountID.
|
2021-05-31 15:36:35 +00:00
|
|
|
GetNotificationsForAccount(accountID string, limit int, maxID string, sinceID string) ([]*gtsmodel.Notification, error)
|
2021-05-27 14:06:24 +00:00
|
|
|
|
2021-06-23 14:35:57 +00:00
|
|
|
// GetUserCountForInstance returns the number of known accounts registered with the given domain.
|
|
|
|
GetUserCountForInstance(domain string) (int, error)
|
|
|
|
|
|
|
|
// GetStatusCountForInstance returns the number of known statuses posted from the given domain.
|
|
|
|
GetStatusCountForInstance(domain string) (int, error)
|
|
|
|
|
|
|
|
// GetDomainCountForInstance returns the number of known instances known that the given domain federates with.
|
|
|
|
GetDomainCountForInstance(domain string) (int, error)
|
2021-07-05 11:23:03 +00:00
|
|
|
|
|
|
|
// GetAccountsForInstance returns a slice of accounts from the given instance, arranged by ID.
|
|
|
|
GetAccountsForInstance(domain string, maxID string, limit int) ([]*gtsmodel.Account, error)
|
|
|
|
|
2021-04-01 18:46:45 +00:00
|
|
|
/*
|
|
|
|
USEFUL CONVERSION FUNCTIONS
|
|
|
|
*/
|
|
|
|
|
2021-04-19 17:42:19 +00:00
|
|
|
// MentionStringsToMentions takes a slice of deduplicated, lowercase account names in the form "@test@whatever.example.org" for a remote account,
|
|
|
|
// or @test for a local account, which have been mentioned in a status.
|
|
|
|
// It takes the id of the account that wrote the status, and the id of the status itself, and then
|
|
|
|
// checks in the database for the mentioned accounts, and returns a slice of mentions generated based on the given parameters.
|
|
|
|
//
|
|
|
|
// Note: this func doesn't/shouldn't do any manipulation of the accounts in the DB, it's just for checking
|
|
|
|
// if they exist in the db and conveniently returning them if they do.
|
|
|
|
MentionStringsToMentions(targetAccounts []string, originAccountID string, statusID string) ([]*gtsmodel.Mention, error)
|
|
|
|
|
|
|
|
// TagStringsToTags takes a slice of deduplicated, lowercase tags in the form "somehashtag", which have been
|
|
|
|
// used in a status. It takes the id of the account that wrote the status, and the id of the status itself, and then
|
|
|
|
// returns a slice of *model.Tag corresponding to the given tags. If the tag already exists in database, that tag
|
|
|
|
// will be returned. Otherwise a pointer to a new tag struct will be created and returned.
|
|
|
|
//
|
|
|
|
// Note: this func doesn't/shouldn't do any manipulation of the tags in the DB, it's just for checking
|
|
|
|
// if they exist in the db already, and conveniently returning them, or creating new tag structs.
|
|
|
|
TagStringsToTags(tags []string, originAccountID string, statusID string) ([]*gtsmodel.Tag, error)
|
|
|
|
|
|
|
|
// EmojiStringsToEmojis takes a slice of deduplicated, lowercase emojis in the form ":emojiname:", which have been
|
|
|
|
// used in a status. It takes the id of the account that wrote the status, and the id of the status itself, and then
|
|
|
|
// returns a slice of *model.Emoji corresponding to the given emojis.
|
|
|
|
//
|
|
|
|
// Note: this func doesn't/shouldn't do any manipulation of the emoji in the DB, it's just for checking
|
|
|
|
// if they exist in the db and conveniently returning them if they do.
|
|
|
|
EmojiStringsToEmojis(emojis []string, originAccountID string, statusID string) ([]*gtsmodel.Emoji, error)
|
2021-03-02 17:26:30 +00:00
|
|
|
}
|