aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-12-16 23:06:37 +0100
committerChristian Schneppe <christian@pix-art.de>2017-12-16 23:06:37 +0100
commit6f55d00c2c248676896b81a8f189a9de6d7a4ad7 (patch)
tree57343cc4e9b9bb36cbf01053a81d5d858bb26a99 /src/main/java/de/pixart/messenger
parent6da8c6ef3ba91c4ab22dad97c14e0a6f390cb002 (diff)
XmppUri: Parse 'message action' query
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartConversationActivity.java6
-rw-r--r--src/main/java/de/pixart/messenger/utils/XmppUri.java27
2 files changed, 23 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
index 5e7d8f0f1..d4f9c2385 100644
--- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
@@ -877,7 +877,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
return true;
}
List<Contact> contacts = xmppConnectionService.findContacts(invite.getJid(), invite.account);
- if (invite.isMuc()) {
+ if (invite.isAction(XmppUri.ACTION_JOIN)) {
Conversation muc = xmppConnectionService.findFirstMuc(invite.getJid());
if (muc != null) {
switchToConversation(muc, invite.getBody(), false);
@@ -1203,9 +1203,5 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
}
return false;
}
-
- public boolean isMuc() {
- return muc;
- }
}
}
diff --git a/src/main/java/de/pixart/messenger/utils/XmppUri.java b/src/main/java/de/pixart/messenger/utils/XmppUri.java
index f16ee58ad..63640089e 100644
--- a/src/main/java/de/pixart/messenger/utils/XmppUri.java
+++ b/src/main/java/de/pixart/messenger/utils/XmppUri.java
@@ -14,13 +14,15 @@ import de.pixart.messenger.xmpp.jid.Jid;
public class XmppUri {
protected String jid;
- protected boolean muc;
protected String fingerprint;
protected List<Fingerprint> fingerprints = new ArrayList<>();
private String body;
+ private String action;
protected boolean safeSource = true;
public static final String OMEMO_URI_PARAM = "omemo-sid-";
public static final String OTR_URI_PARAM = "otr-fingerprint";
+ public static final String ACTION_JOIN = "join";
+ public static final String ACTION_MESSAGE = "message";
public XmppUri(String uri) {
try {
@@ -68,11 +70,18 @@ public class XmppUri {
// sample : https://conversations.im/i/foo/bar.com
jid = segments.get(1) + "@" + segments.get(2);
}
- muc = segments.size() > 1 && "j".equalsIgnoreCase(segments.get(0));
+ if (segments.size() > 1 && "j".equalsIgnoreCase(segments.get(0))) {
+ action = ACTION_JOIN;
+ }
fingerprints = parseFingerprints(uri.getQuery(),'&');
} else if ("xmpp".equalsIgnoreCase(scheme)) {
// sample: xmpp:foo@bar.com
- muc = isMuc(uri.getQuery());
+ final String query = uri.getQuery();
+ if (hasAction(query, ACTION_JOIN)) {
+ this.action = ACTION_JOIN;
+ } else if (hasAction(query, ACTION_MESSAGE)) {
+ this.action = ACTION_MESSAGE;
+ }
if (uri.getAuthority() != null) {
jid = uri.getAuthority();
} else {
@@ -143,16 +152,24 @@ public class XmppUri {
return null;
}
- protected boolean isMuc(String query) {
+ private boolean hasAction(String query, String action) {
for(String pair : query == null ? new String[0] : query.split(";")) {
final String[] parts = pair.split("=",2);
- if (parts.length == 1 && "join".equals(parts[0])) {
+ if (parts.length == 1 && parts[0].equals(action)) {
return true;
}
}
return false;
}
+ public boolean isAction(final String action) {
+ if (this.action == null) {
+ return false;
+ }
+
+ return this.action.equals(action);
+ }
+
public Jid getJid() {
try {
return this.jid == null ? null : Jid.fromString(this.jid.toLowerCase());