(
message: Pick<
NormalizedMessage,
"chatType" | "mentionedBot" | "rawContentType" | "content" | "resources"
>,
)
| 75 | return chatId; |
| 76 | } |
| 77 | |
| 78 | export function normalizeFeishuMessage( |
| 79 | message: Pick< |
| 80 | NormalizedMessage, |
| 81 | "chatType" | "mentionedBot" | "rawContentType" | "content" | "resources" |
| 82 | >, |
| 83 | ): FeishuMessageHandlingDecision { |
| 84 | if (message.chatType === "group" && !message.mentionedBot) { |
| 85 | return { action: "ignore" }; |
| 86 | } |
| 87 | |
| 88 | const hasSupportedResource = message.resources.some(isSupportedResource); |
| 89 | |
| 90 | if (message.rawContentType !== "text" && !hasSupportedResource) { |
| 91 | return { action: "unsupported" }; |
| 92 | } |
| 93 | |
| 94 | const text = message.rawContentType === "text" ? message.content.trim() : ""; |
| 95 | if (!text) { |
| 96 | if (hasSupportedResource) { |
| 97 | return { |
| 98 | action: "handle", |
| 99 | text: ATTACHMENT_MESSAGE_TEXT, |
| 100 | }; |
| 101 | } |
| 102 | return { action: "ignore" }; |
| 103 | } |
| 104 | |
| 105 | return { |
| 106 | action: "handle", |
| 107 | text, |
| 108 | }; |
| 109 | } |
| 110 | |
| 111 | function isSupportedResource( |
no outgoing calls
no test coverage detected