aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-08-31 15:43:20 +0200
committerChristian Schneppe <christian@pix-art.de>2019-08-31 15:43:20 +0200
commitcce36fcbb7834f731e5117981ef5f55f27ec11a2 (patch)
tree9373c6841116bc9006e87c324e2670da19070930 /src/main/java
parent24ca2a88fb1013a78d00fb6580853583bc6e7a7f (diff)
include pgp sig and status in presence to non anon muc
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/generator/PresenceGenerator.java23
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java16
2 files changed, 16 insertions, 23 deletions
diff --git a/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java b/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java
index b89783e07..02bd5b078 100644
--- a/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/PresenceGenerator.java
@@ -50,15 +50,20 @@ public class PresenceGenerator extends AbstractGenerator {
return selfPresence(account, status, true);
}
- public PresencePacket selfPresence(Account account, Presence.Status status, boolean includePgpAnnouncement) {
- PresencePacket packet = new PresencePacket();
- if (status.toShowString() != null) {
- packet.addChild("show").setContent(status.toShowString());
- }
- packet.setFrom(account.getJid());
- final String sig = account.getPgpSignature();
- if (includePgpAnnouncement && sig != null && mXmppConnectionService.getPgpEngine() != null) {
- packet.addChild("x", "jabber:x:signed").setContent(sig);
+ public PresencePacket selfPresence(final Account account, final Presence.Status status, final boolean personal) {
+ final PresencePacket packet = new PresencePacket();
+ if (personal) {
+ final String sig = account.getPgpSignature();
+ final String message = account.getPresenceStatusMessage();
+ if (status.toShowString() != null) {
+ packet.addChild("show").setContent(status.toShowString());
+ }
+ if (!TextUtils.isEmpty(message)) {
+ packet.addChild(new Element("status").setContent(message));
+ }
+ if (sig != null && mXmppConnectionService.getPgpEngine() != null) {
+ packet.addChild("x", "jabber:x:signed").setContent(sig);
+ }
}
final String capHash = getCapHash(account);
if (capHash != null) {
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index c1d5655f5..8fc39b97b 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -3105,16 +3105,8 @@ public class XmppConnectionService extends Service {
callback.error(R.string.nick_in_use, conversation);
}
});
-
- PresencePacket packet = new PresencePacket();
+ final PresencePacket packet = mPresenceGenerator.selfPresence(account, Presence.Status.ONLINE, options.nonanonymous());
packet.setTo(joinJid);
- packet.setFrom(conversation.getAccount().getJid());
-
- String sig = account.getPgpSignature();
- if (sig != null) {
- packet.addChild("status").setContent("online");
- packet.addChild("x", "jabber:x:signed").setContent(sig);
- }
sendPresencePacket(account, packet);
} else {
conversation.setContactJid(joinJid);
@@ -4461,11 +4453,7 @@ public class XmppConnectionService extends Service {
} else {
status = getTargetPresence();
}
- PresencePacket packet = mPresenceGenerator.selfPresence(account, status);
- String message = account.getPresenceStatusMessage();
- if (message != null && !message.isEmpty()) {
- packet.addChild(new Element("status").setContent(message));
- }
+ final PresencePacket packet = mPresenceGenerator.selfPresence(account, status);
if (mLastActivity > 0 && includeIdleTimestamp) {
long since = Math.min(mLastActivity, System.currentTimeMillis()); //don't send future dates
packet.addChild("idle", Namespace.IDLE).setAttribute("since", AbstractGenerator.getTimestamp(since));