Skip to content

Commit

Permalink
fix(lark): fix edge case when send in thread
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Dec 27, 2024
1 parent de3ac50 commit 7cf7c58
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 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.8.4",
"version": "3.8.5",
"type": "module",
"main": "lib/index.cjs",
"types": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions adapters/lark/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default LarkBot

declare module '@satorijs/core' {
interface Session {
feishu: Lark.Internal
lark: Lark.Internal
feishu: Lark.Internal & Lark.EventPayload
lark: Lark.Internal & Lark.EventPayload
}
}
14 changes: 11 additions & 3 deletions adapters/lark/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
async post(data?: any) {
try {
let resp: Lark.Message
let quote = this.quote
const payload = this.options?.session?.lark
if (!quote && payload?.type === 'im.message.receive_v1' && payload.event.message.thread_id) {
quote = {
id: payload.event.message.message_id,
replyInThread: true,
}
}
if (this.editMessageIds) {
const messageId = this.editMessageIds.pop()
if (!messageId) throw new Error('No message to edit')
Expand All @@ -25,10 +33,10 @@ export class LarkMessageEncoder<C extends Context = Context> extends MessageEnco
} else {
await this.bot.internal.updateImMessage(messageId, data)
}
} else if (this.quote?.id) {
resp = await this.bot.internal.replyImMessage(this.quote.id, {
} else if (quote?.id) {
resp = await this.bot.internal.replyImMessage(quote.id, {
...data,
reply_in_thread: this.quote.replyInThread,
reply_in_thread: quote.replyInThread,
})
} else {
data.receive_id = this.channelId
Expand Down
1 change: 1 addition & 0 deletions adapters/lark/src/types/message/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ declare module '../event' {
message_id: string
root_id: string
parent_id: string
thread_id: string
create_time: string
chat_id: string
chat_type: string
Expand Down

0 comments on commit 7cf7c58

Please sign in to comment.