services

package
v0.0.0-...-5df9c1d Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatService

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

func NewChatService

NewChatService can be used as a constructor to create a ChatService "object"

func (*ChatService) CreateChat

func (service *ChatService) CreateChat(req *models.ChatCreateRequestDTO, currentUsername string) (*models.ChatCreateResponseDTO, *customerrors.CustomError, int)

CreateChat creates a chat for a given post id, username and the current logged-in user

func (*ChatService) GetChatsByUsername

func (service *ChatService) GetChatsByUsername(username string) (*models.ChatsResponseDTO, *customerrors.CustomError, int)

GetChatsByUsername retrieves all chats of a user by its username

type ChatServiceInterface

type ChatServiceInterface interface {
	CreateChat(req *models.ChatCreateRequestDTO, currentUsername string) (*models.ChatCreateResponseDTO, *customerrors.CustomError, int)
	GetChatsByUsername(username string) (*models.ChatsResponseDTO, *customerrors.CustomError, int)
}

type CommentService

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

func NewCommentService

NewCommentService can be used as a constructor to create a CommentService "object"

func (*CommentService) CreateComment

func (service *CommentService) CreateComment(req *models.CommentCreateRequestDTO, postId, currentUsername string) (*models.CommentResponseDTO, *customerrors.CustomError, int)

CreateComment creates a new comment for a given post id using the provided request data

func (*CommentService) GetCommentsByPostId

func (service *CommentService) GetCommentsByPostId(postId string, offset, limit int) (*models.CommentFeedResponseDTO, *customerrors.CustomError, int)

GetCommentsByPostId retrieves comments for a given post id using the provided pagination information

type CommentServiceInterface

type CommentServiceInterface interface {
	CreateComment(req *models.CommentCreateRequestDTO, postId, currentUsername string) (*models.CommentResponseDTO, *customerrors.CustomError, int)
	GetCommentsByPostId(postId string, offset, limit int) (*models.CommentFeedResponseDTO, *customerrors.CustomError, int)
}

type FeedService

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

func NewFeedService

NewFeedService can be used as a constructor to create a FeedService "object"

func (*FeedService) GetPostsByHashtag

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

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

func (*FeedService) GetPostsByUsername

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

GetPostsByUsername returns a pagination object with the posts of a user using pagination parameters

func (*FeedService) GetPostsGlobalFeed

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

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

func (*FeedService) GetPostsPersonalFeed

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

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

type FeedServiceInterface

type FeedServiceInterface interface {
	GetPostsByUsername(username string, offset, limit int, currentUsername string) (*models.UserFeedDTO, *customerrors.CustomError, int)
	GetPostsGlobalFeed(lastPostId string, limit int, currentUsername string) (*models.GeneralFeedDTO, *customerrors.CustomError, int)
	GetPostsPersonalFeed(username string, lastPostId string, limit int, currentUsername string) (*models.GeneralFeedDTO, *customerrors.CustomError, int)
	GetPostsByHashtag(hashtag string, lastPostId string, limit int, currentUsername string) (*models.GeneralFeedDTO, *customerrors.CustomError, int)
}

type ImageService

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

func NewImageService

func NewImageService(imageRepo repositories.ImageRepositoryInterface) *ImageService

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

func (*ImageService) GetImageById

func (service *ImageService) GetImageById(imageId string) (*models.ImageDTO, *customerrors.CustomError, int)

GetImageById can be used in image controller to return an image from the database

type ImageServiceInterface

type ImageServiceInterface interface {
	GetImageById(imageId string) (*models.ImageDTO, *customerrors.CustomError, int)
}

type LikeService

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

func NewLikeService

NewLikeService can be used as a constructor to create a LikeService "object"

func (*LikeService) DeleteLike

func (service *LikeService) DeleteLike(postId string, currentUsername string) (*customerrors.CustomError, int)

DeleteLike deletes a like for a given post id and the current logged-in user

func (*LikeService) PostLike

func (service *LikeService) PostLike(postId, currentUsername string) (*customerrors.CustomError, int)

PostLike creates a like for a given post id and the current logged-in user

type LikeServiceInterface

type LikeServiceInterface interface {
	PostLike(postId, currentUsername string) (*customerrors.CustomError, int)
	DeleteLike(postId, currentUsername 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 MessageService

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

func NewMessageService

NewMessageService can be used as a constructor to create a MessageService "object"

func (*MessageService) CreateMessage

func (service *MessageService) CreateMessage(chatId, currentUsername string, req *models.MessageCreateRequestDTO, connectedParticipants []string) (*models.MessageRecordDTO, *customerrors.CustomError, int)

CreateMessage creates a new message for a given chatId and username

func (*MessageService) GetChatById

func (service *MessageService) GetChatById(chatId string, currentUsername string) (*models.Chat, *customerrors.CustomError, int)

GetChatById retrieves a chat by its chatId and checks if the current user is a participant of the chat

func (*MessageService) GetMessagesByChatId

func (service *MessageService) GetMessagesByChatId(chatId, currentUsername string, offset, limit int) (*models.MessagesResponseDTO, *customerrors.CustomError, int)

GetMessagesByChatId retrieves all messages of a chat by its chatId

type MessageServiceInterface

type MessageServiceInterface interface {
	GetChatById(chatId string, currentUsername string) (*models.Chat, *customerrors.CustomError, int)
	GetMessagesByChatId(chatId, currentUsername string, offset, limit int) (*models.MessagesResponseDTO, *customerrors.CustomError, int)
	CreateMessage(chatId, currentUsername string, req *models.MessageCreateRequestDTO, connectedParticipants []string) (*models.MessageRecordDTO, *customerrors.CustomError, int)
}

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 NotificationService

type NotificationService struct {
	PushSubscriptionService PushSubscriptionServiceInterface
	// contains filtered or unexported fields
}

func NewNotificationService

func NewNotificationService(
	notificationRepository repositories.NotificationRepositoryInterface,
	puhSubscriptionService PushSubscriptionServiceInterface) *NotificationService

NewNotificationService can be used as a constructor to create a NotificationService "object"

func (*NotificationService) CreateNotification

func (service *NotificationService) CreateNotification(notificationType string, forUsername string, fromUsername string) error

CreateNotification is a service function that creates a notification and pushes it to client if push service is registered

func (*NotificationService) DeleteNotificationById

func (service *NotificationService) DeleteNotificationById(notificationId string, currentUsername string) (*customerrors.CustomError, int)

DeleteNotificationById is a service function that deletes a notification by its id

func (*NotificationService) GetNotifications

func (service *NotificationService) GetNotifications(username string) (*models.NotificationsResponseDTO, *customerrors.CustomError, int)

GetNotifications is a service function that gets all notifications for the current user

type NotificationServiceInterface

type NotificationServiceInterface interface {
	CreateNotification(notificationType string, forUsername string, fromUsername string) error
	GetNotifications(username string) (*models.NotificationsResponseDTO, *customerrors.CustomError, int)
	DeleteNotificationById(notificationId string, currentUsername string) (*customerrors.CustomError, int)
}

type PasswordResetService

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

func NewPasswordResetService

NewPasswordResetService can be used as a constructor to generate a new PasswordResetService "object"

func (*PasswordResetService) InitiatePasswordReset

func (service *PasswordResetService) InitiatePasswordReset(username string) (*models.InitiatePasswordResetResponseDTO, *customerrors.CustomError, int)

InitiatePasswordReset initiates a password reset process by generating a token and sending it via email

func (*PasswordResetService) ResetPassword

func (service *PasswordResetService) ResetPassword(username string, req *models.ResetPasswordRequestDTO) (*customerrors.CustomError, int)

ResetPassword sets a new password for the user if the provided token is valid and the password meets policy requirements

type PasswordResetServiceInterface

type PasswordResetServiceInterface interface {
	InitiatePasswordReset(username string) (*models.InitiatePasswordResetResponseDTO, *customerrors.CustomError, int)
	ResetPassword(username string, req *models.ResetPasswordRequestDTO) (*customerrors.CustomError, int)
}

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

type PostServiceInterface

type PostServiceInterface interface {
	CreatePost(req *models.PostCreateRequestDTO, username string) (*models.PostResponseDTO, *customerrors.CustomError, int)
	DeletePost(postId string, username string) (*customerrors.CustomError, int)
}

type PushSubscriptionService

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

func NewPushSubscriptionService

func NewPushSubscriptionService(pushSubscriptionRepo repositories.PushSubscriptionRepositoryInterface) *PushSubscriptionService

NewPushSubscriptionService can be used as a constructor to create a PushSubscriptionService "object"

func (*PushSubscriptionService) CreatePushSubscription

CreatePushSubscription saves a new push subscription key to the database to send notifications to the client

func (*PushSubscriptionService) GetVapidKey

GetVapidKey returns a VAPID key for clients to register for push notifications

func (*PushSubscriptionService) SendPushMessages

func (service *PushSubscriptionService) SendPushMessages(notificationObject *models.NotificationRecordDTO, toUsername string)

SendPushMessages sends push messages to all push subscriptions of a user

type PushSubscriptionServiceInterface

type PushSubscriptionServiceInterface interface {
	GetVapidKey() (*models.VapidKeyResponseDTO, *customerrors.CustomError, int)
	CreatePushSubscription(req *models.PushSubscriptionRequestDTO, currentUsername string) (*models.PushSubscriptionResponseDTO, *customerrors.CustomError, int)
	SendPushMessages(notificationObject *models.NotificationRecordDTO, toUsername string)
}

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(queryType 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(queryType 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

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.UserCreateResponseDTO, *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.UserInformationUpdateRequestDTO, currentUsername string) (*models.UserInformationUpdateResponseDTO, *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