[MOD] Do NOT do unnecessary notifications

I should move notifying users into some sort of background task. It is
not particularly necessary to send events, and essentially slows down
the requester thread doing something that's not really sending an event.

It could also scale terribly in rooms where there exists a lot of local
users, with every one of them having possibly at least hundreds of sync
tokens.
This commit is contained in:
LDA 2024-12-03 15:57:05 +01:00
parent 4b427a4c82
commit 33edd2ceaf
2 changed files with 3 additions and 8 deletions

View file

@ -338,13 +338,6 @@ RoomAddEventV1(Room *room, PduV1 pdu, PduV1Status status)
/* If we have a membership change, then add it to the
* proper table. */
{
CommonID *id = UserIdParse(pdu.sender, NULL);
User *user = UserLockID(room->db, id);
UserPushEvent(user, pdu_json);
UserUnlock(user);
UserIdFree(id);
}
if (relates_to && RelationFromJson(relates_to, &rel, &errp))
{
DbRef *relate = DbLock(

View file

@ -1387,6 +1387,8 @@ UserPushEvent(User *user, HashMap *event)
UserPushJoinSync(user, roomId);
/* TODO: In some very fun cases, this loop could be cosmically slow.
* Especially in the scale of 1.5k sync tokens. It can happen. */
entries = DbList(user->db, 3, "users", user->name, "sync");
for (i = 0; i < ArraySize(entries); i++)
{
@ -1859,7 +1861,7 @@ UserIsSyncOld(User *user, char *token)
dt = UtilTsMillis() - JsonValueAsInteger(HashMapGet(map, "creation"));
DbUnlock(user->db, ref);
return dt > (3 * 24 * 60 * 60 * 1000); /* Three days of timeout. */
return dt > (3 * 60 * 60 * 1000); /* Three hours of timeout. */
}
bool
UserSyncExists(User *user, char *sync)