Documentation
¶
Index ¶
Constants ¶
View Source
const ( MIN_REGISTRATION_CODE = 100_000 MAX_REGISTRATION_CODE = 999_999 MIN_SIGNIN_CODE = 100_000 MAX_SIGNIN_CODE = 999_999 )
View Source
const ( ACCESS_TOKEN_EXPIRY = time.Hour * 3 REFRESH_TOKEN_EXPIRY = time.Hour * 24 * 7 * 2 )
View Source
const ( MAX_SEARCH_LIMIT = 10 GITHUB_LINK_TYPE = "github" TELEGRAM_LINK_TYPE = "telegram" MAX_SOCIAL_LINKS_COUNT = 2 )
Variables ¶
View Source
var ( ErrInternal = errors.New("internal server error") ErrUsernameCannotContainSpecialCharacters = errors.New("username cannot contain special characters") ErrInternalTryAgainLater = errors.New("internal server error, please try again later") ErrInvalidCredentials = errors.New("invalid credentials") ErrInvalidCode = errors.New("invalid code") ErrUserNotFound = errors.New("user not found") ErrFollowToYourself = errors.New("you cannot follow to yourself") ErrAlreadyFollowing = errors.New("you are already following this user") ErrCooldown = errors.New("cooldown") ErrFieldsNotAllowedToUpdate = errors.New("these fields are not allowed to be updated") ErrUserWithUsernameAlreadyExists = errors.New("user with this username is already exists") ErrUserWithEmailAlreadyExists = errors.New("user with this email is already exists") ErrUserAlreadyExists = errors.New("user with this email or username is already exists") ErrFileMustBeImage = errors.New("file must be image") ErrFileMustHaveValidExtension = errors.New("file must have a valid extension") ErrFailedToUploadAvatarToCDN = errors.New("failed to upload avatar to cdn") ErrMaxSocialLinksAchieved = errors.New("maximum count of social links achieved") ErrLinkHasInvalidType = errors.New("the link has invalid type") ErrInvalidOldPassword = errors.New("invalid old password") ErrInvalidForgotPasswordCode = errors.New("invalid code") )
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth interface { SendRegistrationCode(ctx context.Context, input dto.CreateUserReq) error ResendRegistrationCode(ctx context.Context, input dto.CreateUserReq) error VerifyRegistrationCodeAndCreateUser(ctx context.Context, code int) (*dto.GetUserDto, *jwtmanager.JWTPair, error) SendSignInCode(ctx context.Context, signInDto dto.SignInReq) error VerifySignInCodeAndSignIn(ctx context.Context, code int) (*dto.GetUserDto, *jwtmanager.JWTPair, error) RefreshTokens(ctx context.Context, refreshToken string) (*jwtmanager.JWTPair, error) UpdatePassword(ctx context.Context, userID uuid.UUID, oldPassword, newPassword string) error RequestForgotPasswordCode(ctx context.Context, email string) error ChangeForgottenPasswordByCode(ctx context.Context, req dto.ChangeForgottenPasswordReq) error }
type Service ¶
func New ¶
func New(logger *zap.Logger, repo *repository.Repository, rabbitmq *rabbitmq.MQConn) *Service
type User ¶
type User interface { FindByID(ctx context.Context, id uuid.UUID) (*model.FullUser, error) FindByUsername(ctx context.Context, getterID *uuid.UUID, username string) (*dto.GetUserDto, error) SearchByUsername(ctx context.Context, username string, limit int, offset int) ([]*dto.GetUserDto, error) FindUserFollowers(ctx context.Context, id uuid.UUID, limit int, offset int) ([]*model.FullFollower, error) Follow(ctx context.Context, follower model.Follower) error Unfollow(ctx context.Context, follower model.Follower) error UpdateNewPostNotificationsEnabled(ctx context.Context, follower model.Follower) error FindUserFollows(ctx context.Context, id uuid.UUID, limit int, offset int) ([]*model.FullFollower, error) Update(ctx context.Context, user model.FullUser, updates map[string]interface{}) error SetAvatar(ctx context.Context, user model.FullUser, fileHeader *multipart.FileHeader) error AddSocialLink(ctx context.Context, user model.FullUser, link string) error DeleteSocialLink(ctx context.Context, user model.FullUser, platform string) error }
Click to show internal directories.
Click to hide internal directories.