mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
added force media_conn option
This commit is contained in:
@@ -113,7 +113,7 @@ export class WAConnection extends Base {
|
||||
await generateThumbnail(buffer, mediaType, options)
|
||||
|
||||
// send a query JSON to obtain the url & auth token to upload our media
|
||||
let json = await this.refreshMediaConn ()
|
||||
let json = await this.refreshMediaConn (options.forceNewMediaOptions)
|
||||
|
||||
let mediaUrl: string
|
||||
for (let host of json.hosts) {
|
||||
@@ -273,10 +273,13 @@ export class WAConnection extends Base {
|
||||
@Mutex ()
|
||||
protected async refreshMediaConn (forceGet = false) {
|
||||
if (!this.mediaConn || forceGet || (new Date().getTime()-this.mediaConn.fetchDate.getTime()) > this.mediaConn.ttl*1000) {
|
||||
const result = await this.query({json: ['query', 'mediaConn']})
|
||||
this.mediaConn = result.media_conn
|
||||
this.mediaConn = await this.getNewMediaConn()
|
||||
this.mediaConn.fetchDate = new Date()
|
||||
}
|
||||
return this.mediaConn
|
||||
}
|
||||
protected async getNewMediaConn () {
|
||||
const result = await this.query({json: ['query', 'mediaConn']})
|
||||
return result.media_conn
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,6 +329,8 @@ export interface MessageOptions {
|
||||
uploadAgent?: Agent
|
||||
/** If set to true (default), automatically detects if you're sending a link & attaches the preview*/
|
||||
detectLinks?: boolean
|
||||
/** Fetches new media options for every media file */
|
||||
forceNewMediaOptions?: boolean
|
||||
}
|
||||
export interface WABroadcastListInfo {
|
||||
status: number
|
||||
|
||||
Reference in New Issue
Block a user