user.go (2455B)
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 // User contains functions related to user getting/setting/creation. 27 type User interface { 28 // GetAllUsers returns all local user accounts, or an error if something goes wrong. 29 GetAllUsers(ctx context.Context) ([]*gtsmodel.User, Error) 30 // GetUserByID returns one user with the given ID, or an error if something goes wrong. 31 GetUserByID(ctx context.Context, id string) (*gtsmodel.User, Error) 32 // GetUserByAccountID returns one user by its account ID, or an error if something goes wrong. 33 GetUserByAccountID(ctx context.Context, accountID string) (*gtsmodel.User, Error) 34 // GetUserByID returns one user with the given email address, or an error if something goes wrong. 35 GetUserByEmailAddress(ctx context.Context, emailAddress string) (*gtsmodel.User, Error) 36 // GetUserByExternalID returns one user with the given external id, or an error if something goes wrong. 37 GetUserByExternalID(ctx context.Context, id string) (*gtsmodel.User, Error) 38 // GetUserByConfirmationToken returns one user by its confirmation token, or an error if something goes wrong. 39 GetUserByConfirmationToken(ctx context.Context, confirmationToken string) (*gtsmodel.User, Error) 40 // PutUser will attempt to place user in the database 41 PutUser(ctx context.Context, user *gtsmodel.User) Error 42 // UpdateUser updates one user by its primary key, updating either only the specified columns, or all of them. 43 UpdateUser(ctx context.Context, user *gtsmodel.User, columns ...string) Error 44 // DeleteUserByID deletes one user by its ID. 45 DeleteUserByID(ctx context.Context, userID string) Error 46 }