fix jid.withResource() for domain jids

This commit is contained in:
Daniel Gultsch 2020-05-18 09:14:57 +02:00
parent a0920b83e2
commit df3273a6fc
5 changed files with 18 additions and 12 deletions

View file

@ -451,13 +451,13 @@ public class Contact implements ListItem, Blockable {
@Override
public boolean isDomainBlocked() {
return getAccount().isBlocked(Jid.ofDomain(this.getJid().getDomain()));
return getAccount().isBlocked(this.getJid().getDomain());
}
@Override
public Jid getBlockedJid() {
if (isDomainBlocked()) {
return Jid.ofDomain(getJid().getDomain());
return getJid().getDomain();
} else {
return getJid();
}

View file

@ -2821,7 +2821,7 @@ public class XmppConnectionService extends Service {
boolean changed = false;
for (ListIterator<Jid> iterator = cryptoTargets.listIterator(); iterator.hasNext(); ) {
Jid jid = iterator.next();
if (!members.contains(jid) && !members.contains(Jid.ofDomain(jid.getDomain()))) {
if (!members.contains(jid) && !members.contains(jid.getDomain())) {
iterator.remove();
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": removed " + jid + " from crypto targets of " + conversation.getName());
changed = true;

View file

@ -520,7 +520,7 @@ public class UIHelper {
return ((Conversation) conversation).getMucOptions().getSelf().getName();
} else {
final Jid jid = conversation.getAccount().getJid();
return jid.getLocal() != null ? jid.getLocal() : Jid.ofDomain(jid.getDomain()).toString();
return jid.getLocal() != null ? jid.getLocal() : jid.getDomain().toString();
}
}
}

View file

@ -40,13 +40,19 @@ public class WrappedJid implements eu.siacs.conversations.xmpp.Jid {
@Override
public eu.siacs.conversations.xmpp.Jid withResource(CharSequence resource) {
final Localpart localpart = inner.getLocalpartOrNull();
try {
return new WrappedJid(
JidCreate.fullFrom(
inner.getLocalpartOrThrow(),
inner.getDomain(),
Resourcepart.from(resource.toString())
));
final Resourcepart resourcepart = Resourcepart.from(resource.toString());
if (localpart == null) {
return new WrappedJid(JidCreate.domainFullFrom(inner.getDomain(),resourcepart));
} else {
return new WrappedJid(
JidCreate.fullFrom(
localpart,
inner.getDomain(),
resourcepart
));
}
} catch (XmppStringprepException e) {
throw new IllegalArgumentException(e);
}

View file

@ -1276,7 +1276,7 @@ public class XmppConnection implements Runnable {
private void sendServiceDiscoveryItems(final Jid server) {
mPendingServiceDiscoveries.incrementAndGet();
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
iq.setTo(Jid.ofDomain(server.getDomain()));
iq.setTo(server.getDomain());
iq.query("http://jabber.org/protocol/disco#items");
this.sendIqPacket(iq, (account, packet) -> {
if (packet.getType() == IqPacket.TYPE.RESULT) {
@ -1641,7 +1641,7 @@ public class XmppConnection implements Runnable {
public Identity getServerIdentity() {
synchronized (this.disco) {
ServiceDiscoveryResult result = disco.get(Jid.ofDomain(account.getJid().getDomain()));
ServiceDiscoveryResult result = disco.get(account.getJid().getDomain());
if (result == null) {
return Identity.UNKNOWN;
}