Skip to content

Commit

Permalink
feat: support for searching local images (#29)
Browse files Browse the repository at this point in the history
Co-authored-by: idanran <96647698+idanran@users.noreply.github.com>
  • Loading branch information
idranme and idranme authored Apr 20, 2024
1 parent 696fc34 commit af981ee
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ export function apply(ctx: Context, config: Config = {}) {
const id = session.channelId
pendings.add(id)
try {
const isPrivate = await http.isLocal(url)
if (isPrivate) {
const { data, mime } = await http.file(url)
const formData = new FormData()
formData.append('photo', new Blob([data], { type: mime }))
formData.append('isAjax', 'true')
const uploadResponse = await http.post('https://imgops.com/store', formData)
url = 'https:/' + uploadResponse
}
const result = await callback(http, url, session, config)
if (typeof result === 'string') return result
} catch (error) {
Expand Down

0 comments on commit af981ee

Please sign in to comment.