add omemo fingerprints to web links as well
This commit is contained in:
parent
6e289b8738
commit
56991bbaeb
|
@ -610,23 +610,17 @@ public class Account extends AbstractEntity {
|
||||||
List<XmppUri.Fingerprint> fingerprints = this.getFingerprints();
|
List<XmppUri.Fingerprint> fingerprints = this.getFingerprints();
|
||||||
String uri = "xmpp:"+this.getJid().toBareJid().toString();
|
String uri = "xmpp:"+this.getJid().toBareJid().toString();
|
||||||
if (fingerprints.size() > 0) {
|
if (fingerprints.size() > 0) {
|
||||||
StringBuilder builder = new StringBuilder(uri);
|
return XmppUri.getFingerprintUri(uri,fingerprints,';');
|
||||||
builder.append('?');
|
} else {
|
||||||
for(int i = 0; i < fingerprints.size(); ++i) {
|
return uri;
|
||||||
XmppUri.FingerprintType type = fingerprints.get(i).type;
|
|
||||||
if (type == XmppUri.FingerprintType.OMEMO) {
|
|
||||||
builder.append(XmppUri.OMEMO_URI_PARAM);
|
|
||||||
builder.append(fingerprints.get(i).deviceId);
|
|
||||||
} else if (type == XmppUri.FingerprintType.OTR) {
|
|
||||||
builder.append(XmppUri.OTR_URI_PARAM);
|
|
||||||
}
|
|
||||||
builder.append('=');
|
|
||||||
builder.append(fingerprints.get(i).fingerprint);
|
|
||||||
if (i != fingerprints.size() -1) {
|
|
||||||
builder.append(';');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder.toString();
|
|
||||||
|
public String getShareableLink() {
|
||||||
|
List<XmppUri.Fingerprint> fingerprints = this.getFingerprints();
|
||||||
|
String uri = "https://conversations.im/i/"+this.getJid().toBareJid().toString();
|
||||||
|
if (fingerprints.size() > 0) {
|
||||||
|
return XmppUri.getFingerprintUri(uri,fingerprints,'&');
|
||||||
} else {
|
} else {
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
|
@ -756,7 +756,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
intent.setType("text/plain");
|
intent.setType("text/plain");
|
||||||
String text;
|
String text;
|
||||||
if (http) {
|
if (http) {
|
||||||
text = "https://conversations.im/i/"+mAccount.getJid().toBareJid().toString();
|
text = mAccount.getShareableLink();
|
||||||
} else {
|
} else {
|
||||||
text = mAccount.getShareableUri();
|
text = mAccount.getShareableUri();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ public class XmppUri {
|
||||||
jid = segments.get(1) + "@" + segments.get(2);
|
jid = segments.get(1) + "@" + segments.get(2);
|
||||||
}
|
}
|
||||||
muc = segments.size() > 1 && "j".equalsIgnoreCase(segments.get(0));
|
muc = segments.size() > 1 && "j".equalsIgnoreCase(segments.get(0));
|
||||||
|
fingerprints = parseFingerprints(uri.getQuery(),'&');
|
||||||
} else if ("xmpp".equalsIgnoreCase(scheme)) {
|
} else if ("xmpp".equalsIgnoreCase(scheme)) {
|
||||||
// sample: xmpp:foo@bar.com
|
// sample: xmpp:foo@bar.com
|
||||||
muc = isMuc(uri.getQuery());
|
muc = isMuc(uri.getQuery());
|
||||||
|
@ -166,6 +167,26 @@ public class XmppUri {
|
||||||
OTR
|
OTR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getFingerprintUri(String base, List<XmppUri.Fingerprint> fingerprints, char seperator) {
|
||||||
|
StringBuilder builder = new StringBuilder(base);
|
||||||
|
builder.append('?');
|
||||||
|
for(int i = 0; i < fingerprints.size(); ++i) {
|
||||||
|
XmppUri.FingerprintType type = fingerprints.get(i).type;
|
||||||
|
if (type == XmppUri.FingerprintType.OMEMO) {
|
||||||
|
builder.append(XmppUri.OMEMO_URI_PARAM);
|
||||||
|
builder.append(fingerprints.get(i).deviceId);
|
||||||
|
} else if (type == XmppUri.FingerprintType.OTR) {
|
||||||
|
builder.append(XmppUri.OTR_URI_PARAM);
|
||||||
|
}
|
||||||
|
builder.append('=');
|
||||||
|
builder.append(fingerprints.get(i).fingerprint);
|
||||||
|
if (i != fingerprints.size() -1) {
|
||||||
|
builder.append(seperator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public static class Fingerprint {
|
public static class Fingerprint {
|
||||||
public final FingerprintType type;
|
public final FingerprintType type;
|
||||||
public final String fingerprint;
|
public final String fingerprint;
|
||||||
|
|
Loading…
Reference in a new issue