Skip to content

Commit

Permalink
Send new invite notification to same user if rooms are different
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Dor committed Sep 28, 2017
1 parent 2e7b5d2 commit c816217
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/io/kamax/mxisd/invitation/InvitationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,16 @@ public synchronized IThreePidInviteReply storeInvite(IThreePidInvite invitation)

String invId = getId(invitation);
log.info("Handling invite for {}:{} from {} in room {}", invitation.getMedium(), invitation.getAddress(), invitation.getSender(), invitation.getRoomId());
if (invitations.containsKey(invId)) {
IThreePidInviteReply reply = invitations.get(invId);
if (reply != null) {
log.info("Invite is already pending for {}:{}, returning data", invitation.getMedium(), invitation.getAddress());
return invitations.get(invId);
if (!StringUtils.equals(invitation.getRoomId(), reply.getInvite().getRoomId())) {
log.info("Sending new notification as new invite room {} is different from the original {}", invitation.getRoomId(), reply.getInvite().getRoomId());
notifMgr.sendForInvite(new ThreePidInviteReply(reply.getId(), invitation, reply.getToken(), reply.getDisplayName()));
} else {
// FIXME we should check attempt and send if bigger
}
return reply;
}

Optional<?> result = lookupMgr.find(invitation.getMedium(), invitation.getAddress(), true);
Expand All @@ -220,7 +227,7 @@ public synchronized IThreePidInviteReply storeInvite(IThreePidInvite invitation)
String token = RandomStringUtils.randomAlphanumeric(64);
String displayName = invitation.getAddress().substring(0, 3) + "...";

IThreePidInviteReply reply = new ThreePidInviteReply(invId, invitation, token, displayName);
reply = new ThreePidInviteReply(invId, invitation, token, displayName);

log.info("Performing invite to {}:{}", invitation.getMedium(), invitation.getAddress());
notifMgr.sendForInvite(reply);
Expand Down

0 comments on commit c816217

Please sign in to comment.