@@ -10,6 +10,7 @@ import { Web3Adapter } from "web3-adapter";
1010import path from "path" ;
1111import dotenv from "dotenv" ;
1212import { AppDataSource } from "../../database/data-source" ;
13+ import { shouldProcessWebhook } from "../../context/OperationContext" ;
1314
1415dotenv . config ( { path : path . resolve ( __dirname , "../../../../../.env" ) } ) ;
1516export const adapter = new Web3Adapter ( {
@@ -253,6 +254,12 @@ export class PostgresSubscriber implements EntitySubscriberInterface {
253254 private async handleChange ( entity : any , tableName : string ) : Promise < void > {
254255 console . log ( `🔍 handleChange called for: ${ tableName } , entityId: ${ entity ?. id } ` ) ;
255256
257+ // Check if this operation should be processed (only ConsentService operations for groups/messages)
258+ if ( ! shouldProcessWebhook ( entity ?. id , tableName ) ) {
259+ console . log ( `⏭️ Skipping webhook for ${ tableName } :${ entity ?. id } - not from ConsentService (protected entity)` ) ;
260+ return ;
261+ }
262+
256263 // Handle junction table changes - DON'T IGNORE group_participants!
257264 // @ts -ignore
258265 const junctionInfo = JUNCTION_TABLE_MAP [ tableName ] ;
@@ -344,6 +351,12 @@ export class PostgresSubscriber implements EntitySubscriberInterface {
344351 return ;
345352 }
346353
354+ // Check if this junction table change should be processed (only ConsentService operations for groups)
355+ if ( ! shouldProcessWebhook ( parentId , junctionInfo . entity ) ) {
356+ console . log ( `⏭️ Skipping junction table webhook for ${ junctionInfo . entity } :${ parentId } - not from ConsentService (protected entity)` ) ;
357+ return ;
358+ }
359+
347360 const repository = AppDataSource . getRepository ( junctionInfo . entity ) ;
348361 const parentEntity = await repository . findOne ( {
349362 where : { id : parentId } ,
@@ -408,6 +421,12 @@ export class PostgresSubscriber implements EntitySubscriberInterface {
408421 */
409422 private async sendGroupWebhook ( data : any ) : Promise < void > {
410423 try {
424+ // Check if this group webhook should be processed (only ConsentService operations for groups)
425+ if ( ! shouldProcessWebhook ( data . id , "groups" ) ) {
426+ console . log ( `⏭️ Skipping group webhook for ${ data . id } - not from ConsentService (protected entity)` ) ;
427+ return ;
428+ }
429+
411430 // Skip groups with Match ID in description (already processed)
412431 if ( data . description && typeof data . description === 'string' && data . description . startsWith ( 'Match ID:' ) ) {
413432 console . log ( `🔍 Skipping group webhook - has Match ID in description: ${ data . description } ` ) ;
0 commit comments