2021-08-20 10:26:56 +00:00
|
|
|
/*
|
|
|
|
GoToSocial
|
2023-01-05 11:43:00 +00:00
|
|
|
Copyright (C) 2021-2023 GoToSocial Authors admin@gotosocial.org
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
|
|
|
)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// Status contains functions for getting statuses, creating statuses, and checking various other fields on statuses.
|
|
|
|
type Status interface {
|
2021-09-01 09:08:21 +00:00
|
|
|
// GetStatusByID returns one status from the database, with no rel fields populated, only their linking ID / URIs
|
2021-08-25 13:34:33 +00:00
|
|
|
GetStatusByID(ctx context.Context, id string) (*gtsmodel.Status, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
2023-01-10 14:19:05 +00:00
|
|
|
// GetStatuses gets a slice of statuses corresponding to the given status IDs.
|
|
|
|
GetStatuses(ctx context.Context, ids []string) ([]*gtsmodel.Status, Error)
|
|
|
|
|
2021-09-01 09:08:21 +00:00
|
|
|
// GetStatusByURI returns one status from the database, with no rel fields populated, only their linking ID / URIs
|
2021-08-25 13:34:33 +00:00
|
|
|
GetStatusByURI(ctx context.Context, uri string) (*gtsmodel.Status, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
2021-09-01 09:08:21 +00:00
|
|
|
// GetStatusByURL returns one status from the database, with no rel fields populated, only their linking ID / URIs
|
2021-08-25 13:34:33 +00:00
|
|
|
GetStatusByURL(ctx context.Context, uri string) (*gtsmodel.Status, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// PutStatus stores one status in the database.
|
2021-08-25 13:34:33 +00:00
|
|
|
PutStatus(ctx context.Context, status *gtsmodel.Status) Error
|
2021-08-20 10:26:56 +00:00
|
|
|
|
2023-03-01 17:52:44 +00:00
|
|
|
// UpdateStatus updates one status in the database.
|
|
|
|
UpdateStatus(ctx context.Context, status *gtsmodel.Status, columns ...string) Error
|
2022-09-12 11:03:23 +00:00
|
|
|
|
2022-09-21 17:55:52 +00:00
|
|
|
// DeleteStatusByID deletes one status from the database.
|
|
|
|
DeleteStatusByID(ctx context.Context, id string) Error
|
|
|
|
|
2021-08-20 10:26:56 +00:00
|
|
|
// CountStatusReplies returns the amount of replies recorded for a status, or an error if something goes wrong
|
2021-08-25 13:34:33 +00:00
|
|
|
CountStatusReplies(ctx context.Context, status *gtsmodel.Status) (int, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// CountStatusReblogs returns the amount of reblogs/boosts recorded for a status, or an error if something goes wrong
|
2021-08-25 13:34:33 +00:00
|
|
|
CountStatusReblogs(ctx context.Context, status *gtsmodel.Status) (int, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// CountStatusFaves returns the amount of faves/likes recorded for a status, or an error if something goes wrong
|
2021-08-25 13:34:33 +00:00
|
|
|
CountStatusFaves(ctx context.Context, status *gtsmodel.Status) (int, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// GetStatusParents gets the parent statuses of a given status.
|
|
|
|
//
|
|
|
|
// If onlyDirect is true, only the immediate parent will be returned.
|
2021-08-25 13:34:33 +00:00
|
|
|
GetStatusParents(ctx context.Context, status *gtsmodel.Status, onlyDirect bool) ([]*gtsmodel.Status, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// GetStatusChildren gets the child statuses of a given status.
|
|
|
|
//
|
|
|
|
// If onlyDirect is true, only the immediate children will be returned.
|
2021-08-25 13:34:33 +00:00
|
|
|
GetStatusChildren(ctx context.Context, status *gtsmodel.Status, onlyDirect bool, minID string) ([]*gtsmodel.Status, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// IsStatusFavedBy checks if a given status has been faved by a given account ID
|
2021-08-25 13:34:33 +00:00
|
|
|
IsStatusFavedBy(ctx context.Context, status *gtsmodel.Status, accountID string) (bool, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// IsStatusRebloggedBy checks if a given status has been reblogged/boosted by a given account ID
|
2021-08-25 13:34:33 +00:00
|
|
|
IsStatusRebloggedBy(ctx context.Context, status *gtsmodel.Status, accountID string) (bool, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// IsStatusMutedBy checks if a given status has been muted by a given account ID
|
2021-08-25 13:34:33 +00:00
|
|
|
IsStatusMutedBy(ctx context.Context, status *gtsmodel.Status, accountID string) (bool, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// IsStatusBookmarkedBy checks if a given status has been bookmarked by a given account ID
|
2021-08-25 13:34:33 +00:00
|
|
|
IsStatusBookmarkedBy(ctx context.Context, status *gtsmodel.Status, accountID string) (bool, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// GetStatusFaves returns a slice of faves/likes of 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.
|
2021-08-25 13:34:33 +00:00
|
|
|
GetStatusFaves(ctx context.Context, status *gtsmodel.Status) ([]*gtsmodel.StatusFave, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
|
|
|
|
// GetStatusReblogs returns a slice of statuses that are a boost/reblog of 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.
|
2021-08-25 13:34:33 +00:00
|
|
|
GetStatusReblogs(ctx context.Context, status *gtsmodel.Status) ([]*gtsmodel.Status, Error)
|
2021-08-20 10:26:56 +00:00
|
|
|
}
|