mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:05:10 +00:00
[ADD/WIP] Bridging Matrix redacts
I'll still need to consider making redacts from other people count as "moderations", whatever that is to Gajim, instead of a "self-redact". Also, _please_, support it if you _ever_ wish adoption, XMPP users!
This commit is contained in:
parent
71bef54634
commit
3c26ee6d22
5 changed files with 174 additions and 2 deletions
|
|
@ -15,6 +15,74 @@ XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type, ch
|
|||
Free(ident);
|
||||
}
|
||||
|
||||
void
|
||||
XMPPRetract(XMPPComponent *comp, char *fr, char *to, char *type, char *redact)
|
||||
{
|
||||
XMLElement *message;
|
||||
char *ident = StrRandom(32), *from;
|
||||
if (!comp || !fr || !to || !type || !redact)
|
||||
{
|
||||
Free(ident);
|
||||
return;
|
||||
}
|
||||
|
||||
message = XMLCreateTag("message");
|
||||
XMLAddAttr(message, "from", (from = StrConcat(3, fr, "@", comp->host)));
|
||||
XMLAddAttr(message, "to", to);
|
||||
XMLAddAttr(message, "type", type);
|
||||
XMLAddAttr(message, "id", ident);
|
||||
|
||||
{
|
||||
XMLElement *apply_to, *retract, *body, *txt, *fallback;
|
||||
|
||||
apply_to = XMLCreateTag("apply-to");
|
||||
XMLAddAttr(apply_to, "xmlns", "urn:xmpp:fasten:0");
|
||||
XMLAddAttr(apply_to, "id", redact);
|
||||
{
|
||||
retract = XMLCreateTag("retract");
|
||||
XMLAddAttr(retract, "xmlns", "urn:xmpp:message-retract:0");
|
||||
XMLAddChild(apply_to, retract);
|
||||
}
|
||||
XMLAddChild(message, apply_to);
|
||||
|
||||
retract = XMLCreateTag("retract");
|
||||
XMLAddAttr(retract, "xmlns", "urn:xmpp:message-retract:1");
|
||||
XMLAddAttr(retract, "id", redact);
|
||||
XMLAddChild(message, retract);
|
||||
|
||||
fallback = XMLCreateTag("fallback");
|
||||
XMLAddAttr(fallback, "xmlns", "urn:xmpp:fallback:0");
|
||||
XMLAddAttr(fallback, "for", "urn:xmpp:message-retract:0");
|
||||
XMLAddChild(message, fallback);
|
||||
|
||||
fallback = XMLCreateTag("fallback");
|
||||
XMLAddAttr(fallback, "xmlns", "urn:xmpp:fallback:0");
|
||||
XMLAddAttr(fallback, "for", "urn:xmpp:message-retract:1");
|
||||
XMLAddChild(message, fallback);
|
||||
|
||||
body = XMLCreateTag("body");
|
||||
txt = XMLCreateText(
|
||||
"This person attempted to retract a previous message, "
|
||||
"but your client does not yet support the 0.4.1 version of "
|
||||
"XEP-0424.\n\n"
|
||||
|
||||
"(_Parsee is jealous of being able to read such messages._)"
|
||||
);
|
||||
XMLAddChild(body, txt);
|
||||
XMLAddChild(message, body);
|
||||
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&comp->write_lock);
|
||||
XMLEncode(comp->stream, message);
|
||||
StreamFlush(comp->stream);
|
||||
XMLFreeElement(message);
|
||||
|
||||
pthread_mutex_unlock(&comp->write_lock);
|
||||
|
||||
Free(from);
|
||||
Free(ident);
|
||||
}
|
||||
void
|
||||
XMPPSendPlainID(XMPPComponent *comp, char *fr, char *to, char *msg, char *type, char *rst, char *rse, char *event_id, char *oob, char *edit, char *ident)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue