mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 18:25:10 +00:00
[FIX] Properly handle new contents with Matrix
No more ugly asterisks. It annoyed me enough.
This commit is contained in:
parent
5ddc5d3e5c
commit
86deab29af
2 changed files with 36 additions and 3 deletions
|
|
@ -370,6 +370,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
|
|||
DbRef *ref = NULL;
|
||||
HashMap *json;
|
||||
|
||||
char *unedited_id = MatrixGetEdit(event);
|
||||
char *body = GrabString(event, 2, "content", "body");
|
||||
char *id = GrabString(event, 1, "room_id");
|
||||
char *ev_id = GrabString(event, 1, "event_id");
|
||||
|
|
@ -381,12 +382,17 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
|
|||
char *unauth = NULL;
|
||||
char *origin_id = NULL, *stanza = NULL;
|
||||
char *sender = NULL;
|
||||
char *unedited_id = MatrixGetEdit(event);
|
||||
char *url = GrabString(event, 2, "content", "url");
|
||||
char *encoded_from = NULL;
|
||||
|
||||
bool direct = false;
|
||||
|
||||
if (unedited_id)
|
||||
{
|
||||
char *new_content = GrabString(event, 3, "content", "m.new_content", "body");
|
||||
if (new_content) body = new_content;
|
||||
}
|
||||
|
||||
if (ParseeIsPuppet(data->config, m_sender) ||
|
||||
ParseeManageBan(data, m_sender, id))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -207,6 +207,32 @@ XMPPifyElement(HashMap *event, XMLElement *elem, XMPPFlags flags)
|
|||
}
|
||||
return xepd;
|
||||
}
|
||||
static char *
|
||||
GetRawBody(HashMap *event)
|
||||
{
|
||||
if (MatrixGetEdit(event))
|
||||
{
|
||||
char *new = GrabString(event, 3, "content", "m.new_content", "body");
|
||||
if (new)
|
||||
{
|
||||
return new;
|
||||
}
|
||||
}
|
||||
return GrabString(event, 2, "content", "body");
|
||||
}
|
||||
static char *
|
||||
GetHTMLBody(HashMap *event)
|
||||
{
|
||||
if (MatrixGetEdit(event))
|
||||
{
|
||||
char *new = GrabString(event, 3, "content", "m.new_content", "formatted_body");
|
||||
if (new)
|
||||
{
|
||||
return new;
|
||||
}
|
||||
}
|
||||
return GrabString(event, 2, "content", "formatted_body");
|
||||
}
|
||||
char *
|
||||
ParseeXMPPify(HashMap *event)
|
||||
{
|
||||
|
|
@ -231,11 +257,12 @@ ParseeXMPPify(HashMap *event)
|
|||
if (!StrEquals(format, "org.matrix.custom.html"))
|
||||
{
|
||||
/* Settle for the raw body instead. */
|
||||
char *body = JsonValueAsString(JsonGet(event, 2, "content", "body"));
|
||||
char *body = GetRawBody(event);
|
||||
return StrDuplicate(body);
|
||||
}
|
||||
|
||||
html = JsonValueAsString(JsonGet(event, 2, "content", "formatted_body"));
|
||||
html = GetHTMLBody(event);
|
||||
|
||||
html = StrConcat(3, "<html>", html, "</html>");
|
||||
elem = XMLCDecode(StrStreamReader(html), true, true);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue