Documentation ¶
Index ¶
- type ChatService
- type ChatServiceInterface
- type CommentService
- func (service *CommentService) CreateComment(req *models.CommentCreateRequestDTO, postId, currentUsername string) (*models.CommentResponseDTO, *customerrors.CustomError, int)
- func (service *CommentService) GetCommentsByPostId(postId string, offset, limit int) (*models.CommentFeedResponseDTO, *customerrors.CustomError, int)
- type CommentServiceInterface
- type FeedService
- func (service *FeedService) GetPostsByHashtag(hashtag string, lastPostId string, limit int, currentUsername string) (*models.GeneralFeedDTO, *customerrors.CustomError, int)
- func (service *FeedService) GetPostsByUsername(username string, offset, limit int, currentUsername string) (*models.UserFeedDTO, *customerrors.CustomError, int)
- func (service *FeedService) GetPostsGlobalFeed(lastPostId string, limit int, currentUsername string) (*models.GeneralFeedDTO, *customerrors.CustomError, int)
- func (service *FeedService) GetPostsPersonalFeed(username string, lastPostId string, limit int, currentUsername string) (*models.GeneralFeedDTO, *customerrors.CustomError, int)
- type FeedServiceInterface
- type ImageService
- type ImageServiceInterface
- type LikeService
- type LikeServiceInterface
- type MailService
- type MailServiceInterface
- type MessageService
- func (service *MessageService) CreateMessage(chatId, currentUsername string, req *models.MessageCreateRequestDTO, ...) (*models.MessageRecordDTO, *customerrors.CustomError, int)
- func (service *MessageService) GetChatById(chatId string, currentUsername string) (*models.Chat, *customerrors.CustomError, int)
- func (service *MessageService) GetMessagesByChatId(chatId, currentUsername string, offset, limit int) (*models.MessagesResponseDTO, *customerrors.CustomError, int)
- type MessageServiceInterface
- type MockMailService
- type NotificationService
- func (service *NotificationService) CreateNotification(notificationType string, forUsername string, fromUsername string) error
- func (service *NotificationService) DeleteNotificationById(notificationId string, currentUsername string) (*customerrors.CustomError, int)
- func (service *NotificationService) GetNotifications(username string) (*models.NotificationsResponseDTO, *customerrors.CustomError, int)
- type NotificationServiceInterface
- type PasswordResetService
- type PasswordResetServiceInterface
- type PostService
- type PostServiceInterface
- type PushSubscriptionService
- func (service *PushSubscriptionService) CreatePushSubscription(req *models.PushSubscriptionRequestDTO, currentUsername string) (*models.PushSubscriptionResponseDTO, *customerrors.CustomError, int)
- func (service *PushSubscriptionService) GetVapidKey() (*models.VapidKeyResponseDTO, *customerrors.CustomError, int)
- func (service *PushSubscriptionService) SendPushMessages(notificationObject *models.NotificationRecordDTO, toUsername string)
- type PushSubscriptionServiceInterface
- type SubscriptionService
- func (service *SubscriptionService) DeleteSubscription(subscriptionId string, currentUsername string) (*customerrors.CustomError, int)
- func (service *SubscriptionService) GetSubscriptions(queryType string, limit int, offset int, username string, ...) (*models.SubscriptionResponseDTO, *customerrors.CustomError, int)
- func (service *SubscriptionService) PostSubscription(req *models.SubscriptionPostRequestDTO, currentUsername string) (*models.SubscriptionPostResponseDTO, *customerrors.CustomError, int)
- type SubscriptionServiceInterface
- type UserService
- func (service *UserService) ActivateUser(username string, token string) (*models.UserLoginResponseDTO, *customerrors.CustomError, int)
- func (service *UserService) ChangeUserPassword(req *models.ChangePasswordDTO, currentUsername string) (*customerrors.CustomError, int)
- func (service *UserService) CreateUser(req models.UserCreateRequestDTO) (*models.UserCreateResponseDTO, *customerrors.CustomError, int)
- func (service *UserService) GetUserProfile(username string, currentUser string) (*models.UserProfileResponseDTO, *customerrors.CustomError, int)
- func (service *UserService) LoginUser(req models.UserLoginRequestDTO) (*models.UserLoginResponseDTO, *customerrors.CustomError, int)
- func (service *UserService) RefreshToken(req *models.UserRefreshTokenRequestDTO) (*models.UserLoginResponseDTO, *customerrors.CustomError, int)
- func (service *UserService) ResendActivationToken(username string) (*customerrors.CustomError, int)
- func (service *UserService) SearchUser(username string, limit int, offset int, currentUsername string) (*models.UserSearchResponseDTO, *customerrors.CustomError, int)
- func (service *UserService) UpdateUserInformation(req *models.UserInformationUpdateRequestDTO, currentUsername string) (*models.UserInformationUpdateResponseDTO, *customerrors.CustomError, int)
- type UserServiceInterface
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 ¶
func NewChatService( chatRepo repositories.ChatRepositoryInterface, userRepo repositories.UserRepositoryInterface, notificationService NotificationServiceInterface) *ChatService
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 ¶
func NewCommentService(commentRepo repositories.CommentRepositoryInterface, postRepo repositories.PostRepositoryInterface, userRepo repositories.UserRepositoryInterface) *CommentService
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 ¶
func NewFeedService(postRepo repositories.PostRepositoryInterface, userRepo repositories.UserRepositoryInterface, likeRepo repositories.LikeRepositoryInterface, commentRepo repositories.CommentRepositoryInterface) *FeedService
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 ¶
func NewLikeService( likeRepo repositories.LikeRepositoryInterface, postRepo repositories.PostRepositoryInterface) *LikeService
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"
type MailServiceInterface ¶
type MessageService ¶
type MessageService struct {
// contains filtered or unexported fields
}
func NewMessageService ¶
func NewMessageService(messageRepo repositories.MessageRepositoryInterface, chatRepo repositories.ChatRepositoryInterface, notificationService NotificationServiceInterface) *MessageService
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
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 ¶
func NewPasswordResetService(userRepo repositories.UserRepositoryInterface, passwordResetRepo repositories.PasswordResetRepositoryInterface, mailService MailServiceInterface, validator utils.ValidatorInterface) *PasswordResetService
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 ¶
func NewPostService(postRepo repositories.PostRepositoryInterface, userRepo repositories.UserRepositoryInterface, hashtagRepo repositories.HashtagRepositoryInterface, validator utils.ValidatorInterface, likeRepo repositories.LikeRepositoryInterface, commentRepo repositories.CommentRepositoryInterface, notificationService NotificationServiceInterface) *PostService
NewPostService can be used as a constructor to create a PostService "object"
func (*PostService) CreatePost ¶
func (service *PostService) CreatePost(req *models.PostCreateRequestDTO, username string) (*models.PostResponseDTO, *customerrors.CustomError, int)
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 ¶
func (service *PushSubscriptionService) CreatePushSubscription(req *models.PushSubscriptionRequestDTO, currentUsername string) (*models.PushSubscriptionResponseDTO, *customerrors.CustomError, int)
CreatePushSubscription saves a new push subscription key to the database to send notifications to the client
func (*PushSubscriptionService) GetVapidKey ¶
func (service *PushSubscriptionService) GetVapidKey() (*models.VapidKeyResponseDTO, *customerrors.CustomError, int)
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 NewSubscriptionService ¶
func NewSubscriptionService( subscriptionRepo repositories.SubscriptionRepositoryInterface, userRepo repositories.UserRepositoryInterface, notificationService NotificationServiceInterface) *SubscriptionService
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 ¶
func (service *SubscriptionService) PostSubscription(req *models.SubscriptionPostRequestDTO, currentUsername string) (*models.SubscriptionPostResponseDTO, *customerrors.CustomError, int)
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 ¶
func NewUserService( userRepo repositories.UserRepositoryInterface, activationTokenRepo repositories.ActivationTokenRepositoryInterface, mailService MailServiceInterface, validator utils.ValidatorInterface, postRepo repositories.PostRepositoryInterface, imageRepo repositories.ImageRepositoryInterface, subscriptionRepo repositories.SubscriptionRepositoryInterface) *UserService
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 ¶
func (service *UserService) CreateUser(req models.UserCreateRequestDTO) (*models.UserCreateResponseDTO, *customerrors.CustomError, int)
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 ¶
func (service *UserService) LoginUser(req models.UserLoginRequestDTO) (*models.UserLoginResponseDTO, *customerrors.CustomError, int)
LoginUser can be called from the controller and verifies password and returns response, error and status code
func (*UserService) RefreshToken ¶
func (service *UserService) RefreshToken(req *models.UserRefreshTokenRequestDTO) (*models.UserLoginResponseDTO, *customerrors.CustomError, int)
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.UserInformationUpdateRequestDTO, currentUsername string) (*models.UserInformationUpdateResponseDTO, *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.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 }