Skip to content

Commit

Permalink
fix(telegram): telegram sticky file mime type (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
idranme authored Aug 5, 2023
1 parent 7a03fce commit cf1f132
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions adapters/telegram/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@satorijs/satori": "^2.6.0"
},
"dependencies": {
"file-type": "^16.5.4",
"form-data": "^4.0.0"
}
}
6 changes: 5 additions & 1 deletion adapters/telegram/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { adaptAuthorMeta, adaptGuildMember, adaptMessageMeta, adaptUser } from '
import { TelegramMessageEncoder } from './message'
import { HttpServer } from './server'
import { HttpPolling } from './polling'
import FileType from 'file-type'

const logger = new Logger('telegram')

Expand Down Expand Up @@ -267,7 +268,10 @@ export class TelegramBot<T extends TelegramBot.Config = TelegramBot.Config> exte
if (this.server) {
return { url: `${this.server}/${filePath}` }
}
const { mime, data } = await this.$getFile(filePath)
let { mime, data } = await this.$getFile(filePath)
if (mime === 'application/octet-stream') {
mime = await FileType.fromBuffer(data)?.mime

Check failure on line 273 in adapters/telegram/src/bot.ts

View workflow job for this annotation

GitHub Actions / build

Property 'mime' does not exist on type 'Promise<FileTypeResult>'.
}
const base64 = `data:${mime};base64,` + arrayBufferToBase64(data)
return { url: base64 }
}
Expand Down

0 comments on commit cf1f132

Please sign in to comment.