aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/message_processor.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2018-01-12 21:13:46 +0100
committerfiaxh <git@mx.ax.lt>2018-01-28 00:38:47 +0100
commitbbfac9115500405095210f046dbccef913d03e04 (patch)
treed8cce86ecf58e4cf9a0a3e5bc7192df0c12f1e94 /libdino/src/service/message_processor.vala
parent782ae4c049e2b6fab13d7453cbb0e74610e7d200 (diff)
downloaddino-bbfac9115500405095210f046dbccef913d03e04.tar.gz
dino-bbfac9115500405095210f046dbccef913d03e04.zip
Fix certain Slack specific issues (using host-based workarounds)
Diffstat (limited to 'libdino/src/service/message_processor.vala')
-rw-r--r--libdino/src/service/message_processor.vala18
1 files changed, 18 insertions, 0 deletions
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala
index ec6316a0..39f7f373 100644
--- a/libdino/src/service/message_processor.vala
+++ b/libdino/src/service/message_processor.vala
@@ -64,6 +64,7 @@ public class MessageProcessor : StreamInteractionModule, Object {
if (message.body == null) return;
Entities.Message new_message = create_in_message(account, message);
+ if (new_message == null) return;
determine_message_type(account, message, new_message);
}
@@ -82,6 +83,23 @@ public class MessageProcessor : StreamInteractionModule, Object {
new_message.ourpart = new_message.direction == Entities.Message.DIRECTION_SENT ? message.from : message.to;
new_message.stanza = message;
+ // Slack non-standard behavior
+ if (account.domainpart.index_of("xmpp.slack.com") == account.domainpart.length - 14) {
+ if (new_message.counterpart.equals_bare(account.bare_jid)) {
+ // Ignore messages from us, because we neither know which conversation they belong to, nor can match
+ // them to one of our send messages because of timestamp mismatches.
+ return null;
+ }
+ if (new_message.direction == Entities.Message.DIRECTION_RECEIVED && message.type_ == "chat" && new_message.body.index_of("["+account.localpart+"] ") == 0) {
+ // That is the best thing we can do, although allowing for attacks.
+ new_message.direction = Entities.Message.DIRECTION_SENT;
+ new_message.body = new_message.body.substring(account.localpart.length + 3);
+ }
+ if (message.stanza.get_attribute("ts") != null) {
+ new_message.time = new DateTime.from_unix_utc((int64) double.parse(message.stanza.get_attribute("ts")));
+ }
+ }
+
Xep.MessageArchiveManagement.MessageFlag? mam_message_flag = Xep.MessageArchiveManagement.MessageFlag.get_flag(message);
if (mam_message_flag != null) new_message.local_time = mam_message_flag.server_time;
if (new_message.local_time == null || new_message.local_time.compare(new DateTime.now_utc()) > 0) new_message.local_time = new DateTime.now_utc();