diff --git a/README.MD b/README.MD index 2955984..786e905 100644 --- a/README.MD +++ b/README.MD @@ -72,8 +72,7 @@ Currently, the main sources of documentation are the Ayadocs(for headers) and th ## TODOS before 1.0 rolls around - Make Parsee actually go *vroooooooooommmmmmm*. -- PROPER FUCKING VCARD AVATARS - XMPP->Matrix is decent, Matrix->XMPP is effectively a WIP +- Avoid making 'back-puppets' from Matrix as much as possible - 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 dependency list of Parsee for that. diff --git a/src/Commands/Plumb.c b/src/Commands/Plumb.c index 66f8283..f51e4e6 100644 --- a/src/Commands/Plumb.c +++ b/src/Commands/Plumb.c @@ -63,7 +63,7 @@ CommandHead(CmdPlumb, cmd, argp) if (chat_id) { 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); } diff --git a/src/Main.c b/src/Main.c index 7f01258..af2496d 100644 --- a/src/Main.c +++ b/src/Main.c @@ -106,6 +106,8 @@ Main(Array *args, HashMap *env) /* Write out the config file to a YAML document */ Log(LOG_INFO, "Generating YAML..."); yaml = StreamOpen("parsee.yaml", "w"); + ParseeConfigLoad(configuration); + ParseeConfigInit(); ParseeExportConfigYAML(yaml); StreamClose(yaml); Free(opts); diff --git a/src/MatrixEventHandler.c b/src/MatrixEventHandler.c index 8fec7ca..0f84789 100644 --- a/src/MatrixEventHandler.c +++ b/src/MatrixEventHandler.c @@ -34,7 +34,7 @@ JoinMUC(ParseeData *data, HashMap *event, char *jid, char *muc, char *name, char UnistrFree(filtered); /* 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 *input = StrConcat(3, sender, name, nonce_str); diff --git a/src/Parsee/Config.c b/src/Parsee/Config.c index 0e1ee04..541c0a4 100644 --- a/src/Parsee/Config.c +++ b/src/Parsee/Config.c @@ -77,6 +77,7 @@ ParseeSetThreads(int xmpp, int http) { if (!config) { + Achievement("THREAD COUNT REQUEST WITHOUT CONFIG", true); return; } config->http_threads = http; @@ -88,6 +89,7 @@ ParseeExportConfigYAML(Stream *stream) { if (!stream || !config) { + Achievement("YAML EXPORT REQUEST WITHOUT CONFIG", true); return; } StreamPrintf(stream, "# Autogenerated YAML AS entry for %s\n", NAME); @@ -109,6 +111,7 @@ ParseeExportConfigYAML(Stream *stream) StreamPrintf(stream, " aliases:\n"); StreamPrintf(stream, " - exclusive: true\n"); StreamPrintf(stream, " regex: \"#%s_.*\"\n", config->namespace_base); + StreamFlush(stream); } void diff --git a/src/Parsee/Data.c b/src/Parsee/Data.c index 87b2263..3d2bbb8 100644 --- a/src/Parsee/Data.c +++ b/src/Parsee/Data.c @@ -337,6 +337,15 @@ ParseePushStanza(ParseeData *data, char *chat_id, char *stanza_id, char *id, cha } /* 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); j = DbJson(ref); diff --git a/src/Parsee/User.c b/src/Parsee/User.c index fe7d00b..5614ca2 100644 --- a/src/Parsee/User.c +++ b/src/Parsee/User.c @@ -552,10 +552,16 @@ ParseeSendPresence(ParseeData *data) while (HashMapIterate(mucs, &muc, (void **) &val)) { 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 */ - Log(LOG_NOTICE, "Sending presence to %s", rev); - XMPPJoinMUC(data->jabber, "parsee", rev, NULL, false); + Log(LOG_NOTICE, "Sending presence to %s last=%ds", rev, diff); + XMPPJoinMUC(data->jabber, "parsee", rev, NULL, diff, false); + DbUnlock(data->db, chat); + Free(chat_id); Free(rev); } DbUnlock(data->db, ref); diff --git a/src/Routes/Root.c b/src/Routes/Root.c index e0e3e87..a68bfbc 100644 --- a/src/Routes/Root.c +++ b/src/Routes/Root.c @@ -173,7 +173,7 @@ RouteHead(RouteRoot, arr, argp) P("
"); { P("More information available at "); - P("the actual page."); } diff --git a/src/Routes/UserAck.c b/src/Routes/UserAck.c index 54ca96e..50029ba 100644 --- a/src/Routes/UserAck.c +++ b/src/Routes/UserAck.c @@ -131,7 +131,7 @@ RouteHead(RouteRoomAck, arr, argp) { char *rev = StrConcat(2, muc, "/parsee"); 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); } diff --git a/src/Signal.c b/src/Signal.c index 89e48e2..4274561 100644 --- a/src/Signal.c +++ b/src/Signal.c @@ -25,6 +25,7 @@ SignalHandler(int signal) if (signal == SIGPIPE) { Log(LOG_DEBUG, "Caught a SIGPIPE..."); + return; } } diff --git a/src/XMPPThread/ReListener.c b/src/XMPPThread/ReListener.c index f518a67..56d5317 100644 --- a/src/XMPPThread/ReListener.c +++ b/src/XMPPThread/ReListener.c @@ -134,6 +134,7 @@ ParseeXMPPThread(void *argp) ParseeData *args = argp; XMPPComponent *jabber = args->jabber; XMLElement *stanza = NULL; + HashMap *await_table2; size_t i; /* Initialise the await table */ @@ -268,7 +269,9 @@ ParseeXMPPThread(void *argp) } ArrayFree(info.stanzas); - HashMapFree(await_table); + await_table2 = await_table; + await_table = NULL; + HashMapFree(await_table2); pthread_mutex_destroy(&info.lock); diff --git a/src/include/XMPP.h b/src/include/XMPP.h index 0a4cfe7..b3f4c09 100644 --- a/src/include/XMPP.h +++ b/src/include/XMPP.h @@ -30,7 +30,7 @@ extern XMPPComponent * XMPPInitialiseCompStream(char *host, int port); extern bool XMPPAuthenticateCompStream(XMPPComponent *comp, char *shared); /* 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); /* TODO: XMPP stuff, I don't fucking know, I'm not a Jabbernerd. */