[ADD] Push pupmet events too.

This commit is contained in:
LDA 2024-06-27 04:02:26 +02:00
commit 82bed09b03
4 changed files with 25 additions and 5 deletions

View file

@ -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);

View file

@ -8,7 +8,7 @@
#include <XML.h>
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 */
}

View file

@ -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);

View file

@ -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);