Closed marcinadd closed 4 years ago
Ok. But don't forget that deleted message should be only for one user. I mean if user A deletes a message, user B should still have it.
I have started implementing it , by having a new table called associations where you associate a message with a user. When you create a new message you create new entries in the associations table where you have the user , the message and an id as an index ( so by creating a message you create an entry for the sender and one for the receiver) . You can now filter your messages that you get from the server based on this table ( so we hide the messages you deleted from your view)
Good idea.
public void deleteMessageForUser(Message messageToBeDeleted, User user){
Optional<Association> messageOptional = associationRepository.findByUser(user).stream()
.filter(association -> messageToBeDeleted.equals(association.getMessage()))
.findFirst();
messageOptional.ifPresent(association -> associationRepository.delete(association));
}
}
I regard that better option is to use findFirstByUserAndMessage(), it isn't?
yeap something like that , I have it in a fork . I want to add something more concrete in the unit test ( like test containers) as mocking with the current state is an issue
No problem. If you have any suggestions or enhancements just open a new issue.
Ok. I'll look at it tomorrow.
I can give it a go