Fix check of source of MAM message

This commit is contained in:
fiaxh 2019-09-10 22:03:24 +02:00
parent e84f2c4956
commit 307f16cc86

View file

@ -94,11 +94,16 @@ public class ReceivedPipelineListener : StanzaListener<MessageStanza> {
public override string[] after_actions { get { return after_actions_const; } } public override string[] after_actions { get { return after_actions_const; } }
public override async bool run(XmppStream stream, MessageStanza message) { public override async bool run(XmppStream stream, MessageStanza message) {
// if (message.from != stream.remote_name) return;
if (stream.get_flag(Flag.IDENTITY) == null) return false; if (stream.get_flag(Flag.IDENTITY) == null) return false;
StanzaNode? message_node = message.stanza.get_deep_subnode(NS_VER(stream) + ":result", "urn:xmpp:forward:0:forwarded", Xmpp.NS_URI + ":message"); StanzaNode? message_node = message.stanza.get_deep_subnode(NS_VER(stream) + ":result", "urn:xmpp:forward:0:forwarded", Xmpp.NS_URI + ":message");
if (message_node != null) { if (message_node != null) {
// MAM messages must come from our server // TODO or a MUC server
if (!message.from.equals(stream.get_flag(Bind.Flag.IDENTITY).my_jid.bare_jid)) {
warning("Received alledged MAM message from %s, ignoring", message.from.to_string());
return true;
}
StanzaNode? forward_node = message.stanza.get_deep_subnode(NS_VER(stream) + ":result", "urn:xmpp:forward:0:forwarded", DelayedDelivery.NS_URI + ":delay"); StanzaNode? forward_node = message.stanza.get_deep_subnode(NS_VER(stream) + ":result", "urn:xmpp:forward:0:forwarded", DelayedDelivery.NS_URI + ":delay");
DateTime? datetime = DelayedDelivery.Module.get_time_for_node(forward_node); DateTime? datetime = DelayedDelivery.Module.get_time_for_node(forward_node);
message.add_flag(new MessageFlag(datetime)); message.add_flag(new MessageFlag(datetime));