mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Merge branch 'master' into pr/2472
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { AxiosRequestConfig } from 'axios'
|
||||
import type NodeCache from 'node-cache'
|
||||
import type { Logger } from 'pino'
|
||||
import type { Readable } from 'stream'
|
||||
@@ -5,6 +6,7 @@ import type { URL } from 'url'
|
||||
import { proto } from '../../WAProto'
|
||||
import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults'
|
||||
import type { GroupMetadata } from './GroupMetadata'
|
||||
import { CacheStore } from './Socket'
|
||||
|
||||
// export the WAMessage Prototypes
|
||||
export { proto as WAProto }
|
||||
@@ -210,9 +212,11 @@ export type MediaGenerationOptions = {
|
||||
mediaTypeOverride?: MediaType
|
||||
upload: WAMediaUploadFunction
|
||||
/** cache media so it does not have to be uploaded again */
|
||||
mediaCache?: NodeCache
|
||||
mediaCache?: CacheStore
|
||||
|
||||
mediaUploadTimeoutMs?: number
|
||||
|
||||
options?: AxiosRequestConfig
|
||||
}
|
||||
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
||||
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
import { AxiosRequestConfig } from 'axios'
|
||||
import type { Agent } from 'https'
|
||||
import type NodeCache from 'node-cache'
|
||||
import type { Logger } from 'pino'
|
||||
import type { URL } from 'url'
|
||||
import { proto } from '../../WAProto'
|
||||
@@ -11,33 +10,40 @@ import { MediaConnInfo } from './Message'
|
||||
export type WAVersion = [number, number, number]
|
||||
export type WABrowserDescription = [string, string, string]
|
||||
|
||||
export type MessageRetryMap = { [msgId: string]: number }
|
||||
export type CacheStore = {
|
||||
/** get a cached key and change the stats */
|
||||
get<T>(key: string): T | undefined
|
||||
/** set a key in the cache */
|
||||
set<T>(key: string, value: T): void
|
||||
/** delete a key from the cache */
|
||||
del(key: string): void
|
||||
/** flush all data */
|
||||
flushAll(): void
|
||||
}
|
||||
|
||||
export type SocketConfig = {
|
||||
/** the WS url to connect to WA */
|
||||
waWebSocketUrl: string | URL
|
||||
/** Fails the connection if the socket times out in this interval */
|
||||
connectTimeoutMs: number
|
||||
connectTimeoutMs: number
|
||||
/** Default timeout for queries, undefined for no timeout */
|
||||
defaultQueryTimeoutMs: number | undefined
|
||||
/** ping-pong interval for WS connection */
|
||||
keepAliveIntervalMs: number
|
||||
/** proxy agent */
|
||||
agent?: Agent
|
||||
agent?: Agent
|
||||
/** pino logger */
|
||||
logger: Logger
|
||||
logger: Logger
|
||||
/** version to connect with */
|
||||
version: WAVersion
|
||||
/** override browser config */
|
||||
browser: WABrowserDescription
|
||||
/** agent used for fetch requests -- uploading/downloading media */
|
||||
fetchAgent?: Agent
|
||||
browser: WABrowserDescription
|
||||
/** agent used for fetch requests -- uploading/downloading media */
|
||||
fetchAgent?: Agent
|
||||
/** should the QR be printed in the terminal */
|
||||
printQRInTerminal: boolean
|
||||
/** should events be emitted for actions done by this socket connection */
|
||||
emitOwnEvents: boolean
|
||||
/** provide a cache to store media, so does not have to be re-uploaded */
|
||||
mediaCache?: NodeCache
|
||||
/** custom upload hosts to upload media to */
|
||||
customUploadHosts: MediaConnInfo['hosts']
|
||||
/** time to wait between sending new retry requests */
|
||||
@@ -50,14 +56,19 @@ export type SocketConfig = {
|
||||
shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean
|
||||
/** transaction capability options for SignalKeyStore */
|
||||
transactionOpts: TransactionCapabilityOptions
|
||||
/** provide a cache to store a user's device list */
|
||||
userDevicesCache?: NodeCache
|
||||
/** marks the client as online whenever the socket successfully connects */
|
||||
markOnlineOnConnect: boolean
|
||||
|
||||
/** provide a cache to store media, so does not have to be re-uploaded */
|
||||
mediaCache?: CacheStore
|
||||
/**
|
||||
* map to store the retry counts for failed messages;
|
||||
* used to determine whether to retry a message or not */
|
||||
msgRetryCounterMap?: MessageRetryMap
|
||||
msgRetryCounterCache?: CacheStore
|
||||
/** provide a cache to store a user's device list */
|
||||
userDevicesCache?: CacheStore
|
||||
/** cache to store call offers */
|
||||
callOfferCache?: CacheStore
|
||||
/** width for link preview images */
|
||||
linkPreviewImageThumbnailWidth: number
|
||||
/** Should Baileys ask the phone for full history, will be received async */
|
||||
@@ -92,7 +103,7 @@ export type SocketConfig = {
|
||||
}
|
||||
|
||||
/** options for axios */
|
||||
options: AxiosRequestConfig<any>
|
||||
options: AxiosRequestConfig<{}>
|
||||
/**
|
||||
* fetch a message from your store
|
||||
* implement this so that messages failed to send (solves the "this message can take a while" issue) can be retried
|
||||
|
||||
Reference in New Issue
Block a user