(
key: IntegrationTaskKey,
params: ChatPostMessageArguments
)
| 109 | } |
| 110 | |
| 111 | postMessage( |
| 112 | key: IntegrationTaskKey, |
| 113 | params: ChatPostMessageArguments |
| 114 | ): Promise<ChatPostMessageResponse> { |
| 115 | return this.runTask( |
| 116 | key, |
| 117 | async (client) => { |
| 118 | try { |
| 119 | return client.chat.postMessage(params); |
| 120 | } catch (error) { |
| 121 | if (isPlatformError(error)) { |
| 122 | if (error.data.error === "not_in_channel") { |
| 123 | const joinResponse = await this.joinConversation(`Join ${params.channel}`, { |
| 124 | channel: params.channel, |
| 125 | }); |
| 126 | |
| 127 | if (joinResponse.ok) { |
| 128 | return client.chat.postMessage(params); |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | throw error; |
| 134 | } |
| 135 | }, |
| 136 | { |
| 137 | name: "Post Message", |
| 138 | params, |
| 139 | icon: "slack", |
| 140 | properties: [ |
| 141 | { |
| 142 | label: "Channel ID", |
| 143 | text: params.channel, |
| 144 | }, |
| 145 | ...(params.text ? [{ label: "Message", text: params.text }] : []), |
| 146 | ], |
| 147 | } |
| 148 | ); |
| 149 | } |
| 150 | |
| 151 | joinConversation( |
| 152 | key: IntegrationTaskKey, |
no test coverage detected