aboutsummaryrefslogtreecommitdiff
path: root/libdino/src
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-08-14 20:22:52 +0200
committerfiaxh <git@lightrise.org>2021-08-17 22:32:33 +0200
commit447464f4d1ac0c184764f103ac9e51f7ff2dce91 (patch)
treedf4aab32001564c5aa706500ce6e7d68904e2d47 /libdino/src
parentcf8501ba30e26bbc02b42204acf5cff650b338f4 (diff)
downloaddino-447464f4d1ac0c184764f103ac9e51f7ff2dce91.tar.gz
dino-447464f4d1ac0c184764f103ac9e51f7ff2dce91.zip
Display message delivery error, color text using theme colors
fixes #672
Diffstat (limited to 'libdino/src')
-rw-r--r--libdino/src/entity/message.vala5
-rw-r--r--libdino/src/service/message_processor.vala13
2 files changed, 17 insertions, 1 deletions
diff --git a/libdino/src/entity/message.vala b/libdino/src/entity/message.vala
index 7192f6aa..9c062f73 100644
--- a/libdino/src/entity/message.vala
+++ b/libdino/src/entity/message.vala
@@ -16,9 +16,12 @@ public class Message : Object {
UNSENT,
WONTSEND,
SENDING,
- SENT
+ SENT,
+ ERROR
}
+ public static Marked[] MARKED_RECEIVED = new Marked[] { Marked.READ, Marked.RECEIVED, Marked.ACKNOWLEDGED };
+
public enum Type {
ERROR,
CHAT,
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala
index 669aa193..fcabeba6 100644
--- a/libdino/src/service/message_processor.vala
+++ b/libdino/src/service/message_processor.vala
@@ -144,6 +144,19 @@ public class MessageProcessor : StreamInteractionModule, Object {
hitted_range[query_id] = -2;
}
});
+ stream_interactor.module_manager.get_module(account, Xmpp.MessageModule.IDENTITY).received_error.connect((stream, message_stanza, error_stanza) => {
+ Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(message_stanza.from.bare_jid, account);
+ if (conversation == null) return;
+ Message? message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_stanza_id(message_stanza.id, conversation);
+ if (message == null) return;
+ // We don't care about delivery errors if our counterpart already ACKed the message.
+ if (message.marked in Message.MARKED_RECEIVED) return;
+
+ warning("Message delivery error from %s. Type: %s, Condition: %s, Text: %s", message_stanza.from.to_string(), error_stanza.type_ ?? "-", error_stanza.condition, error_stanza.text ?? "-");
+ if (error_stanza.condition == Xmpp.ErrorStanza.CONDITION_RECIPIENT_UNAVAILABLE && error_stanza.type_ == Xmpp.ErrorStanza.TYPE_CANCEL) return;
+
+ message.marked = Message.Marked.ERROR;
+ });
convert_sending_to_unsent_msgs(account);
}