Skip to content

Commit

Permalink
fix(lark): set refresh interval to 20 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 9, 2025
1 parent 1858596 commit 9595e33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion adapters/lark/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@satorijs/adapter-lark",
"description": "Lark (飞书) Adapter for Satorijs",
"version": "3.9.1",
"version": "3.9.4",
"type": "module",
"main": "lib/index.cjs",
"types": "lib/index.d.ts",
Expand Down
9 changes: 5 additions & 4 deletions adapters/lark/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ export class LarkBot<C extends Context = Context> extends Bot<C, LarkBot.Config>
})
this.logger.debug('refreshed token %s', token)
this.token = token
if (this._refresher) clearTimeout(this._refresher)
// https://open.feishu.cn/document/server-docs/authentication-management/access-token/tenant_access_token_internal
// tenant_access_token 的最大有效期是 2 小时。
// 剩余有效期小于 30 分钟时,调用本接口会返回一个新的 tenant_access_token,这会同时存在两个有效的 tenant_access_token。
// 剩余有效期小于 30 分钟时,调用本接口会返回一个新的 tenant_access_token,此时会同时存在两个有效的 tenant_access_token。
// 剩余有效期大于等于 30 分钟时,调用本接口会返回原有的 tenant_access_token。
// https://open.feishu.cn/document/server-docs/authentication-management/access-token/tenant_access_token_internal
if (this._refresher) clearTimeout(this._refresher)
this._refresher = setTimeout(() => this.refreshToken(), Time.minute * 100)
// 初次获得 token 后的半小时内必须刷新一次,因为初次获得的 token 可能是 1.5 小时前生成的。
this._refresher = setTimeout(() => this.refreshToken(), Time.minute * 20)
this.online()
}

Expand Down

0 comments on commit 9595e33

Please sign in to comment.