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 @Override
public boolean isDomainBlocked() { public boolean isDomainBlocked() {
return getAccount().isBlocked(Jid.ofDomain(this.getJid().getDomain())); return getAccount().isBlocked(this.getJid().getDomain());
} }
@Override @Override
public Jid getBlockedJid() { public Jid getBlockedJid() {
if (isDomainBlocked()) { if (isDomainBlocked()) {
return Jid.ofDomain(getJid().getDomain()); return getJid().getDomain();
} else { } else {
return getJid(); return getJid();
} }

View file

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

View file

@ -520,7 +520,7 @@ public class UIHelper {
return ((Conversation) conversation).getMucOptions().getSelf().getName(); return ((Conversation) conversation).getMucOptions().getSelf().getName();
} else { } else {
final Jid jid = conversation.getAccount().getJid(); 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 @Override
public eu.siacs.conversations.xmpp.Jid withResource(CharSequence resource) { public eu.siacs.conversations.xmpp.Jid withResource(CharSequence resource) {
final Localpart localpart = inner.getLocalpartOrNull();
try { try {
return new WrappedJid( final Resourcepart resourcepart = Resourcepart.from(resource.toString());
JidCreate.fullFrom( if (localpart == null) {
inner.getLocalpartOrThrow(), return new WrappedJid(JidCreate.domainFullFrom(inner.getDomain(),resourcepart));
inner.getDomain(), } else {
Resourcepart.from(resource.toString()) return new WrappedJid(
)); JidCreate.fullFrom(
localpart,
inner.getDomain(),
resourcepart
));
}
} catch (XmppStringprepException e) { } catch (XmppStringprepException e) {
throw new IllegalArgumentException(e); throw new IllegalArgumentException(e);
} }

View file

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