diff --git a/src/MatrixEventHandler.c b/src/MatrixEventHandler.c index 4c0045f..2e6a118 100644 --- a/src/MatrixEventHandler.c +++ b/src/MatrixEventHandler.c @@ -93,7 +93,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event) char *user = GrabString(json, 1, "xmpp_user"); char *local = ParseeEncodeMXID(sender); - XMPPSendPlain(jabber, local, user, body, NULL, NULL, NULL); + XMPPSendPlain(jabber, local, user, body, NULL, NULL, NULL, ev_id); Free(local); Free(reply_id); @@ -124,7 +124,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event) XMPPSendPlain( jabber, jid, muc_id, xepd ? xepd : body, "groupchat", - stanza, sender + stanza, sender, ev_id ); Free(rev); Free(name); diff --git a/src/XMPP/Stanza.c b/src/XMPP/Stanza.c index 15dcbb1..b47c4e4 100644 --- a/src/XMPP/Stanza.c +++ b/src/XMPP/Stanza.c @@ -8,7 +8,7 @@ #include void -XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type, char *rst, char *rse) +XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type, char *rst, char *rse, char *event_id) { XMLElement *message, *body, *data, *parsee; char *from; @@ -33,6 +33,7 @@ XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type, ch XMLElement *parsee_version, *ver_elem; XMLElement *parsee_link, *link_elem; XMLElement *parsee_text, *text_elem; + XMLElement *parsee_event, *event_elem; parsee_version = XMLCreateTag("version"); ver_elem = XMLCreateText(VERSION); @@ -53,6 +54,14 @@ XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type, ch text_elem = XMLCreateText("LDA will never beat the allegations"); XMLAddChild(parsee_text, text_elem); XMLAddChild(parsee, parsee_text); + + if (event_id) + { + parsee_event = XMLCreateTag("event-id"); + event_elem = XMLCreateText(event_id); + XMLAddChild(parsee_event, event_elem); + XMLAddChild(parsee, parsee_event); + } /* TODO: Add custom fields depending on the caller's wishes */ } diff --git a/src/XMPPThread.c b/src/XMPPThread.c index a747a80..a4ba583 100644 --- a/src/XMPPThread.c +++ b/src/XMPPThread.c @@ -152,6 +152,18 @@ MessageStanza(ParseeData *args, XMLElement *stanza) Free(res); Free(encoded); } + else if (mroom_id) + { + XMLElement *parsee = XMLookForUnique(stanza, "x-parsee"); + XMLElement *event = XMLookForUnique(parsee, "event-id"); + XMLElement *e_d = ArrayGet(event ? event->children : NULL, 0); + char *s_id_str = XMPPGetStanzaID(stanza); + char *id_str = HashMapGet(stanza->attrs, "id"); + if (ParseeVerifyStanza(args, chat_id, s_id_str)) + { + ParseePushStanza(args, chat_id, s_id_str, id_str, e_d->data, from); + } + } Free(chat_id); Free(mroom_id); Free(from_matrix); diff --git a/src/include/XMPP.h b/src/include/XMPP.h index 8020d8b..d23b850 100644 --- a/src/include/XMPP.h +++ b/src/include/XMPP.h @@ -28,8 +28,7 @@ extern bool XMPPAuthenticateCompStream(XMPPComponent *comp, char *shared); extern void XMPPJoinMUC(XMPPComponent *comp, char *fr, char *muc); /* TODO: XMPP stuff, I don't fucking know, I'm not a Jabbernerd. */ -extern void XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type, char *rst, char *rse); -extern void XMPPSendMUC(XMPPComponent *comp, char *fr, char *as, char *to, char *msg, char *type); +extern void XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type, char *rst, char *rse, char *event_id); /* Closes a raw component stream. */ extern void XMPPEndCompStream(XMPPComponent *stream);