aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/parser/MessageParser.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-01-09 22:21:40 +0100
committerChristian Schneppe <christian@pix-art.de>2017-01-09 22:21:40 +0100
commit135e9c9bdc66a58781211f45e1cb0517ad675d20 (patch)
treec3880342e0b2adc226aa2a9c292bb0430b9b693a /src/main/java/de/pixart/messenger/parser/MessageParser.java
parent1f23f9448356c04092e7c0c21e589aba26dde595 (diff)
automatically bookmark private, non-anonymous mucs where inviter is trusted
Diffstat (limited to 'src/main/java/de/pixart/messenger/parser/MessageParser.java')
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 69c2faff9..b6f68e364 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -167,12 +167,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
private class Invite {
- Jid jid;
- String password;
-
- Invite(Jid jid, String password) {
+ final Jid jid;
+ final String password;
+ final Contact inviter;
+ Invite(Jid jid, String password, Contact inviter) {
this.jid = jid;
this.password = password;
+ this.inviter = inviter;
}
public boolean execute(Account account) {
@@ -181,7 +182,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (!conversation.getMucOptions().online()) {
conversation.getMucOptions().setPassword(password);
mXmppConnectionService.databaseBackend.updateConversation(conversation);
- mXmppConnectionService.joinMuc(conversation);
+ mXmppConnectionService.joinMuc(conversation, inviter != null && inviter.mutualPresenceSubscription());
mXmppConnectionService.updateConversationUi();
}
return true;
@@ -190,18 +191,22 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
}
- private Invite extractInvite(Element message) {
+ private Invite extractInvite(Account account, Element message) {
Element x = message.findChild("x", "http://jabber.org/protocol/muc#user");
if (x != null) {
Element invite = x.findChild("invite");
if (invite != null) {
Element pw = x.findChild("password");
- return new Invite(message.getAttributeAsJid("from"), pw != null ? pw.getContent() : null);
+ Jid from = invite.getAttributeAsJid("from");
+ Contact contact = from == null ? null : account.getRoster().getContact(from);
+ return new Invite(message.getAttributeAsJid("from"), pw != null ? pw.getContent() : null, contact);
}
} else {
x = message.findChild("x", "jabber:x:conference");
if (x != null) {
- return new Invite(x.getAttributeAsJid("jid"), x.getAttribute("password"));
+ Jid from = message.getAttributeAsJid("from");
+ Contact contact = from == null ? null : account.getRoster().getContact(from);
+ return new Invite(x.getAttributeAsJid("jid"), x.getAttribute("password"), contact);
}
}
return null;
@@ -364,7 +369,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
counterpart = from;
}
- Invite invite = extractInvite(packet);
+ Invite invite = extractInvite(account, packet);
if (invite != null && invite.execute(account)) {
return;
}