Twingate-Labs / tg-group-profile-manager

Slackbot to manage Twingate group memberships
Apache License 2.0
8 stars 2 forks source link

Sending self-approval messages in the App channel and not in a private message #15

Open ErezWeiss opened 1 week ago

ErezWeiss commented 1 week ago

HI! We use the Slack bot app's Messages page as a live audit page - to know who requests what and when. As an admin, I can see all the requests and who approved them. We expect to see a message when people in the approvers' group get their approval (=self approval). Nowadays they get a private message from the app that says:

The access request through profile 'Microservices Production Ephemeral Access'. Group: production-activities Your access will expire in 1 Hour Self Approved

We want it to be visible to the rest of the admins, means all the approvers will get a message about this self-approval. Thanks! Erez

ErezWeiss commented 1 week ago

This is my suggestion for SelfServeApproval.mjs, line 258

            // Notify all approvers about the self-approval
            const approverGroup = await profileManager.lookUpGroupUsersByName(this.approverGroup)
            for (const approver of approverGroup.users) {
                const approverSlackInfo = await client.users.lookupByEmail({email: approver.email})
                let messageString = `<@${slackUserId}> has self-approved access through profile _'${this.profileName}'_.\nGroup: ${selectedGroup}\nDuration: ${selectedTime}\nReason For Request: ${reasonForRequest}\n\`Self-Approved\``

                msgOption = {
                    channel: approverSlackInfo.user.id,
                    text: messageString,
                    blocks: [
                        {
                            type: 'section',
                            text: {
                                type: 'mrkdwn',
                                text: messageString
                            }
                        }
                    ]
                }
                await client.chat.postMessage(msgOption)
            }