services

package
v0.0.0-...-1f82a06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImageService

type ImageService struct {
	// contains filtered or unexported fields
}

func NewImageService

func NewImageService(fileSystem repositories.FileSystemInterface, validator utils.ValidatorInterface) *ImageService

NewImageService can be used as a constructor to create a ImageService "object"

func (*ImageService) DeleteImage

func (service *ImageService) DeleteImage(filename string) (*customerrors.CustomError, int)

DeleteImage can be used in other services to delete an image from the file system

func (*ImageService) GetImage

func (service *ImageService) GetImage(filename string) ([]byte, *customerrors.CustomError, int)

GetImage can be used in image controller to return an image from the file system

func (*ImageService) SaveImage

func (service *ImageService) SaveImage(fileHeader multipart.FileHeader) (string, *customerrors.CustomError, int)

SaveImage can be used in other services to save an image to the file system and return the image url

type ImageServiceInterface

type ImageServiceInterface interface {
	SaveImage(fileHeader multipart.FileHeader) (string, *customerrors.CustomError, int)
	GetImage(filename string) ([]byte, *customerrors.CustomError, int)
	DeleteImage(filename string) (*customerrors.CustomError, int)
}

type MailService

type MailService struct {
}

func NewMailService

func NewMailService() *MailService

NewMailService can be used as a constructor to generate a new MailService "object"

func (*MailService) SendMail

func (service *MailService) SendMail(receiver string, subject string, body string) error

SendMail sends a mail to a receiver with the given subject and body text

type MailServiceInterface

type MailServiceInterface interface {
	SendMail(receiver string, subject string, body string) error
}

type MockMailService

type MockMailService struct {
	mock.Mock
	MailServiceInterface
}

MockMailService is a mock implementation of the MailServiceInterface

func (*MockMailService) SendMail

func (m *MockMailService) SendMail(receiver string, subject string, body string) error

type PostService

type PostService struct {
	// contains filtered or unexported fields
}

func NewPostService

NewPostService can be used as a constructor to create a PostService "object"

func (*PostService) CreatePost

func (*PostService) DeletePost

func (service *PostService) DeletePost(postId string, username string) (*customerrors.CustomError, int)

DeletePost deletes a post by id and returns an error if the post does not exist or the requesting user is not the author

func (*PostService) GetPostsByHashtag

func (service *PostService) GetPostsByHashtag(hashtag string, lastPostId string, limit int) (*models.GeneralFeedDTO, *customerrors.CustomError, int)

GetPostsByHashtag returns a pagination object with the posts in the personal feed using pagination parameters

func (*PostService) GetPostsByUsername

func (service *PostService) GetPostsByUsername(username string, offset, limit int) (*models.UserFeedDTO, *customerrors.CustomError, int)

func (*PostService) GetPostsGlobalFeed

func (service *PostService) GetPostsGlobalFeed(lastPostId string, limit int) (*models.GeneralFeedDTO, *customerrors.CustomError, int)

GetPostsGlobalFeed returns a pagination object with the posts in the global feed using pagination parameters

func (*PostService) GetPostsPersonalFeed

func (service *PostService) GetPostsPersonalFeed(username string, lastPostId string, limit int) (*models.GeneralFeedDTO, *customerrors.CustomError, int)

GetPostsPersonalFeed returns a pagination object with the posts in the personal feed using pagination parameters

type PostServiceInterface

type PostServiceInterface interface {
	CreatePost(req *models.PostCreateRequestDTO, file *multipart.FileHeader, username string) (*models.PostResponseDTO, *customerrors.CustomError, int)
	GetPostsByUsername(username string, offset, limit int) (*models.UserFeedDTO, *customerrors.CustomError, int)
	GetPostsGlobalFeed(lastPostId string, limit int) (*models.GeneralFeedDTO, *customerrors.CustomError, int)
	GetPostsPersonalFeed(username string, lastPostId string, limit int) (*models.GeneralFeedDTO, *customerrors.CustomError, int)
	DeletePost(postId string, username string) (*customerrors.CustomError, int)
	GetPostsByHashtag(hashtag string, lastPostId string, limit int) (*models.GeneralFeedDTO, *customerrors.CustomError, int)
}

type SubscriptionService

type SubscriptionService struct {
	// contains filtered or unexported fields
}

func (*SubscriptionService) DeleteSubscription

func (service *SubscriptionService) DeleteSubscription(subscriptionId string, currentUsername string) (*customerrors.CustomError, int)

func (*SubscriptionService) GetSubscriptions

func (service *SubscriptionService) GetSubscriptions(ftype string, limit int, offset int, username string, currentUsername string) (*models.SubscriptionResponseDTO, *customerrors.CustomError, int)

func (*SubscriptionService) PostSubscription

type SubscriptionServiceInterface

type SubscriptionServiceInterface interface {
	PostSubscription(req *models.SubscriptionPostRequestDTO, currentUsername string) (*models.SubscriptionPostResponseDTO, *customerrors.CustomError, int)
	DeleteSubscription(subscriptionId string, currentUsername string) (*customerrors.CustomError, int)
	GetSubscriptions(ftype string, limit int, offset int, username string, currentUsername string) (*models.SubscriptionResponseDTO, *customerrors.CustomError, int)
}

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

NewUserService can be used as a constructor to generate a new UserService "object"

func (*UserService) ActivateUser

func (service *UserService) ActivateUser(username string, token string) (*models.UserLoginResponseDTO, *customerrors.CustomError, int)

ActivateUser can be called from the controller to verify email using token and returns response, error and status code

func (*UserService) ChangeUserPassword

func (service *UserService) ChangeUserPassword(req *models.ChangePasswordDTO, currentUsername string) (*customerrors.CustomError, int)

ChangeUserPassword can be called from the controller to update a user's password

func (*UserService) CreateUser

CreateUser can be called from the controller and saves the user to the db and returns response, error and status code

func (*UserService) GetUserProfile

func (service *UserService) GetUserProfile(username string, currentUser string) (*models.UserProfileResponseDTO, *customerrors.CustomError, int)

GetUserProfile returns information about the user

func (*UserService) LoginUser

LoginUser can be called from the controller and verifies password and returns response, error and status code

func (*UserService) RefreshToken

RefreshToken can be called from the controller with refresh token to return a new access token

func (*UserService) ResendActivationToken

func (service *UserService) ResendActivationToken(username string) (*customerrors.CustomError, int)

ResendActivationToken can be sent from controller to resend a six digit code via mail

func (*UserService) SearchUser

func (service *UserService) SearchUser(username string, limit int, offset int, currentUsername string) (*models.UserSearchResponseDTO, *customerrors.CustomError, int)

SearchUser can be called from the controller to search for users and returns response, error and status code

func (*UserService) UpdateUserInformation

func (service *UserService) UpdateUserInformation(req *models.UserInformationUpdateDTO, currentUsername string) (*models.UserInformationUpdateDTO, *customerrors.CustomError, int)

UpdateUserInformation can be called from the controller to update a user's nickname and status

type UserServiceInterface

type UserServiceInterface interface {
	CreateUser(req models.UserCreateRequestDTO) (*models.UserResponseDTO, *customerrors.CustomError, int)
	LoginUser(req models.UserLoginRequestDTO) (*models.UserLoginResponseDTO, *customerrors.CustomError, int)
	ActivateUser(username string, token string) (*models.UserLoginResponseDTO, *customerrors.CustomError, int)
	ResendActivationToken(username string) (*customerrors.CustomError, int)
	RefreshToken(req *models.UserRefreshTokenRequestDTO) (*models.UserLoginResponseDTO, *customerrors.CustomError, int)
	SearchUser(username string, limit int, offset int, currentUsername string) (*models.UserSearchResponseDTO, *customerrors.CustomError, int)
	UpdateUserInformation(req *models.UserInformationUpdateDTO, currentUsername string) (*models.UserInformationUpdateDTO, *customerrors.CustomError, int)
	ChangeUserPassword(req *models.ChangePasswordDTO, currentUsername string) (*customerrors.CustomError, int)
	GetUserProfile(username string, currentUser string) (*models.UserProfileResponseDTO, *customerrors.CustomError, int)
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL