Skip to content

Commit

Permalink
fixing an issue with multiple selfserveapproval does not work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
chenbishop committed Dec 21, 2022
1 parent 1177a0d commit 663749d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions profileFlows/SelfServeApproval.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export class SelfServeApproval extends BaseProfile {
const expiry = this.durationParser(Math.round(Date.now()/1000), selectedTime)

const request = {
requestedProfile: this.profileName,
approverSlackId: slackUserId,
requesterTwingateId: tgUser.id,
requesterEmail: tgUser.email,
Expand Down Expand Up @@ -465,6 +466,7 @@ export class SelfServeApproval extends BaseProfile {
let expiry = "Forever"
if (request.selectedTime !== "Forever") {
request.approverSlackId = body.user.id
request.requestedProfile = this.profileName
expiry = this.durationParser(Math.round(body.message.ts), request.selectedTime)
await client.chat.scheduleMessage({
// await client.chat.postMessage({
Expand Down Expand Up @@ -526,6 +528,11 @@ export class SelfServeApproval extends BaseProfile {
}

async scheduledMessageTrigger({event, client, body, context, ack, logger}) {
const request = JSON.parse(event.text.replace("#Scheduled Message Trigger#", ""))

// skip if not the profile
if (request.requestedProfile !== this.profileName) return

const botInfo = await client.auth.test()

// confirm the message was sent by the same bot user
Expand All @@ -534,8 +541,6 @@ export class SelfServeApproval extends BaseProfile {
return
}

const request = JSON.parse(event.text.replace("#Scheduled Message Trigger#", ""))

// remove user from group through twingate API
const profileManager = new SlackProfileManager()
await profileManager.removeUserFromGroup(request.requestedGroupId, request.requesterTwingateId)
Expand Down

0 comments on commit 663749d

Please sign in to comment.