Skip to content

Commit

Permalink
fix(dingtalk): internal api result parsing (#253)
Browse files Browse the repository at this point in the history
Co-authored-by: LittleC <26459759+XxLittleCxX@users.noreply.github.com>
  • Loading branch information
MaikoTan and XxLittleCxX authored Apr 2, 2024
1 parent 92e5626 commit 350472a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions adapters/dingtalk/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class HttpServer<C extends Context = Context> extends Adapter<C, Dingtalk
async connect(bot: DingtalkBot<C>) {
await bot.refreshToken()
await bot.getLogin()
bot.online()

// https://open.dingtalk.com/document/orgapp/receive-message
this.ctx.server.post('/dingtalk', async (ctx) => {
Expand Down
2 changes: 1 addition & 1 deletion adapters/dingtalk/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Internal {
config.params = { ...config.params, access_token: this.bot.token }
}
try {
return await quester(method, url, config)
return (await quester(method, url, config)).data
} catch (error) {
if (!Quester.Error.is(error) || !error.response) throw error
throw new Error(`[${error.response.status}] ${JSON.stringify(error.response.data)}`)
Expand Down
1 change: 1 addition & 0 deletions adapters/dingtalk/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class WsClient<C extends Context = Context> extends Adapter.WsClient<C, D
async prepare() {
await this.bot.refreshToken()
await this.bot.getLogin()
// Ref: https://open.dingtalk.com/document/direction/stream-mode-protocol-access-description
const { endpoint, ticket } = await this.bot.http.post<{
endpoint: string
ticket: string
Expand Down

0 comments on commit 350472a

Please sign in to comment.