1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 02:27:58 +01:00

[muc] Only retrieve MUCUser once in Presence listener

This commit is contained in:
Florian Schmaus 2020-11-08 19:37:41 +01:00
parent 5dfed2935f
commit f12fe2264a

View file

@ -195,6 +195,7 @@ public class MultiUserChat {
} }
final EntityFullJid myRoomJID = myRoomJid; final EntityFullJid myRoomJID = myRoomJid;
final boolean isUserStatusModification = presence.getFrom().equals(myRoomJID); final boolean isUserStatusModification = presence.getFrom().equals(myRoomJID);
final MUCUser mucUser = MUCUser.from(packet);
switch (presence.getType()) { switch (presence.getType()) {
case available: case available:
@ -205,9 +206,8 @@ public class MultiUserChat {
MUCAffiliation oldAffiliation = mucExtension.getItem().getAffiliation(); MUCAffiliation oldAffiliation = mucExtension.getItem().getAffiliation();
MUCRole oldRole = mucExtension.getItem().getRole(); MUCRole oldRole = mucExtension.getItem().getRole();
// Get the new occupant's affiliation & role // Get the new occupant's affiliation & role
mucExtension = MUCUser.from(packet); MUCAffiliation newAffiliation = mucUser.getItem().getAffiliation();
MUCAffiliation newAffiliation = mucExtension.getItem().getAffiliation(); MUCRole newRole = mucUser.getItem().getRole();
MUCRole newRole = mucExtension.getItem().getRole();
// Fire role modification events // Fire role modification events
checkRoleModifications(oldRole, newRole, isUserStatusModification, from); checkRoleModifications(oldRole, newRole, isUserStatusModification, from);
// Fire affiliation modification events // Fire affiliation modification events
@ -228,7 +228,6 @@ public class MultiUserChat {
break; break;
case unavailable: case unavailable:
occupantsMap.remove(from); occupantsMap.remove(from);
MUCUser mucUser = MUCUser.from(packet);
if (mucUser != null && mucUser.hasStatus()) { if (mucUser != null && mucUser.hasStatus()) {
if (isUserStatusModification) { if (isUserStatusModification) {
userHasLeft(); userHasLeft();