fix(services): resolve infinite subscription loop in moderationService

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-26 22:24:04 +00:00
1 parent fe4042e8cc
commit d48847aa5a
1 file changed
+28
+28
View File
@@ -528,6 +528,7 @@ export class ModerationService {
this.contactSubscription = null;
this.contactListPromise = null;
this.lastContactEventId = null;
this.reportEvents = new Map();
this.reportSummaries = new Map();
@@ -1074,6 +1075,9 @@ export class ModerationService {
}
for (const value of next) {
if (previous.has(value)) {
continue;
}
this.subscribeToTrustedMuteList(value).catch((error) => {
this.log(
`(moderationService) failed to subscribe to trusted mute list for ${value}`,
@@ -1988,6 +1992,10 @@ export class ModerationService {
return;
}
if (event.id && event.id === this.lastContactEventId) {
return;
}
const nextSet = new Set();
for (const tag of event.tags) {
if (!Array.isArray(tag) || tag[0] !== "p") {
@@ -1999,6 +2007,26 @@ export class ModerationService {
}
}
if (this.viewerContacts instanceof Set && this.viewerContacts.size === nextSet.size) {
let changed = false;
for (const value of nextSet) {
if (!this.viewerContacts.has(value)) {
changed = true;
break;
}
}
if (!changed) {
if (event.id) {
this.lastContactEventId = event.id;
}
return;
}
}
if (event.id) {
this.lastContactEventId = event.id;
}
this.rebuildTrustedContacts(nextSet, { previous: previousContacts });
}