Package api.mpba.rastvdmy.service.impl
Class MessageServiceImpl
java.lang.Object
api.mpba.rastvdmy.service.impl.MessageServiceImpl
- All Implemented Interfaces:
 MessageService
Implementation of the MessageService interface for managing messages between users.
 This service provides methods for sending and retrieving messages,
 including message encryption and decryption functionalities.
- 
Constructor Summary
ConstructorsConstructorDescriptionMessageServiceImpl(MessageRepository messageRepository, UserProfileRepository userProfileRepository, TokenVerifierService tokenVerifierService) Constructor for MessageServiceImpl. - 
Method Summary
Modifier and TypeMethodDescriptionRetrieves all messages, decrypting their content before returning.sendMessage(jakarta.servlet.http.HttpServletRequest request, String receiverEmail, String content) Sends a message from the sender to the specified receiver. 
- 
Constructor Details
- 
MessageServiceImpl
@Autowired public MessageServiceImpl(MessageRepository messageRepository, UserProfileRepository userProfileRepository, TokenVerifierService tokenVerifierService) Constructor for MessageServiceImpl.- Parameters:
 messageRepository- the message repository to be useduserProfileRepository- the user profile repository to be usedtokenVerifierService- the service for extracting user token and getting user data from the request
 
 - 
 - 
Method Details
- 
getMessages
Retrieves all messages, decrypting their content before returning.- Specified by:
 getMessagesin interfaceMessageService- Returns:
 - a list of decrypted messages
 
 - 
sendMessage
public Message sendMessage(jakarta.servlet.http.HttpServletRequest request, String receiverEmail, String content) throws Exception Sends a message from the sender to the specified receiver.- Specified by:
 sendMessagein interfaceMessageService- Parameters:
 request- the HTTP request containing user datareceiverEmail- the email of the receivercontent- the content of the message- Returns:
 - the saved Message object
 - Throws:
 Exception- if an error occurs during message sending
 
 -