gtsocial-umbx

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

admin.go (2761B)


      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 	"net"
     23 
     24 	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
     25 )
     26 
     27 // Admin contains functions related to instance administration (new signups etc).
     28 type Admin interface {
     29 	// IsUsernameAvailable checks whether a given username is available on our domain.
     30 	// Returns an error if the username is already taken, or something went wrong in the db.
     31 	IsUsernameAvailable(ctx context.Context, username string) (bool, Error)
     32 
     33 	// IsEmailAvailable checks whether a given email address for a new account is available to be used on our domain.
     34 	// Return an error if:
     35 	// A) the email is already associated with an account
     36 	// B) we block signups from this email domain
     37 	// C) something went wrong in the db
     38 	IsEmailAvailable(ctx context.Context, email string) (bool, Error)
     39 
     40 	// NewSignup creates a new user in the database with the given parameters.
     41 	// By the time this function is called, it should be assumed that all the parameters have passed validation!
     42 	NewSignup(ctx context.Context, username string, reason string, requireApproval bool, email string, password string, signUpIP net.IP, locale string, appID string, emailVerified bool, externalID string, admin bool) (*gtsmodel.User, Error)
     43 
     44 	// CreateInstanceAccount creates an account in the database with the same username as the instance host value.
     45 	// Ie., if the instance is hosted at 'example.org' the instance user will have a username of 'example.org'.
     46 	// This is needed for things like serving files that belong to the instance and not an individual user/account.
     47 	CreateInstanceAccount(ctx context.Context) Error
     48 
     49 	// CreateInstanceInstance creates an instance in the database with the same domain as the instance host value.
     50 	// Ie., if the instance is hosted at 'example.org' the instance will have a domain of 'example.org'.
     51 	// This is needed for things like serving instance information through /api/v1/instance
     52 	CreateInstanceInstance(ctx context.Context) Error
     53 }