From 02351dc0fb3e123b2a7e2705c65aba2b0ba06cc1 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 18 Sep 2019 09:55:18 +0200 Subject: [PATCH] fixed direct invites after adhoc --- .../generator/MessageGenerator.java | 4 ++++ .../services/ChannelDiscoveryService.java | 18 ++++++++++++++++-- .../services/XmppConnectionService.java | 9 +++++---- .../ui/util/MucDetailsContextMenuHelper.java | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java b/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java index 8f56d39bb..dbf8e7cb2 100644 --- a/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java @@ -193,6 +193,10 @@ public class MessageGenerator extends AbstractGenerator { if (password != null) { x.setAttribute("password", password); } + if (contact.isFullJid()) { + packet.addChild("no-store", "urn:xmpp:hints"); + packet.addChild("no-copy", "urn:xmpp:hints"); + } return packet; } diff --git a/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java b/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java index 24aa7bdac..680c3af4e 100644 --- a/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java +++ b/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java @@ -16,6 +16,7 @@ import eu.siacs.conversations.Config; import eu.siacs.conversations.http.HttpConnectionManager; import eu.siacs.conversations.http.services.MuclumbusService; import okhttp3.OkHttpClient; +import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -77,8 +78,8 @@ public class ChannelDiscoveryService { public void onResponse(@NonNull Call call, @NonNull Response response) { final MuclumbusService.Rooms body = response.body(); if (body == null) { - Log.d(Config.LOGTAG, "code from muclumbus=" + response.code()); listener.onChannelSearchResultsFound(Collections.emptyList()); + logError(response); return; } cache.put("", body.items); @@ -104,8 +105,8 @@ public class ChannelDiscoveryService { public void onResponse(@NonNull Call call, @NonNull Response response) { final MuclumbusService.SearchResult body = response.body(); if (body == null) { - Log.d(Config.LOGTAG, "code from muclumbus=" + response.code()); listener.onChannelSearchResultsFound(Collections.emptyList()); + logError(response); return; } cache.put(query, body.result.items); @@ -120,6 +121,19 @@ public class ChannelDiscoveryService { }); } + private static void logError(final Response response) { + final ResponseBody errorBody = response.errorBody(); + Log.d(Config.LOGTAG, "code from muclumbus=" + response.code()); + if (errorBody == null) { + return; + } + try { + Log.d(Config.LOGTAG,"error body="+errorBody.string()); + } catch (IOException e) { + //ignored + } + } + public interface OnChannelSearchResultsFound { void onChannelSearchResultsFound(List results); } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index e51c83a6a..5024a9613 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2947,9 +2947,11 @@ public class XmppConnectionService extends Service { for (Jid invite : jids) { invite(conversation, invite); } - if (account.countPresences() > 1) { - directInvite(conversation, account.getJid().asBareJid()); - } + for(String resource : account.getSelfContact().getPresences().toResourceArray()) { + Jid other = account.getJid().withResource(resource); + Log.d(Config.LOGTAG,account.getJid().asBareJid()+": sending direct invite to "+other); + directInvite(conversation, other); + } saveConversationAsBookmark(conversation, name); if (callback != null) { callback.success(conversation); @@ -3077,7 +3079,6 @@ public class XmppConnectionService extends Service { if (packet.getType() == IqPacket.TYPE.RESULT) { Data data = Data.parse(packet.query().findChild("x", Namespace.DATA)); data.submit(options); - Log.d(Config.LOGTAG,data.toString()); IqPacket set = new IqPacket(IqPacket.TYPE.SET); set.setTo(conversation.getJid().asBareJid()); set.query("http://jabber.org/protocol/muc#owner").addChild(data); diff --git a/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java b/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java index 28c869f1e..c3e874310 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java +++ b/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java @@ -178,7 +178,7 @@ public final class MucDetailsContextMenuHelper { return true; case R.id.invite: if (user.getAffiliation().ranks(MucOptions.Affiliation.MEMBER)) { - activity.xmppConnectionService.directInvite(conversation, jid); + activity.xmppConnectionService.directInvite(conversation, jid.asBareJid()); } else { activity.xmppConnectionService.invite(conversation, jid); }