[FIX/ADD] Fix YAML generation, keep track of time

This commit is contained in:
LDA 2024-10-11 16:09:21 +02:00
commit 13a9d23fa0
12 changed files with 33 additions and 10 deletions

View file

@ -72,8 +72,7 @@ Currently, the main sources of documentation are the Ayadocs(for headers) and th
## TODOS before 1.0 rolls around ## TODOS before 1.0 rolls around
- Make Parsee actually go *vroooooooooommmmmmm*. - Make Parsee actually go *vroooooooooommmmmmm*.
- PROPER FUCKING VCARD AVATARS - Avoid making 'back-puppets' from Matrix as much as possible
XMPP->Matrix is decent, Matrix->XMPP is effectively a WIP
- Add [libomemo](https://github.com/gkdr/libomemo) or something as an optional dependency. - Add [libomemo](https://github.com/gkdr/libomemo) or something as an optional dependency.
- It depends on more stuff anyways, and I don't want to weigh down the - It depends on more stuff anyways, and I don't want to weigh down the
dependency list of Parsee for that. dependency list of Parsee for that.

View file

@ -63,7 +63,7 @@ CommandHead(CmdPlumb, cmd, argp)
if (chat_id) if (chat_id)
{ {
char *rev = StrConcat(2, muc, "/parsee"); char *rev = StrConcat(2, muc, "/parsee");
XMPPJoinMUC(args->data->jabber, "parsee", rev, NULL, false); XMPPJoinMUC(args->data->jabber, "parsee", rev, NULL, -1, false);
Free(rev); Free(rev);
} }

View file

@ -106,6 +106,8 @@ Main(Array *args, HashMap *env)
/* Write out the config file to a YAML document */ /* Write out the config file to a YAML document */
Log(LOG_INFO, "Generating YAML..."); Log(LOG_INFO, "Generating YAML...");
yaml = StreamOpen("parsee.yaml", "w"); yaml = StreamOpen("parsee.yaml", "w");
ParseeConfigLoad(configuration);
ParseeConfigInit();
ParseeExportConfigYAML(yaml); ParseeExportConfigYAML(yaml);
StreamClose(yaml); StreamClose(yaml);
Free(opts); Free(opts);

View file

@ -34,7 +34,7 @@ JoinMUC(ParseeData *data, HashMap *event, char *jid, char *muc, char *name, char
UnistrFree(filtered); UnistrFree(filtered);
/* TODO: vCards! */ /* TODO: vCards! */
while (!XMPPJoinMUC(data->jabber, jid, rev, hash, 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);

View file

@ -77,6 +77,7 @@ ParseeSetThreads(int xmpp, int http)
{ {
if (!config) if (!config)
{ {
Achievement("THREAD COUNT REQUEST WITHOUT CONFIG", true);
return; return;
} }
config->http_threads = http; config->http_threads = http;
@ -88,6 +89,7 @@ ParseeExportConfigYAML(Stream *stream)
{ {
if (!stream || !config) if (!stream || !config)
{ {
Achievement("YAML EXPORT REQUEST WITHOUT CONFIG", true);
return; return;
} }
StreamPrintf(stream, "# Autogenerated YAML AS entry for %s\n", NAME); StreamPrintf(stream, "# Autogenerated YAML AS entry for %s\n", NAME);
@ -109,6 +111,7 @@ ParseeExportConfigYAML(Stream *stream)
StreamPrintf(stream, " aliases:\n"); StreamPrintf(stream, " aliases:\n");
StreamPrintf(stream, " - exclusive: true\n"); StreamPrintf(stream, " - exclusive: true\n");
StreamPrintf(stream, " regex: \"#%s_.*\"\n", config->namespace_base); StreamPrintf(stream, " regex: \"#%s_.*\"\n", config->namespace_base);
StreamFlush(stream);
} }
void void

View file

@ -337,6 +337,15 @@ ParseePushStanza(ParseeData *data, char *chat_id, char *stanza_id, char *id, cha
} }
/* TODO */ /* TODO */
{
ref = DbLock(data->db, 2, "chats", chat_id);
j = DbJson(ref);
if (j)
{
JsonValueFree(HashMapSet(j, "ts", JsonValueInteger(age)));
}
DbUnlock(data->db, ref);
}
{ {
ref = DbCreate(data->db, 4, "chats", chat_id, "stanzas", stanza_id); ref = DbCreate(data->db, 4, "chats", chat_id, "stanzas", stanza_id);
j = DbJson(ref); j = DbJson(ref);

View file

@ -552,10 +552,16 @@ ParseeSendPresence(ParseeData *data)
while (HashMapIterate(mucs, &muc, (void **) &val)) while (HashMapIterate(mucs, &muc, (void **) &val))
{ {
char *rev = StrConcat(2, muc, "/parsee"); char *rev = StrConcat(2, muc, "/parsee");
char *chat_id = ParseeGetFromMUCID(data, muc);
DbRef *chat = DbLockIntent(data->db, DB_HINT_READONLY, 2, "chats", chat_id);
uint64_t ts = GrabInteger(DbJson(chat), 1, "ts");
int diff = ts ? (UtilTsMillis() - ts) / 1000 : -1;
/* Make a fake user join the MUC */ /* Make a fake user join the MUC */
Log(LOG_NOTICE, "Sending presence to %s", rev); Log(LOG_NOTICE, "Sending presence to %s last=%ds", rev, diff);
XMPPJoinMUC(data->jabber, "parsee", rev, NULL, false); XMPPJoinMUC(data->jabber, "parsee", rev, NULL, diff, false);
DbUnlock(data->db, chat);
Free(chat_id);
Free(rev); Free(rev);
} }
DbUnlock(data->db, ref); DbUnlock(data->db, ref);

View file

@ -173,7 +173,7 @@ RouteHead(RouteRoot, arr, argp)
P("<p>"); P("<p>");
{ {
P("More information available at "); P("More information available at ");
P("<a"); P("<a ");
P("href='https://kappach.at/parsee'"); P("href='https://kappach.at/parsee'");
P(">the actual page</a>."); P(">the actual page</a>.");
} }

View file

@ -131,7 +131,7 @@ RouteHead(RouteRoomAck, arr, argp)
{ {
char *rev = StrConcat(2, muc, "/parsee"); char *rev = StrConcat(2, muc, "/parsee");
Log(LOG_NOTICE, "Sending presence to %s", rev); Log(LOG_NOTICE, "Sending presence to %s", rev);
XMPPJoinMUC(args->data->jabber, "parsee", rev, NULL, false); XMPPJoinMUC(args->data->jabber, "parsee", rev, NULL, -1, false);
Free(rev); Free(rev);
} }

View file

@ -25,6 +25,7 @@ SignalHandler(int signal)
if (signal == SIGPIPE) if (signal == SIGPIPE)
{ {
Log(LOG_DEBUG, "Caught a SIGPIPE..."); Log(LOG_DEBUG, "Caught a SIGPIPE...");
return;
} }
} }

View file

@ -134,6 +134,7 @@ ParseeXMPPThread(void *argp)
ParseeData *args = argp; ParseeData *args = argp;
XMPPComponent *jabber = args->jabber; XMPPComponent *jabber = args->jabber;
XMLElement *stanza = NULL; XMLElement *stanza = NULL;
HashMap *await_table2;
size_t i; size_t i;
/* Initialise the await table */ /* Initialise the await table */
@ -268,7 +269,9 @@ ParseeXMPPThread(void *argp)
} }
ArrayFree(info.stanzas); ArrayFree(info.stanzas);
HashMapFree(await_table); await_table2 = await_table;
await_table = NULL;
HashMapFree(await_table2);
pthread_mutex_destroy(&info.lock); pthread_mutex_destroy(&info.lock);

View file

@ -30,7 +30,7 @@ extern XMPPComponent * XMPPInitialiseCompStream(char *host, int port);
extern bool XMPPAuthenticateCompStream(XMPPComponent *comp, char *shared); extern bool XMPPAuthenticateCompStream(XMPPComponent *comp, char *shared);
/* Makes a user join/leave a MUC */ /* Makes a user join/leave a MUC */
extern bool XMPPJoinMUC(XMPPComponent *comp, char *fr, char *muc, char *hash, bool ret); extern bool XMPPJoinMUC(XMPPComponent *comp, char *fr, char *muc, char *hash, int secs, bool ret);
extern void XMPPLeaveMUC(XMPPComponent *comp, char *fr, char *muc, char *r); extern void XMPPLeaveMUC(XMPPComponent *comp, char *fr, char *muc, char *r);
/* TODO: XMPP stuff, I don't fucking know, I'm not a Jabbernerd. */ /* TODO: XMPP stuff, I don't fucking know, I'm not a Jabbernerd. */