Skip to content

Commit

Permalink
[WAHA] Handle DELETED and NON_EXISTING channels (data.state.type)
Browse files Browse the repository at this point in the history
  • Loading branch information
devlikepro committed Aug 18, 2024
1 parent 3d23c05 commit 6c59c7e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Socket/newsletter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const makeNewsletterSocket = (config: SocketConfig) => {
const node = await newsletterWMexQuery(undefined, QueryIds.SUBSCRIBED)
const result = getBinaryNodeChild(node, 'result')?.content?.toString()
const data = JSON.parse(result!).data[XWAPaths.SUBSCRIBED]
return data.map(toNewsletterMetadata)
return data.map(toNewsletterMetadata).filter(Boolean)
},

newsletterAdminCount: async(jid: string) => {
Expand Down Expand Up @@ -253,7 +253,15 @@ export const extractNewsletterMetadata = (node: BinaryNode, isCreate?: boolean)
return toNewsletterMetadata(metadataPath)
}

function toNewsletterMetadata(data: any): NewsletterMetadata {
function toNewsletterMetadata(data: any): NewsletterMetadata | null {
if(data.state.type === 'DELETED') {
return null
}

if(data.state.type === 'NON_EXISTING') {
return null
}

return {
id: data.id,
state: data.state.type,
Expand Down

0 comments on commit 6c59c7e

Please sign in to comment.