mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 02:05:17 +00:00
[ADD/FIX] XMPP->Matrix mod, fix PL issue
This commit is contained in:
parent
3c26ee6d22
commit
e7c44a05e2
7 changed files with 106 additions and 21 deletions
|
|
@ -26,6 +26,10 @@
|
|||
AdvertiseSimple("urn:xmpp:avatar:data+notify") \
|
||||
AdvertiseSimple("urn:xmpp:avatar:metadata") \
|
||||
AdvertiseSimple("urn:xmpp:message-correct:0") \
|
||||
AdvertiseSimple("urn:xmpp:message-moderate:0") \
|
||||
AdvertiseSimple("urn:xmpp:message-moderate:1") \
|
||||
AdvertiseSimple("urn:xmpp:message-retract:0") \
|
||||
AdvertiseSimple("urn:xmpp:message-retract:1") \
|
||||
AdvertiseSimple("urn:xmpp:avatar:data") \
|
||||
AdvertiseSimple("urn:xmpp:chat-markers:0") \
|
||||
AdvertiseSimple("urn:xmpp:reactions:0") \
|
||||
|
|
@ -54,6 +58,12 @@ ParseeJID(ParseeData *data)
|
|||
{
|
||||
return StrConcat(2, "parsee@", data->config->component_host);
|
||||
}
|
||||
static char *
|
||||
ParseeMXID(ParseeData *data)
|
||||
{
|
||||
return StrConcat(4, "@", data->config->sender_localpart,
|
||||
":", data->config->homeserver_host);
|
||||
}
|
||||
|
||||
static int
|
||||
ICollate(unsigned char *cata, unsigned char *catb)
|
||||
|
|
@ -401,6 +411,10 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
|
||||
char *to, *room, *from, *from_matrix, *decode_from;
|
||||
char *mroom_id = NULL;
|
||||
char *replaced = XMPPGetReplacedID(stanza);
|
||||
char *retracted = XMPPGetRetractedID(stanza);
|
||||
char *reply_to = XMPPGetReply(stanza);
|
||||
char *moderated = XMPPGetModeration(stanza);
|
||||
size_t i;
|
||||
|
||||
to = NULL;
|
||||
|
|
@ -415,6 +429,30 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (moderated)
|
||||
{
|
||||
/* TODO: Parsee MUST check if it is a valid MUC */
|
||||
char *resource = ParseeGetResource(from);
|
||||
char *chat_id = ParseeGetFromMUCID(args, from);
|
||||
char *event_id = NULL;
|
||||
char *encoded = ParseeMXID(args);
|
||||
mroom_id = ParseeGetBridgedRoom(args, stanza);
|
||||
if (!resource && chat_id)
|
||||
{
|
||||
event_id = ParseeGetEventFromID(args, stanza, moderated);
|
||||
ASRedact(args->config, mroom_id, encoded, event_id);
|
||||
ParseePushAllStanza(args, stanza, event_id);
|
||||
pthread_mutex_unlock(&thr->info->chk_lock);
|
||||
|
||||
Free(event_id);
|
||||
}
|
||||
Free(mroom_id);
|
||||
Free(resource);
|
||||
Free(encoded);
|
||||
Free(chat_id);
|
||||
}
|
||||
body = XMLookForUnique(stanza, "body");
|
||||
|
||||
event = XMLookForTKV(stanza, "event",
|
||||
"xmlns", "http://jabber.org/protocol/pubsub#event"
|
||||
);
|
||||
|
|
@ -497,7 +535,6 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
|
||||
}
|
||||
#undef CHAT_STATES
|
||||
body = XMLookForUnique(stanza, "body");
|
||||
if (!body)
|
||||
{
|
||||
XMLFreeElement(stanza);
|
||||
|
|
@ -534,9 +571,6 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
char *res = ParseeGetResource(from);
|
||||
char *encoded = ParseeEncodeJID(args->config, decode_from, false);
|
||||
char *event_id = NULL;
|
||||
char *replaced = XMPPGetReplacedID(stanza);
|
||||
char *retracted = XMPPGetRetractedID(stanza);
|
||||
char *reply_to = XMPPGetReply(stanza);
|
||||
bool chat = false;
|
||||
|
||||
if (StrEquals(HashMapGet(stanza->attrs, "type"), "chat"))
|
||||
|
|
@ -631,6 +665,7 @@ MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
else if (retracted)
|
||||
{
|
||||
event_id = ParseeGetEventFromID(args, stanza, retracted);
|
||||
Log(LOG_WARNING, "RETRACTING %s %s", retracted, event_id);
|
||||
ASRedact(args->config, mroom_id, encoded, event_id);
|
||||
ParseePushAllStanza(args, stanza, event_id);
|
||||
pthread_mutex_unlock(&thr->info->chk_lock);
|
||||
|
|
@ -1099,8 +1134,17 @@ PresenceStanza(ParseeData *args, XMLElement *stanza)
|
|||
{
|
||||
HashMap *powers = ASGetPL(args->config, room);
|
||||
int64_t level = GrabInteger(powers, 2, "users", from_matrix);
|
||||
char *parsee = ParseeMXID(args);
|
||||
|
||||
if (powers && level != power_level)
|
||||
/* I may or may not have fucked up the state hard with this
|
||||
* lacking any checking. (--gen) */
|
||||
if (StrEquals(parsee, from_matrix))
|
||||
{
|
||||
/* TODO: Give the user an achievement, this is goofy. */
|
||||
Log(LOG_ERR, "BAD PL DOWNGRADE (%d->%d)", level, power_level);
|
||||
}
|
||||
if (powers && level != power_level &&
|
||||
!StrEquals(parsee, from_matrix))
|
||||
{
|
||||
HashMap *users = GrabObject(powers, 1, "users");
|
||||
JsonValue *val = JsonValueInteger(power_level);
|
||||
|
|
@ -1113,6 +1157,7 @@ PresenceStanza(ParseeData *args, XMLElement *stanza)
|
|||
{
|
||||
JsonFree(powers);
|
||||
}
|
||||
Free(parsee);
|
||||
}
|
||||
|
||||
if (StrEquals(type, "unavailable"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue