gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

status.go (4463B)


      1 // GoToSocial
      2 // Copyright (C) GoToSocial Authors admin@gotosocial.org
      3 // SPDX-License-Identifier: AGPL-3.0-or-later
      4 //
      5 // This program is free software: you can redistribute it and/or modify
      6 // it under the terms of the GNU Affero General Public License as published by
      7 // the Free Software Foundation, either version 3 of the License, or
      8 // (at your option) any later version.
      9 //
     10 // This program is distributed in the hope that it will be useful,
     11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 // GNU Affero General Public License for more details.
     14 //
     15 // You should have received a copy of the GNU Affero General Public License
     16 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18 package db
     19 
     20 import (
     21 	"context"
     22 
     23 	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
     24 )
     25 
     26 // Status contains functions for getting statuses, creating statuses, and checking various other fields on statuses.
     27 type Status interface {
     28 	// GetStatusByID returns one status from the database, with no rel fields populated, only their linking ID / URIs
     29 	GetStatusByID(ctx context.Context, id string) (*gtsmodel.Status, Error)
     30 
     31 	// GetStatuses gets a slice of statuses corresponding to the given status IDs.
     32 	GetStatuses(ctx context.Context, ids []string) ([]*gtsmodel.Status, Error)
     33 
     34 	// GetStatusByURI returns one status from the database, with no rel fields populated, only their linking ID / URIs
     35 	GetStatusByURI(ctx context.Context, uri string) (*gtsmodel.Status, Error)
     36 
     37 	// GetStatusByURL returns one status from the database, with no rel fields populated, only their linking ID / URIs
     38 	GetStatusByURL(ctx context.Context, uri string) (*gtsmodel.Status, Error)
     39 
     40 	// PopulateStatus ensures that all sub-models of a status are populated (e.g. mentions, attachments, etc).
     41 	PopulateStatus(ctx context.Context, status *gtsmodel.Status) error
     42 
     43 	// PutStatus stores one status in the database.
     44 	PutStatus(ctx context.Context, status *gtsmodel.Status) Error
     45 
     46 	// UpdateStatus updates one status in the database.
     47 	UpdateStatus(ctx context.Context, status *gtsmodel.Status, columns ...string) Error
     48 
     49 	// DeleteStatusByID deletes one status from the database.
     50 	DeleteStatusByID(ctx context.Context, id string) Error
     51 
     52 	// CountStatusReplies returns the amount of replies recorded for a status, or an error if something goes wrong
     53 	CountStatusReplies(ctx context.Context, status *gtsmodel.Status) (int, Error)
     54 
     55 	// CountStatusReblogs returns the amount of reblogs/boosts recorded for a status, or an error if something goes wrong
     56 	CountStatusReblogs(ctx context.Context, status *gtsmodel.Status) (int, Error)
     57 
     58 	// CountStatusFaves returns the amount of faves/likes recorded for a status, or an error if something goes wrong
     59 	CountStatusFaves(ctx context.Context, status *gtsmodel.Status) (int, Error)
     60 
     61 	// GetStatusParents gets the parent statuses of a given status.
     62 	//
     63 	// If onlyDirect is true, only the immediate parent will be returned.
     64 	GetStatusParents(ctx context.Context, status *gtsmodel.Status, onlyDirect bool) ([]*gtsmodel.Status, Error)
     65 
     66 	// GetStatusChildren gets the child statuses of a given status.
     67 	//
     68 	// If onlyDirect is true, only the immediate children will be returned.
     69 	GetStatusChildren(ctx context.Context, status *gtsmodel.Status, onlyDirect bool, minID string) ([]*gtsmodel.Status, Error)
     70 
     71 	// IsStatusFavedBy checks if a given status has been faved by a given account ID
     72 	IsStatusFavedBy(ctx context.Context, status *gtsmodel.Status, accountID string) (bool, Error)
     73 
     74 	// IsStatusRebloggedBy checks if a given status has been reblogged/boosted by a given account ID
     75 	IsStatusRebloggedBy(ctx context.Context, status *gtsmodel.Status, accountID string) (bool, Error)
     76 
     77 	// IsStatusMutedBy checks if a given status has been muted by a given account ID
     78 	IsStatusMutedBy(ctx context.Context, status *gtsmodel.Status, accountID string) (bool, Error)
     79 
     80 	// IsStatusBookmarkedBy checks if a given status has been bookmarked by a given account ID
     81 	IsStatusBookmarkedBy(ctx context.Context, status *gtsmodel.Status, accountID string) (bool, Error)
     82 
     83 	// GetStatusReblogs returns a slice of statuses that are a boost/reblog of the given status.
     84 	// This slice will be unfiltered, not taking account of blocks and whatnot, so filter it before serving it back to a user.
     85 	GetStatusReblogs(ctx context.Context, status *gtsmodel.Status) ([]*gtsmodel.Status, Error)
     86 }