Merge pull request #2791 from ChaosKid42/roster_action_with_name

allow roster action with name
This commit is contained in:
Daniel Gultsch 2018-02-12 20:27:49 +01:00 committed by GitHub
commit 347389c497
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -423,6 +423,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

@ -16,6 +16,7 @@ public class XmppUri {
protected String jid;
protected List<Fingerprint> fingerprints = new ArrayList<>();
private String body;
private String name;
private String action;
protected boolean safeSource = true;
@ -92,7 +93,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 {
@ -137,10 +139,10 @@ public class XmppUri {
return fingerprints;
}
protected String parseBody(String query) {
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 && "body".equals(parts[0].toLowerCase(Locale.US))) {
if (parts.length == 2 && key.equals(parts[0].toLowerCase(Locale.US))) {
try {
return URLDecoder.decode(parts[1],"UTF-8");
} catch (UnsupportedEncodingException e) {
@ -190,6 +192,10 @@ public class XmppUri {
return body;
}
public String getName() {
return name;
}
public List<Fingerprint> getFingerprints() {
return this.fingerprints;
}