diff options
author | fiaxh <git@lightrise.org> | 2021-04-29 15:03:37 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2021-04-29 16:14:17 +0200 |
commit | 4c6664a365bb64904078c07c588f129456583457 (patch) | |
tree | 4b386cbfdb0ea3bd65bc5448c0a38a2aa1008519 /xmpp-vala/src/module/xep | |
parent | 421f43dd8bd993eb88581e1b5011cc061ceb4fc8 (diff) | |
download | dino-4c6664a365bb64904078c07c588f129456583457.tar.gz dino-4c6664a365bb64904078c07c588f129456583457.zip |
Improve JMI handling (type=chat, filter message sender)
Diffstat (limited to 'xmpp-vala/src/module/xep')
-rw-r--r-- | xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala b/xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala index e26be515..71e16a95 100644 --- a/xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala +++ b/xmpp-vala/src/module/xep/0353_jingle_message_initiation.vala @@ -17,47 +17,35 @@ namespace Xmpp.Xep.JingleMessageInitiation { propose_node.put_node(desc_node); } - MessageStanza accepted_message = new MessageStanza() { to=to }; + MessageStanza accepted_message = new MessageStanza() { to=to, type_=MessageStanza.TYPE_CHAT }; accepted_message.stanza.put_node(propose_node); stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message); } public void send_session_retract_to_peer(XmppStream stream, Jid to, string sid) { - MessageStanza retract_message = new MessageStanza() { to=to }; - retract_message.stanza.put_node( - new StanzaNode.build("retract", NS_URI).add_self_xmlns() - .put_attribute("id", sid, NS_URI)); - stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, retract_message); + send_jmi_message(stream, "retract", to, sid); } public void send_session_accept_to_self(XmppStream stream, string sid) { - MessageStanza accepted_message = new MessageStanza() { to=Bind.Flag.get_my_jid(stream).bare_jid }; - accepted_message.stanza.put_node( - new StanzaNode.build("accept", NS_URI).add_self_xmlns() - .put_attribute("id", sid, NS_URI)); - stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message); + send_jmi_message(stream, "accept", Bind.Flag.get_my_jid(stream).bare_jid, sid); } public void send_session_reject_to_self(XmppStream stream, string sid) { - MessageStanza accepted_message = new MessageStanza() { to=Bind.Flag.get_my_jid(stream).bare_jid }; - accepted_message.stanza.put_node( - new StanzaNode.build("reject", NS_URI).add_self_xmlns() - .put_attribute("id", sid, NS_URI)); - stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message); + send_jmi_message(stream, "reject", Bind.Flag.get_my_jid(stream).bare_jid, sid); } public void send_session_proceed_to_peer(XmppStream stream, Jid to, string sid) { - MessageStanza accepted_message = new MessageStanza() { to=to }; - accepted_message.stanza.put_node( - new StanzaNode.build("proceed", NS_URI).add_self_xmlns() - .put_attribute("id", sid, NS_URI)); - stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message); + send_jmi_message(stream, "proceed", to, sid); } public void send_session_reject_to_peer(XmppStream stream, Jid to, string sid) { - MessageStanza accepted_message = new MessageStanza() { to=to }; + send_jmi_message(stream, "reject", to, sid); + } + + private void send_jmi_message(XmppStream stream, string name, Jid to, string sid) { + MessageStanza accepted_message = new MessageStanza() { to=to, type_=MessageStanza.TYPE_CHAT }; accepted_message.stanza.put_node( - new StanzaNode.build("reject", NS_URI).add_self_xmlns() + new StanzaNode.build(name, NS_URI).add_self_xmlns() .put_attribute("id", sid, NS_URI)); stream.get_module(MessageModule.IDENTITY).send_message.begin(stream, accepted_message); } @@ -95,7 +83,6 @@ namespace Xmpp.Xep.JingleMessageInitiation { session_retracted(message.from, message.to, mi_node.get_attribute("id")); break; case "reject": - if (!message.from.equals_bare(Bind.Flag.get_my_jid(stream))) return; session_rejected(message.from, message.to, mi_node.get_attribute("id")); break; } |