forked from devlikeapro/waha
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94191a2
commit df3bc97
Showing
25 changed files
with
1,666 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { BufferJSON } from '@adiwajshing/baileys/lib/Utils'; | ||
import { | ||
CallHandler, | ||
ExecutionContext, | ||
Injectable, | ||
NestInterceptor, | ||
StreamableFile, | ||
} from '@nestjs/common'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
@Injectable() | ||
export class BufferJsonReplacerInterceptor implements NestInterceptor { | ||
intercept(context: ExecutionContext, next: CallHandler): Observable<any> { | ||
return next.handle().pipe( | ||
map((data) => { | ||
if (typeof data !== 'object' || data === null) { | ||
return data; | ||
} | ||
// Buffer | ||
if (Buffer.isBuffer(data) || data?.data || data?.url) { | ||
return data; | ||
} | ||
|
||
// StreamableFile | ||
if (data instanceof StreamableFile) { | ||
return data; | ||
} | ||
|
||
return JSON.parse(JSON.stringify(data, BufferJSON.replacer)); | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.