-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8dc80b
commit 9dbd59d
Showing
4 changed files
with
137 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from typing import Any, Callable | ||
from slack_sdk import WebClient | ||
|
||
from utils.env import env | ||
|
||
|
||
def handle_reject_event_view(ack: Callable, body: dict[str, Any], client: WebClient): | ||
ack() | ||
view = body["view"] | ||
message = view["state"]["values"]["message"]["message"]["rich_text_value"] | ||
event_id = view["private_metadata"] | ||
|
||
event = env.airtable.get_event(event_id) | ||
|
||
if not event: | ||
client.chat_postEphemeral( | ||
user=body["user"]["id"], | ||
channel=body["user"]["id"], | ||
text=f"Event with id `{event_id}` not found.", | ||
) | ||
return | ||
|
||
if event["fields"].get("Canceled", False): | ||
client.chat_postEphemeral( | ||
user=body["user"]["id"], | ||
channel=body["user"]["id"], | ||
text=f"Event with id `{event_id}` has already been rejected.", | ||
) | ||
return | ||
|
||
event = env.airtable.update_event(event_id, **{"Canceled": True}) | ||
|
||
client.chat_postMessage( | ||
channel=env.slack_approval_channel, | ||
text=f"<@{body['user']['id']}> rejected {event['fields']['Title']} for <@{event['fields']['Leader Slack ID']}> with the following reason.", | ||
blocks=[ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": f"<@{body['user']['id']}> rejected {event['fields']['Title']} for <@{event['fields']['Leader Slack ID']}> with the following reason." | ||
} | ||
}, { | ||
"type": "divider", | ||
}, | ||
message | ||
] | ||
) | ||
|
||
client.chat_postMessage( | ||
channel=event["fields"]["Leader Slack ID"], | ||
text=f"Your event {event['fields']['Title']} has been rejected by <@{body['user']['id']}> with the following reason. Please reach out to them if you have any questions or need help.", | ||
blocks=[ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": f"Your event {event['fields']['Title']} has been rejected by <@{body['user']['id']}> :(\nPlease reach out to them if you have any questions or need help." | ||
} | ||
}, { | ||
"type": "divider", | ||
}, | ||
message | ||
] | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from utils.env import env | ||
|
||
def get_reject_event_modal(event_id: str): | ||
event = env.airtable.get_event(event_id) | ||
if not event: | ||
return { | ||
"type": "modal", | ||
"title": { | ||
"type": "plain_text", | ||
"text": "Error", | ||
"emoji": True | ||
}, | ||
"close": { | ||
"type": "plain_text", | ||
"text": "Close", | ||
"emoji": True | ||
}, | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": f"Event with id `{event_id}` not found." | ||
} | ||
} | ||
] | ||
} | ||
return { | ||
"type": "modal", | ||
"callback_id": "reject_event", | ||
"title": { | ||
"type": "plain_text", | ||
"text": "Reject Event", | ||
"emoji": True | ||
}, | ||
"submit": { | ||
"type": "plain_text", | ||
"text": "Reject", | ||
"emoji": True | ||
}, | ||
"close": { | ||
"type": "plain_text", | ||
"text": "Cancel", | ||
"emoji": True | ||
}, | ||
"blocks": [ | ||
{ | ||
"type": "input", | ||
"block_id": "message", | ||
"element": { | ||
"type": "rich_text_input", | ||
"action_id": "message" | ||
}, | ||
"label": { | ||
"type": "plain_text", | ||
"text": f"Why are you rejecting \"{event['fields']['Title']}\"?", | ||
"emoji": True | ||
} | ||
} | ||
], | ||
"private_metadata": event_id | ||
} |