Skip to content

Commit 75ba7ad

Browse files
committed
feat(org-detection): org approval reply
1 parent 6995780 commit 75ba7ad

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

src/support/slack/actions/approve-org.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,41 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
export default function approveOrg() {
14-
return async ({ ack }) => {
15-
await ack();
13+
import { Blocks, Message } from 'slack-block-builder';
14+
15+
export default function approveOrg(lambdaContext) {
16+
const { log } = lambdaContext;
17+
18+
return async ({ ack, body, respond }) => {
19+
try {
20+
const { message = {}, user } = body;
21+
const { blocks } = message;
22+
23+
log.info(JSON.stringify(body));
24+
25+
await ack(); // slack expects acknowledgement within 3s
26+
27+
const replyText = Message()
28+
.blocks(
29+
Blocks.Section()
30+
.blockId(blocks[0]?.block_id)
31+
.text(blocks[0]?.text?.text),
32+
Blocks.Section().text(`Approved by @${user.username} :checked:`),
33+
)
34+
.buildToObject();
35+
36+
const reply = {
37+
...replyText,
38+
text: blocks[0]?.text?.text,
39+
replace_original: true,
40+
};
41+
42+
log.info(`Responding site candidate ignore with: ${JSON.stringify(reply)}`);
43+
44+
await respond(reply);
45+
} catch (e) {
46+
log.error('Error occurred while acknowledging site candidate ignore', e);
47+
throw e;
48+
}
1649
};
1750
}

0 commit comments

Comments
 (0)