[MOD] Do NOT do unnecessary notifications
Some checks failed
Compile Telodendria / Compile Telodendria (aarch64, alpine) (pull_request) Has been cancelled
Some checks failed
Compile Telodendria / Compile Telodendria (aarch64, alpine) (pull_request) Has been cancelled
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:
parent
4b427a4c82
commit
33edd2ceaf
2 changed files with 3 additions and 8 deletions
|
@ -338,13 +338,6 @@ RoomAddEventV1(Room *room, PduV1 pdu, PduV1Status status)
|
||||||
|
|
||||||
/* If we have a membership change, then add it to the
|
/* If we have a membership change, then add it to the
|
||||||
* proper table. */
|
* 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))
|
if (relates_to && RelationFromJson(relates_to, &rel, &errp))
|
||||||
{
|
{
|
||||||
DbRef *relate = DbLock(
|
DbRef *relate = DbLock(
|
||||||
|
|
|
@ -1387,6 +1387,8 @@ UserPushEvent(User *user, HashMap *event)
|
||||||
|
|
||||||
UserPushJoinSync(user, roomId);
|
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");
|
entries = DbList(user->db, 3, "users", user->name, "sync");
|
||||||
for (i = 0; i < ArraySize(entries); i++)
|
for (i = 0; i < ArraySize(entries); i++)
|
||||||
{
|
{
|
||||||
|
@ -1859,7 +1861,7 @@ UserIsSyncOld(User *user, char *token)
|
||||||
dt = UtilTsMillis() - JsonValueAsInteger(HashMapGet(map, "creation"));
|
dt = UtilTsMillis() - JsonValueAsInteger(HashMapGet(map, "creation"));
|
||||||
|
|
||||||
DbUnlock(user->db, ref);
|
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
|
bool
|
||||||
UserSyncExists(User *user, char *sync)
|
UserSyncExists(User *user, char *sync)
|
||||||
|
|
Loading…
Reference in a new issue