Skip to content

Commit

Permalink
fix: throw private url error
Browse files Browse the repository at this point in the history
  • Loading branch information
XxLittleCxX committed Aug 30, 2023
1 parent a3ea0c8 commit 5a2e749
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions adapters/dingtalk/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export class DingtalkMessageEncoder extends MessageEncoder<DingtalkBot> {
// await this.sendMessage('sampleImageMsg', {
// photoURL: attrs.url
// })
if (this.bot.ctx.http.isPrivate(attrs.url)) {
throw new Error(`Send ${type} failed, please use public url.`)
// this.buffer += `![${attrs.alt}](https://static.dingtalk.com/media/${media_id}_${width}_${height}.jpg)`
}
this.buffer += `![${attrs.alt}](${attrs.url})`
} else if (type === 'message') {
await this.flush()
Expand Down
4 changes: 4 additions & 0 deletions adapters/line/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class LineMessageEncoder extends MessageEncoder<LineBot> {
async visit(element: h) {
const { type, attrs, children } = element

if (attrs.url && ['image', 'video', 'audio'].includes(type)) {
throw new Error(`Send ${type} failed, please use public url.`)
}

if (type === 'text') {
this.buffer += attrs.content
} else if (type === 'image' && attrs.url) {
Expand Down

0 comments on commit 5a2e749

Please sign in to comment.