mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 16:55:10 +00:00
[FIX] Ignore unavailable statuses
They aren't that useful, especially in MUCs.
This commit is contained in:
parent
0facbaa5e5
commit
389870c5d3
9 changed files with 108 additions and 9 deletions
BIN
etc/man/man7/.parsee-bridge-guidebook.7.swp
Normal file
BIN
etc/man/man7/.parsee-bridge-guidebook.7.swp
Normal file
Binary file not shown.
BIN
etc/man/man7/.parsee-cmd-syntax.7.swp
Normal file
BIN
etc/man/man7/.parsee-cmd-syntax.7.swp
Normal file
Binary file not shown.
70
etc/man/man7/parsee-bridge-guidebook.7
Normal file
70
etc/man/man7/parsee-bridge-guidebook.7
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
." The last field is the codename, by the way.
|
||||||
|
." ALL MANPAGES FOR PARSEE ARE UNDER PUBLIC DOMAIN
|
||||||
|
.TH parsee-bridge-guidebook 7 "Parsee Utility" "star-of-hope"
|
||||||
|
|
||||||
|
.SH NAME
|
||||||
|
parsee-bridge-guidebook - A short guidebook on running a Parsee bridge
|
||||||
|
|
||||||
|
.SH INTRODUCTION
|
||||||
|
.P
|
||||||
|
This manpage is intended to be a guidebook for Parsee administrators. It
|
||||||
|
is meant to show how to create an instance with an XMPP-Matrix server
|
||||||
|
(though it cannot be specific, due to their ecosystem diversity), how to
|
||||||
|
plumb rooms, and moderate them through.
|
||||||
|
.P
|
||||||
|
It also assumes Parsee is properly built and installed, in which case you
|
||||||
|
are seeing this from
|
||||||
|
.I man
|
||||||
|
itself.
|
||||||
|
|
||||||
|
.SH CONVENTIONS
|
||||||
|
This page shall assume a few things that
|
||||||
|
.B must
|
||||||
|
be changed to fit your configuration. Please read those carefully, or it
|
||||||
|
will come and bite at you!
|
||||||
|
|
||||||
|
.P
|
||||||
|
First off, it assumes that you have a domain at
|
||||||
|
.I blow.hole
|
||||||
|
and that any other domains related to Parsee are it's subdomains, as
|
||||||
|
you'll see.
|
||||||
|
|
||||||
|
.P
|
||||||
|
We also assume you're planning on making the XMPP component available at
|
||||||
|
.I j.blow.hole ,
|
||||||
|
and that Parsee can reach it by using
|
||||||
|
.I localhost:1234 .
|
||||||
|
It is highly recommended that Parsee can reach the component locally, as
|
||||||
|
the stream cannot be encrypted!
|
||||||
|
|
||||||
|
.P
|
||||||
|
The Parsee HTTP server (which is used for media and the appservice) shall
|
||||||
|
be reached through
|
||||||
|
.I https://p.blow.hole/
|
||||||
|
via a reverse proxy. This manual shall only show you what port to make
|
||||||
|
available, as there are many reverse proxy options available.
|
||||||
|
|
||||||
|
.P
|
||||||
|
Finally, the Matrix server will be publicly known as
|
||||||
|
.I m.blow.hole
|
||||||
|
.
|
||||||
|
|
||||||
|
That is, if
|
||||||
|
.B bob
|
||||||
|
is in it, then they shall be known as
|
||||||
|
.I @bob:m.blow.hole .
|
||||||
|
|
||||||
|
.SH SETTING UP
|
||||||
|
Setting up Parsee mainly involves creating a valid configuration file
|
||||||
|
and the database. Most of this however is dealt with by
|
||||||
|
.I parsee-config(1)
|
||||||
|
TODO
|
||||||
|
|
||||||
|
.P
|
||||||
|
|
||||||
|
.SH LICENSE
|
||||||
|
This document is under public domain, or CC0 if not allowed by local law.
|
||||||
|
|
||||||
|
.SH SEE ALSO
|
||||||
|
.B parsee(1), parsee-cmd-syntax(7)
|
||||||
|
|
||||||
|
|
@ -30,13 +30,16 @@ JoinMUC(ParseeData *data, HashMap *event, char *jid, char *muc, char *name, char
|
||||||
|
|
||||||
UnistrFree(uninick);
|
UnistrFree(uninick);
|
||||||
UnistrFree(filtered);
|
UnistrFree(filtered);
|
||||||
|
UnistrFree(filterASCII);
|
||||||
|
|
||||||
/* TODO: vCards! */
|
/* TODO: Make sure that we fall back to plain ASCII if it fails too many
|
||||||
|
* times. */
|
||||||
while (!XMPPJoinMUC(data->jabber, jid, rev, hash, -1, true) && nonce < 32)
|
while (!XMPPJoinMUC(data->jabber, jid, rev, hash, -1, true) && nonce < 32)
|
||||||
{
|
{
|
||||||
char *nonce_str = StrInt(nonce);
|
char *nonce_str = StrInt(nonce);
|
||||||
char *input = StrConcat(3, sender, name, nonce_str);
|
char *input = StrConcat(3, sender, name, nonce_str);
|
||||||
char *hex = ParseeHMACS(data->id, input);
|
char *hex = ParseeHMACS(data->id, input);
|
||||||
|
Unistr *filterASCII = UnistrFilter(uninick, UnistrIsASCII);
|
||||||
|
|
||||||
if (strlen(hex) >= 8)
|
if (strlen(hex) >= 8)
|
||||||
{
|
{
|
||||||
|
|
@ -45,6 +48,7 @@ JoinMUC(ParseeData *data, HashMap *event, char *jid, char *muc, char *name, char
|
||||||
|
|
||||||
Free(nick);
|
Free(nick);
|
||||||
Free(rev);
|
Free(rev);
|
||||||
|
Free(revscii);
|
||||||
|
|
||||||
nick = StrConcat(4, name, "[", hex, "]");
|
nick = StrConcat(4, name, "[", hex, "]");
|
||||||
rev = StrConcat(3, muc, "/", nick);
|
rev = StrConcat(3, muc, "/", nick);
|
||||||
|
|
@ -365,12 +369,12 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
|
||||||
DbRef *ref = NULL;
|
DbRef *ref = NULL;
|
||||||
HashMap *json = NULL;
|
HashMap *json = NULL;
|
||||||
|
|
||||||
char *unedited_id = MatrixGetEdit(event);
|
char *m_sender = GrabString(event, 1, "sender");
|
||||||
|
char *unedited_id = NULL;
|
||||||
char *body = GrabString(event, 2, "content", "body");
|
char *body = GrabString(event, 2, "content", "body");
|
||||||
char *id = GrabString(event, 1, "room_id");
|
char *id = GrabString(event, 1, "room_id");
|
||||||
char *ev_id = GrabString(event, 1, "event_id");
|
char *ev_id = GrabString(event, 1, "event_id");
|
||||||
char *m_sender = GrabString(event, 1, "sender");
|
char *chat_id = NULL, *muc_id = NULL;
|
||||||
char *chat_id, *muc_id;
|
|
||||||
char *reply_id = MatrixGetReply(event);
|
char *reply_id = MatrixGetReply(event);
|
||||||
char *xepd = ParseeXMPPify(event);
|
char *xepd = ParseeXMPPify(event);
|
||||||
char *type, *user, *xmppified_user = NULL, *to = NULL;
|
char *type, *user, *xmppified_user = NULL, *to = NULL;
|
||||||
|
|
@ -381,6 +385,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
|
||||||
char *encoded_from = NULL;
|
char *encoded_from = NULL;
|
||||||
|
|
||||||
bool direct = false;
|
bool direct = false;
|
||||||
|
unedited_id = MatrixGetEdit(event);
|
||||||
|
|
||||||
if (unedited_id)
|
if (unedited_id)
|
||||||
{
|
{
|
||||||
|
|
@ -455,6 +460,7 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
|
||||||
Free(name);
|
Free(name);
|
||||||
Free(avatar);
|
Free(avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply_id)
|
if (reply_id)
|
||||||
{
|
{
|
||||||
/* TODO: Monocles chat DM users HATE this trick!
|
/* TODO: Monocles chat DM users HATE this trick!
|
||||||
|
|
@ -511,8 +517,8 @@ end:
|
||||||
Free(stanza);
|
Free(stanza);
|
||||||
Free(sender);
|
Free(sender);
|
||||||
Free(unauth);
|
Free(unauth);
|
||||||
Free(unedited_id);
|
|
||||||
Free(encoded_from);
|
Free(encoded_from);
|
||||||
|
Free(unedited_id);
|
||||||
|
|
||||||
DbUnlock(data->db, ref);
|
DbUnlock(data->db, ref);
|
||||||
ref = NULL;
|
ref = NULL;
|
||||||
|
|
|
||||||
|
|
@ -210,9 +210,11 @@ XMPPifyElement(HashMap *event, XMLElement *elem, XMPPFlags flags)
|
||||||
static char *
|
static char *
|
||||||
GetRawBody(HashMap *event)
|
GetRawBody(HashMap *event)
|
||||||
{
|
{
|
||||||
if (MatrixGetEdit(event))
|
void *id;
|
||||||
|
if ((id = MatrixGetEdit(event)))
|
||||||
{
|
{
|
||||||
char *new = GrabString(event, 3, "content", "m.new_content", "body");
|
char *new = GrabString(event, 3, "content", "m.new_content", "body");
|
||||||
|
Free(id);
|
||||||
if (new)
|
if (new)
|
||||||
{
|
{
|
||||||
return new;
|
return new;
|
||||||
|
|
|
||||||
10
src/Unistr.c
10
src/Unistr.c
|
|
@ -192,6 +192,16 @@ UnistrGetch(Unistr *unistr, size_t i)
|
||||||
return i < unistr->length ? unistr->codepoints[i] : 0;
|
return i < unistr->length ? unistr->codepoints[i] : 0;
|
||||||
}
|
}
|
||||||
bool
|
bool
|
||||||
|
UnistrIsASCII(uint32_t u)
|
||||||
|
{
|
||||||
|
if (u == 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return u < 0x7F;
|
||||||
|
}
|
||||||
|
bool
|
||||||
UnistrIsBMP(uint32_t u)
|
UnistrIsBMP(uint32_t u)
|
||||||
{
|
{
|
||||||
if (u == 0)
|
if (u == 0)
|
||||||
|
|
|
||||||
|
|
@ -572,7 +572,7 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
||||||
else if (XMLookForTKV(stanza, "query", "xmlns", "jabber:iq:version"))
|
else if (XMLookForTKV(stanza, "query", "xmlns", "jabber:iq:version"))
|
||||||
{
|
{
|
||||||
XMLElement *iq_reply, *query;
|
XMLElement *iq_reply, *query;
|
||||||
XMLElement *name, *version;
|
XMLElement *name, *version, *os;
|
||||||
|
|
||||||
iq_reply = XMLCreateTag("iq");
|
iq_reply = XMLCreateTag("iq");
|
||||||
XMLAddAttr(iq_reply, "to", from);
|
XMLAddAttr(iq_reply, "to", from);
|
||||||
|
|
@ -585,12 +585,15 @@ IQGet(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
||||||
{
|
{
|
||||||
name = XMLCreateTag("name");
|
name = XMLCreateTag("name");
|
||||||
version = XMLCreateTag("version");
|
version = XMLCreateTag("version");
|
||||||
|
os = XMLCreateTag("os");
|
||||||
|
|
||||||
XMLAddChild(name, XMLCreateText(NAME));
|
XMLAddChild(name, XMLCreateText(NAME));
|
||||||
XMLAddChild(version, XMLCreateText(VERSION "[" CODE "]"));
|
XMLAddChild(version, XMLCreateText(VERSION "[" CODE "]"));
|
||||||
|
XMLAddChild(os, XMLCreateText(VERSION "POSIX-like"));
|
||||||
}
|
}
|
||||||
XMLAddChild(query, name);
|
XMLAddChild(query, name);
|
||||||
XMLAddChild(query, version);
|
XMLAddChild(query, version);
|
||||||
|
XMLAddChild(query, os);
|
||||||
XMLAddChild(iq_reply, query);
|
XMLAddChild(iq_reply, query);
|
||||||
|
|
||||||
XMPPSendStanza(jabber, iq_reply, args->config->max_stanza_size);
|
XMPPSendStanza(jabber, iq_reply, args->config->max_stanza_size);
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,7 @@ end_item:
|
||||||
Free(room);
|
Free(room);
|
||||||
FreeStatuses(statuses);
|
FreeStatuses(statuses);
|
||||||
}
|
}
|
||||||
if (status)
|
if (status && !StrEquals(type, "unavailable"))
|
||||||
{
|
{
|
||||||
XMLElement *status_data = ArrayGet(status->children, 0);
|
XMLElement *status_data = ArrayGet(status->children, 0);
|
||||||
char *decode_from = ParseeLookupJID(oid);
|
char *decode_from = ParseeLookupJID(oid);
|
||||||
|
|
@ -309,6 +309,8 @@ end_item:
|
||||||
status_str = status_data->data;
|
status_str = status_data->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* TODO: "The server will automatically set a user's presence to
|
/* TODO: "The server will automatically set a user's presence to
|
||||||
* unavailable if their last active time was over a threshold value
|
* unavailable if their last active time was over a threshold value
|
||||||
* (e.g. 5 minutes)."
|
* (e.g. 5 minutes)."
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,12 @@ extern void UnistrFree(Unistr *unistr);
|
||||||
* Returns: whenever the character is within the BMP */
|
* Returns: whenever the character is within the BMP */
|
||||||
extern bool UnistrIsBMP(uint32_t u);
|
extern bool UnistrIsBMP(uint32_t u);
|
||||||
|
|
||||||
|
/** Returns true IFF the character is within the 7-bit ASCII range
|
||||||
|
* not 0x0000
|
||||||
|
* ------------------------------------------------------------
|
||||||
|
* Returns: whenever the character is within ASCII */
|
||||||
|
extern bool UnistrIsASCII(uint32_t u);
|
||||||
|
|
||||||
typedef bool (*UnistrFilterFunc)(uint32_t u);
|
typedef bool (*UnistrFilterFunc)(uint32_t u);
|
||||||
/** "Filters" characters in a Unistring by codepoint, removing
|
/** "Filters" characters in a Unistring by codepoint, removing
|
||||||
* those with callbacks which return false into a new unistring.
|
* those with callbacks which return false into a new unistring.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue