allow roster action with name

This commit is contained in:
Christian Schneppe 2018-02-15 19:19:20 +01:00
parent 4467368c8c
commit a5176a16f2
2 changed files with 15 additions and 6 deletions

View file

@ -442,6 +442,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
}
final Contact contact = account.getRoster().getContact(contactJid);
if (invite.getName() != null) {
contact.setServerName(invite.getName());
}
if (contact.isSelf()) {
switchToConversation(contact, null);
return true;

View file

@ -17,6 +17,7 @@ public class XmppUri {
protected String fingerprint;
protected List<Fingerprint> fingerprints = new ArrayList<>();
private String body;
private String name;
private String action;
protected boolean safeSource = true;
public static final String OMEMO_URI_PARAM = "omemo-sid-";
@ -93,7 +94,8 @@ public class XmppUri {
}
}
this.fingerprints = parseFingerprints(uri.getQuery());
this.body = parseBody(uri.getQuery());
this.body = parseParameter("body", uri.getQuery());
this.name = parseParameter("name", uri.getQuery());
} else if ("imto".equalsIgnoreCase(scheme)) {
// sample: imto://xmpp/foo@bar.com
try {
@ -138,12 +140,12 @@ public class XmppUri {
return fingerprints;
}
protected String parseBody(String query) {
for(String pair : query == null ? new String[0] : query.split(";")) {
final String[] parts = pair.split("=",2);
if (parts.length == 2 && "body".equals(parts[0].toLowerCase(Locale.US))) {
protected String parseParameter(String key, String query) {
for (String pair : query == null ? new String[0] : query.split(";")) {
final String[] parts = pair.split("=", 2);
if (parts.length == 2 && key.equals(parts[0].toLowerCase(Locale.US))) {
try {
return URLDecoder.decode(parts[1],"UTF-8");
return URLDecoder.decode(parts[1], "UTF-8");
} catch (UnsupportedEncodingException e) {
return null;
}
@ -191,6 +193,10 @@ public class XmppUri {
return body;
}
public String getName() {
return name;
}
public List<Fingerprint> getFingerprints() {
return this.fingerprints;
}