@Override
public void onEvent(UsersInvited event) {
User currentUser = authorizedUserService.getCurrentUser();
for(User invitee: event.getUsers()) {
Contract contract = event.getContract();
Invitation invitation = invitationDAO.getInvitation(currentUser.getId(), invitee.getId(), contract.getId());
if(invitation == null) {
invitation = new Invitation();
invitation.setContract(contract);
invitation.setInvitee(invitee);
invitation.setInviter(currentUser);
}
invitation.setInvitationDate(new Date());
invitationDAO.save(invitation);
}
}