Repository navigation
fix(channel): update fromMe filter to check for undefined #2806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -624,7 +624,7 @@ export class ChannelStartupService { | |
| ...timestampFilter, | ||
| AND: [ | ||
| keyFilters?.id ? { key: { path: ['id'], equals: keyFilters?.id } } : {}, | ||
| keyFilters?.fromMe ? { key: { path: ['fromMe'], equals: keyFilters?.fromMe } } : {}, | ||
| keyFilters?.fromMe !== undefined ? { key: { path: ['fromMe'], equals: keyFilters.fromMe } } : {}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Medium Β· Null filters fail message lookup When a request supplies Reject null Also at Prompt for AI agentsIn `src/api/services/channel.service.ts` at line 627:
**Null filters fail message lookup**
When a request supplies `fromMe: null` alongside an unrecognized key in `where.key`, `keyFilters.fromMe` is null, so the new condition includes `equals: null` in the Prisma JSON filter; Prisma rejects null for this JSON filter and the lookup fails instead of returning messages.
Reject null `fromMe` values in validation or exclude null as well as undefined when building the filter.
Also at `src/api/services/channel.service.ts:652`. |
||
| keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {}, | ||
| keyFilters?.participants ? { key: { path: ['participants'], equals: keyFilters?.participants } } : {}, | ||
| ], | ||
|
|
@@ -648,7 +648,7 @@ export class ChannelStartupService { | |
| ...timestampFilter, | ||
| AND: [ | ||
| keyFilters?.id ? { key: { path: ['id'], equals: keyFilters?.id } } : {}, | ||
| keyFilters?.fromMe ? { key: { path: ['fromMe'], equals: keyFilters?.fromMe } } : {}, | ||
| keyFilters?.fromMe !== undefined ? { key: { path: ['fromMe'], equals: keyFilters.fromMe } } : {}, | ||
| keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {}, | ||
| keyFilters?.participants ? { key: { path: ['participants'], equals: keyFilters?.participants } } : {}, | ||
| ], | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π High Β· False sender filters are ignored
When a message query is handled by the Baileys provider with
fromMe: false,BaileysStartupService.fetchMessagesuses truthy checks forfromMein both its count and result queries, so it omits the filter and returns messages from both sender directions with an unfiltered count.Update both Baileys query checks to include
fromMewhenever it is notundefined.Also at
src/api/services/channel.service.ts:651-652.Prompt for AI agents