parse 'received' carbon-copied error messages. fixes #3803

This commit is contained in:
Daniel Gultsch 2020-08-31 11:06:26 +02:00
parent 3dcb36a417
commit 064264c20b
2 changed files with 75 additions and 69 deletions

View File

@ -29,7 +29,7 @@ public class PresenceGenerator extends AbstractGenerator {
PresencePacket packet = subscription("subscribe", contact); PresencePacket packet = subscription("subscribe", contact);
String displayName = contact.getAccount().getDisplayName(); String displayName = contact.getAccount().getDisplayName();
if (!TextUtils.isEmpty(displayName)) { if (!TextUtils.isEmpty(displayName)) {
packet.addChild("nick",Namespace.NICK).setContent(displayName); packet.addChild("nick", Namespace.NICK).setContent(displayName);
} }
return packet; return packet;
} }
@ -55,7 +55,7 @@ public class PresenceGenerator extends AbstractGenerator {
if (personal) { if (personal) {
final String sig = account.getPgpSignature(); final String sig = account.getPgpSignature();
final String message = account.getPresenceStatusMessage(); final String message = account.getPresenceStatusMessage();
if(status.toShowString() != null) { if (status.toShowString() != null) {
packet.addChild("show").setContent(status.toShowString()); packet.addChild("show").setContent(status.toShowString());
} }
if (!TextUtils.isEmpty(message)) { if (!TextUtils.isEmpty(message)) {
@ -87,7 +87,7 @@ public class PresenceGenerator extends AbstractGenerator {
public PresencePacket sendOfflinePresence(Account account) { public PresencePacket sendOfflinePresence(Account account) {
PresencePacket packet = new PresencePacket(); PresencePacket packet = new PresencePacket();
packet.setFrom(account.getJid()); packet.setFrom(account.getJid());
packet.setAttribute("type","unavailable"); packet.setAttribute("type", "unavailable");
return packet; return packet;
} }
} }

View File

@ -308,8 +308,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
mXmppConnectionService.updateAccountUi(); mXmppConnectionService.updateAccountUi();
} }
private boolean handleErrorMessage(Account account, MessagePacket packet) { private boolean handleErrorMessage(final Account account, final MessagePacket packet) {
if (packet.getType() == MessagePacket.TYPE_ERROR) { if (packet.getType() == MessagePacket.TYPE_ERROR) {
if (packet.fromServer(account)) {
final Pair<MessagePacket, Long> forwarded = packet.getForwardedMessagePacket("received", "urn:xmpp:carbons:2");
if (forwarded != null) {
return handleErrorMessage(account, forwarded.first);
}
}
final Jid from = packet.getFrom(); final Jid from = packet.getFrom();
final String id = packet.getId(); final String id = packet.getId();
if (from != null && id != null) { if (from != null && id != null) {