aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-11-30 21:18:48 +0100
committerChristian Schneppe <christian@pix-art.de>2018-11-30 21:18:48 +0100
commit591f585a7a1eaafaf388821dc05a638c7d3044be (patch)
tree9b10d086500aa23992382337e7a77040f7394e4b /src
parent126b71398479c39c915d2205ec316703a9d2dfbb (diff)
transmit display name (nick) in subscription requests
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Contact.java3
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java5
-rw-r--r--src/main/java/de/pixart/messenger/generator/PresenceGenerator.java10
-rw-r--r--src/main/java/de/pixart/messenger/parser/PresenceParser.java6
4 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Contact.java b/src/main/java/de/pixart/messenger/entities/Contact.java
index 1df6e120a..aa7319ad9 100644
--- a/src/main/java/de/pixart/messenger/entities/Contact.java
+++ b/src/main/java/de/pixart/messenger/entities/Contact.java
@@ -21,6 +21,7 @@ import java.util.Locale;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.android.AbstractPhoneContact;
+import de.pixart.messenger.services.QuickConversationsService;
import de.pixart.messenger.utils.JidHelper;
import de.pixart.messenger.utils.UIHelper;
import de.pixart.messenger.xml.Element;
@@ -133,7 +134,7 @@ public class Contact implements ListItem, Blockable {
return this.systemName;
} else if (!TextUtils.isEmpty(this.serverName)) {
return this.serverName;
- } else if (!TextUtils.isEmpty(this.presenceName) && mutualPresenceSubscription()) {
+ } else if (!TextUtils.isEmpty(this.presenceName) && ((QuickConversationsService.isQuicksy() && Config.QUICKSY_DOMAIN.equals(jid.getDomain())) ||mutualPresenceSubscription())) {
return this.presenceName;
} else if (jid.getLocal() != null) {
return JidHelper.localPartOrFallback(jid);
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index 1fa1c7a2d..b6179fa2e 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -29,6 +29,7 @@ import de.pixart.messenger.Config;
import de.pixart.messenger.crypto.OmemoSetting;
import de.pixart.messenger.crypto.PgpDecryptionService;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
+import de.pixart.messenger.services.QuickConversationsService;
import de.pixart.messenger.utils.JidHelper;
import de.pixart.messenger.xmpp.chatstate.ChatState;
import de.pixart.messenger.xmpp.mam.MamReference;
@@ -561,10 +562,10 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
return contactJid.getLocal() != null ? contactJid.getLocal() : contactJid;
}
}
- } else if (isWithStranger()) {
+ } else if ((QuickConversationsService.isConversations() || !Config.QUICKSY_DOMAIN.equals(contactJid.getDomain())) && isWithStranger()) {
return contactJid;
} else {
- return this.getContact().getDisplayName();
+ return this.getContact().getDisplayName();public PresencePacket requestPresenceUpdatesFrom(Contact contact) {
}
}
diff --git a/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java b/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java
index 95221ce31..b89783e07 100644
--- a/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java
@@ -1,10 +1,13 @@
package de.pixart.messenger.generator;
+import android.text.TextUtils;
+
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.entities.MucOptions;
import de.pixart.messenger.entities.Presence;
import de.pixart.messenger.services.XmppConnectionService;
+import de.pixart.messenger.utils.Namespace;
import de.pixart.messenger.xml.Element;
import de.pixart.messenger.xmpp.stanzas.PresencePacket;
@@ -23,7 +26,12 @@ public class PresenceGenerator extends AbstractGenerator {
}
public PresencePacket requestPresenceUpdatesFrom(Contact contact) {
- return subscription("subscribe", contact);
+ PresencePacket packet = subscription("subscribe", contact);
+ String displayName = contact.getAccount().getDisplayName();
+ if (!TextUtils.isEmpty(displayName)) {
+ packet.addChild("nick", Namespace.NICK).setContent(displayName);
+ }
+ return packet;
}
public PresencePacket stopPresenceUpdatesFrom(Contact contact) {
diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
index 710eca717..0e0b67382 100644
--- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java
+++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
@@ -256,9 +256,6 @@ public class PresenceParser extends AbstractParser implements
final Contact contact = account.getRoster().getContact(from);
if (type == null) {
final String resource = from.isBareJid() ? "" : from.getResource();
- if (contact.setPresenceName(packet.findChildContent("nick", Namespace.NICK))) {
- mXmppConnectionService.getAvatarService().clear(contact);
- }
Avatar avatar = Avatar.parsePresence(packet.findChild("x", "vcard-temp:x:update"));
if (avatar != null && (!contact.isSelf() || account.getAvatar() == null)) {
avatar.owner = from.asBareJid();
@@ -336,6 +333,9 @@ public class PresenceParser extends AbstractParser implements
}
mXmppConnectionService.onContactStatusChanged.onContactStatusChanged(contact, false);
} else if (type.equals("subscribe")) {
+ if (contact.setPresenceName(packet.findChildContent("nick", Namespace.NICK))) {
+ mXmppConnectionService.getAvatarService().clear(contact);
+ }
if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
mXmppConnectionService.sendPresencePacket(account,
mPresenceGenerator.sendPresenceUpdatesTo(contact));