gtsocial-umbx

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

relationship.go (8860B)


      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 // Relationship contains functions for getting or modifying the relationship between two accounts.
     27 type Relationship interface {
     28 	// IsBlocked checks whether source account has a block in place against target.
     29 	IsBlocked(ctx context.Context, sourceAccountID string, targetAccountID string) (bool, Error)
     30 
     31 	// IsEitherBlocked checks whether there is a block in place between either of account1 and account2.
     32 	IsEitherBlocked(ctx context.Context, accountID1 string, accountID2 string) (bool, error)
     33 
     34 	// GetBlockByID fetches block with given ID from the database.
     35 	GetBlockByID(ctx context.Context, id string) (*gtsmodel.Block, error)
     36 
     37 	// GetBlockByURI fetches block with given AP URI from the database.
     38 	GetBlockByURI(ctx context.Context, uri string) (*gtsmodel.Block, error)
     39 
     40 	// GetBlock returns the block from account1 targeting account2, if it exists, or an error if it doesn't.
     41 	GetBlock(ctx context.Context, account1 string, account2 string) (*gtsmodel.Block, error)
     42 
     43 	// PutBlock attempts to place the given account block in the database.
     44 	PutBlock(ctx context.Context, block *gtsmodel.Block) error
     45 
     46 	// DeleteBlockByID removes block with given ID from the database.
     47 	DeleteBlockByID(ctx context.Context, id string) error
     48 
     49 	// DeleteBlockByURI removes block with given AP URI from the database.
     50 	DeleteBlockByURI(ctx context.Context, uri string) error
     51 
     52 	// DeleteAccountBlocks will delete all database blocks to / from the given account ID.
     53 	DeleteAccountBlocks(ctx context.Context, accountID string) error
     54 
     55 	// GetRelationship retrieves the relationship of the targetAccount to the requestingAccount.
     56 	GetRelationship(ctx context.Context, requestingAccount string, targetAccount string) (*gtsmodel.Relationship, Error)
     57 
     58 	// GetFollowByID fetches follow with given ID from the database.
     59 	GetFollowByID(ctx context.Context, id string) (*gtsmodel.Follow, error)
     60 
     61 	// GetFollowByURI fetches follow with given AP URI from the database.
     62 	GetFollowByURI(ctx context.Context, uri string) (*gtsmodel.Follow, error)
     63 
     64 	// GetFollow retrieves a follow if it exists between source and target accounts.
     65 	GetFollow(ctx context.Context, sourceAccountID string, targetAccountID string) (*gtsmodel.Follow, error)
     66 
     67 	// PopulateFollow populates the struct pointers on the given follow.
     68 	PopulateFollow(ctx context.Context, follow *gtsmodel.Follow) error
     69 
     70 	// GetFollowRequestByID fetches follow request with given ID from the database.
     71 	GetFollowRequestByID(ctx context.Context, id string) (*gtsmodel.FollowRequest, error)
     72 
     73 	// GetFollowRequestByURI fetches follow request with given AP URI from the database.
     74 	GetFollowRequestByURI(ctx context.Context, uri string) (*gtsmodel.FollowRequest, error)
     75 
     76 	// GetFollowRequest retrieves a follow request if it exists between source and target accounts.
     77 	GetFollowRequest(ctx context.Context, sourceAccountID string, targetAccountID string) (*gtsmodel.FollowRequest, error)
     78 
     79 	// IsFollowing returns true if sourceAccount follows target account, or an error if something goes wrong while finding out.
     80 	IsFollowing(ctx context.Context, sourceAccountID string, targetAccountID string) (bool, Error)
     81 
     82 	// IsMutualFollowing returns true if account1 and account2 both follow each other, or an error if something goes wrong while finding out.
     83 	IsMutualFollowing(ctx context.Context, sourceAccountID string, targetAccountID string) (bool, Error)
     84 
     85 	// IsFollowRequested returns true if sourceAccount has requested to follow target account, or an error if something goes wrong while finding out.
     86 	IsFollowRequested(ctx context.Context, sourceAccountID string, targetAccountID string) (bool, Error)
     87 
     88 	// PutFollow attempts to place the given account follow in the database.
     89 	PutFollow(ctx context.Context, follow *gtsmodel.Follow) error
     90 
     91 	// UpdateFollow updates one follow by ID.
     92 	UpdateFollow(ctx context.Context, follow *gtsmodel.Follow, columns ...string) error
     93 
     94 	// PutFollowRequest attempts to place the given account follow request in the database.
     95 	PutFollowRequest(ctx context.Context, follow *gtsmodel.FollowRequest) error
     96 
     97 	// UpdateFollowRequest updates one follow request by ID.
     98 	UpdateFollowRequest(ctx context.Context, followRequest *gtsmodel.FollowRequest, columns ...string) error
     99 
    100 	// DeleteFollowByID deletes a follow from the database with the given ID.
    101 	DeleteFollowByID(ctx context.Context, id string) error
    102 
    103 	// DeleteFollowByURI deletes a follow from the database with the given URI.
    104 	DeleteFollowByURI(ctx context.Context, uri string) error
    105 
    106 	// DeleteFollowRequestByID deletes a follow request from the database with the given ID.
    107 	DeleteFollowRequestByID(ctx context.Context, id string) error
    108 
    109 	// DeleteFollowRequestByURI deletes a follow request from the database with the given URI.
    110 	DeleteFollowRequestByURI(ctx context.Context, uri string) error
    111 
    112 	// DeleteAccountFollows will delete all database follows to / from the given account ID.
    113 	DeleteAccountFollows(ctx context.Context, accountID string) error
    114 
    115 	// DeleteAccountFollowRequests will delete all database follow requests to / from the given account ID.
    116 	DeleteAccountFollowRequests(ctx context.Context, accountID string) error
    117 
    118 	// AcceptFollowRequest moves a follow request in the database from the follow_requests table to the follows table.
    119 	// In other words, it should create the follow, and delete the existing follow request.
    120 	//
    121 	// It will return the newly created follow for further processing.
    122 	AcceptFollowRequest(ctx context.Context, originAccountID string, targetAccountID string) (*gtsmodel.Follow, Error)
    123 
    124 	// RejectFollowRequest fetches a follow request from the database, and then deletes it.
    125 	RejectFollowRequest(ctx context.Context, originAccountID string, targetAccountID string) Error
    126 
    127 	// GetAccountFollows returns a slice of follows owned by the given accountID.
    128 	GetAccountFollows(ctx context.Context, accountID string) ([]*gtsmodel.Follow, error)
    129 
    130 	// GetAccountLocalFollows returns a slice of follows owned by the given accountID, only including follows from this instance.
    131 	GetAccountLocalFollows(ctx context.Context, accountID string) ([]*gtsmodel.Follow, error)
    132 
    133 	// CountAccountFollows returns the amount of accounts that the given accountID is following.
    134 	CountAccountFollows(ctx context.Context, accountID string) (int, error)
    135 
    136 	// CountAccountLocalFollows returns the amount of accounts that the given accountID is following, only including follows from this instance.
    137 	CountAccountLocalFollows(ctx context.Context, accountID string) (int, error)
    138 
    139 	// GetAccountFollowers fetches follows that target given accountID.
    140 	GetAccountFollowers(ctx context.Context, accountID string) ([]*gtsmodel.Follow, error)
    141 
    142 	// GetAccountLocalFollowers fetches follows that target given accountID, only including follows from this instance.
    143 	GetAccountLocalFollowers(ctx context.Context, accountID string) ([]*gtsmodel.Follow, error)
    144 
    145 	// CountAccountFollowers returns the amounts that the given ID is followed by.
    146 	CountAccountFollowers(ctx context.Context, accountID string) (int, error)
    147 
    148 	// CountAccountLocalFollowers returns the amounts that the given ID is followed by, only including follows from this instance.
    149 	CountAccountLocalFollowers(ctx context.Context, accountID string) (int, error)
    150 
    151 	// GetAccountFollowRequests returns all follow requests targeting the given account.
    152 	GetAccountFollowRequests(ctx context.Context, accountID string) ([]*gtsmodel.FollowRequest, error)
    153 
    154 	// GetAccountFollowRequesting returns all follow requests originating from the given account.
    155 	GetAccountFollowRequesting(ctx context.Context, accountID string) ([]*gtsmodel.FollowRequest, error)
    156 
    157 	// CountAccountFollowRequests returns number of follow requests targeting the given account.
    158 	CountAccountFollowRequests(ctx context.Context, accountID string) (int, error)
    159 
    160 	// CountAccountFollowerRequests returns number of follow requests originating from the given account.
    161 	CountAccountFollowRequesting(ctx context.Context, accountID string) (int, error)
    162 }