mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 16:55:10 +00:00
[MOD] Notify MUCs about errors
This commit is contained in:
parent
86deab29af
commit
c365681fcb
7 changed files with 37 additions and 27 deletions
43
src/Main.c
43
src/Main.c
|
|
@ -13,7 +13,7 @@
|
|||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Unistring.h>
|
||||
#include <StanzaBuilder.h>
|
||||
#include <Parsee.h>
|
||||
#include <XMPP.h>
|
||||
#include <AS.h>
|
||||
|
|
@ -66,21 +66,36 @@ ParseeCheckMatrix(void *datp)
|
|||
if (!ASPing(data->config))
|
||||
{
|
||||
Log(LOG_ERR, "Cannot reach '%s' properly...", data->config->homeserver_host);
|
||||
if (++streak >= 5)
|
||||
if (++streak == 10)
|
||||
{
|
||||
Log(LOG_ERR, "This has been at least the fifth time in a row.");
|
||||
Log(LOG_ERR, "Please check if your homeserver is active.");
|
||||
Log(LOG_ERR, "%s shall now exit...", NAME);
|
||||
DbRef *ref = DbLockIntent(data->db, DB_HINT_READONLY, 1, "chats");
|
||||
HashMap *json = DbJson(ref);
|
||||
HashMap *mucs = GrabObject(json, 1, "mucs");
|
||||
char *muc;
|
||||
void *ignored;
|
||||
|
||||
/* TODO: SEGV! */
|
||||
pthread_mutex_lock(&data->halt_lock);
|
||||
data->halted = true;
|
||||
pthread_mutex_unlock(&data->halt_lock);
|
||||
|
||||
XMPPFinishCompStream(data->jabber);
|
||||
//pthread_join(xmpp_thr, NULL);
|
||||
Log(LOG_INFO, "Stopping server...");
|
||||
HttpServerStop(data->server);
|
||||
/* Notify any potential MUCs about this */
|
||||
while (HashMapIterate(mucs, &muc, &ignored))
|
||||
{
|
||||
char *id = StrRandom(32);
|
||||
char *sender = StrConcat(3, "parsee@", data->jabber->host, "/parsee");
|
||||
StanzaBuilder *b = CreateStanzaBuilder(sender, muc, id);
|
||||
SetStanzaType(b, "groupchat");
|
||||
SetStanzaBody(b,
|
||||
"This bridge hasn't been able to reach the Matrix host, and "
|
||||
"as such, some messages may not have been sent over."
|
||||
);
|
||||
|
||||
WriteoutStanza(b, data->jabber, 0);
|
||||
DestroyStanzaBuilder(b);
|
||||
|
||||
Free(sender);
|
||||
Free(id);
|
||||
}
|
||||
(void) ignored;
|
||||
|
||||
DbUnlock(data->db, ref);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -109,7 +124,7 @@ Main(Array *args, HashMap *env)
|
|||
);
|
||||
ParseePrintASCII();
|
||||
Log(LOG_INFO, "=======================");
|
||||
Log(LOG_INFO, "(C)opyright 2024 LDA and other contributors");
|
||||
Log(LOG_INFO, "(C)opyright 2024-2025 LDA and other contributors");
|
||||
Log(LOG_INFO, "(This program is free software, see LICENSE.)");
|
||||
|
||||
#ifdef PLATFORM_IPHONE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue