mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 00:45:10 +00:00
[ADD/WIP] Editing support XMPP->Matrix
This commit is contained in:
parent
771c3271ad
commit
ae740878c8
13 changed files with 249 additions and 106 deletions
|
|
@ -40,7 +40,6 @@ MessageStanza(ParseeData *args, XMLElement *stanza)
|
|||
|
||||
XMLElement *body = NULL;
|
||||
XMLElement *data = NULL;
|
||||
XMLElement *stanza_id = NULL;
|
||||
|
||||
char *to, *room, *from, *from_matrix;
|
||||
char *chat_id, *mroom_id;
|
||||
|
|
@ -51,7 +50,6 @@ MessageStanza(ParseeData *args, XMLElement *stanza)
|
|||
XMLFreeElement(stanza);
|
||||
return false;
|
||||
}
|
||||
stanza_id = XMLookForUnique(stanza, "stanza-id");
|
||||
|
||||
to = ParseeDecodeMXID(HashMapGet(stanza->attrs, "to"));
|
||||
from = HashMapGet(stanza->attrs, "from");
|
||||
|
|
@ -69,12 +67,15 @@ MessageStanza(ParseeData *args, XMLElement *stanza)
|
|||
if (mroom_id && !XMPPIsParseeStanza(stanza))
|
||||
{
|
||||
char *res = ParseeGetResource(from);
|
||||
char *encoded = ParseeEncodeJID(args->config, from, false);
|
||||
char *s_id_str = HashMapGet(stanza_id->attrs, "id");
|
||||
char *encoded = ParseeEncodeJID(args->config, from, false);
|
||||
char *s_id_str = XMPPGetStanzaID(stanza);
|
||||
char *o_id_str = XMPPGetOriginID(stanza);
|
||||
char *id_str = HashMapGet(stanza->attrs, "id");
|
||||
char *event_id;
|
||||
char *replaced = XMPPGetReplacedID(stanza);
|
||||
|
||||
/* TODO: Create smarter puppet names */
|
||||
if (ParseeVerifyStanza(args, chat_id, s_id_str))
|
||||
if (ParseeVerifyStanza(args, chat_id, s_id_str) && !replaced)
|
||||
{
|
||||
XMLElement *oob, *oob_data;
|
||||
|
||||
|
|
@ -108,7 +109,18 @@ MessageStanza(ParseeData *args, XMLElement *stanza)
|
|||
"m.room.message", MatrixCreateMessage(data->data)
|
||||
);
|
||||
}
|
||||
ParseePushStanza(args, chat_id, s_id_str, event_id, from);
|
||||
ParseePushStanza(args, chat_id, s_id_str, id_str, event_id, from);
|
||||
Free(event_id);
|
||||
}
|
||||
else if (replaced)
|
||||
{
|
||||
event_id = ParseeEventFromID(args, chat_id, replaced);
|
||||
Log(LOG_WARNING, "RETRACTION REQUEST TO %s->%s", replaced, event_id);
|
||||
Free(ASSend(
|
||||
args->config, mroom_id, encoded,
|
||||
"m.room.message", MatrixCreateReplace(event_id, data->data)
|
||||
));
|
||||
|
||||
Free(event_id);
|
||||
}
|
||||
|
||||
|
|
@ -154,8 +166,10 @@ IQDiscoGet(ParseeData *args, XMPPComponent *jabber, XMLElement *stanza)
|
|||
} \
|
||||
while (0)
|
||||
|
||||
AdvertiseSimple("urn:xmpp:reply:0");
|
||||
AdvertiseSimple("urn:xmpp:message-correct:0");
|
||||
AdvertiseSimple("urn:xmpp:styling:0");
|
||||
AdvertiseSimple("urn:xmpp:reply:0");
|
||||
AdvertiseSimple("urn:xmpp:sid:0");
|
||||
|
||||
AdvertiseSimple("urn:parsee:x-parsee:0");
|
||||
AdvertiseSimple("urn:parsee:jealousy:0");
|
||||
|
|
@ -234,6 +248,7 @@ ParseeXMPPThread(void *argp)
|
|||
from = HashMapGet(stanza->attrs, "from");
|
||||
if (!strncmp(from, killer, strlen(killer)))
|
||||
{
|
||||
Log(LOG_INFO, "Killer detected.");
|
||||
XMLFreeElement(stanza);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue