Skip to content

Commit cb3eae3

Browse files
authored
chore: attmept to fix message spam (#312)
1 parent 85e6aae commit cb3eae3

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

platforms/cerberus/src/web3adapter/watchers/subscriber.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,19 @@ export class PostgresSubscriber implements EntitySubscriberInterface {
177177
// Handle regular entity changes
178178
const data = this.entityToPlain(entity);
179179
if (!data.id) return;
180+
181+
// For Message entities, only process if they are system messages
182+
if (tableName === "messages") {
183+
// Check if this is a system message (starts with $$system-message$$)
184+
const isSystemMessage = data.content && typeof data.content === 'string' && data.content.startsWith('$$system-message$$');
185+
186+
if (!isSystemMessage) {
187+
console.log("📝 Skipping non-system message:", data.id);
188+
return;
189+
}
190+
191+
console.log("📝 Processing system message:", data.id);
192+
}
180193

181194
try {
182195
setTimeout(async () => {

platforms/evoting-api/src/web3adapter/watchers/subscriber.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,23 @@ export class PostgresSubscriber implements EntitySubscriberInterface {
303303
console.log(data, entity)
304304
if (!data.id) return;
305305

306-
// Special logging for Message entities to track group and admin data
306+
// For Message entities, only process if they are system messages
307307
if (tableName === "messages") {
308-
console.log("📝 Processing Message change:", {
308+
// Check if this is a system message (starts with $$system-message$$)
309+
const isSystemMessage = data.content && typeof data.content === 'string' && data.content.startsWith('$$system-message$$');
310+
311+
if (!isSystemMessage) {
312+
console.log("📝 Skipping non-system message:", data.id);
313+
return;
314+
}
315+
316+
console.log("📝 Processing system message:", {
309317
id: data.id,
310318
hasGroup: !!data.group,
311319
groupId: data.group?.id,
312320
hasAdmins: !!data.group?.admins,
313321
adminCount: data.group?.admins?.length || 0,
314-
isSystemMessage: data.isSystemMessage
322+
isSystemMessage: true
315323
});
316324
}
317325

0 commit comments

Comments
 (0)