Skip to content

Commit d755e3f

Browse files
committed
Fix mentor volunteer invite
1 parent 041d77d commit d755e3f

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

pybot/endpoints/slack/actions/mentor_volunteer.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
from enum import IntEnum
1+
import logging
22

33
from sirbot import SirBot
44
from slack import methods
55
from slack.actions import Action
6+
from slack.exceptions import SlackAPIError
67

78
from pybot.endpoints.slack.message_templates.mentor_volunteer import MentorVolunteer
89
from pybot.endpoints.slack.utils import MENTOR_CHANNEL
910

10-
11-
class VolunteerBlockIndex(IntEnum):
12-
SKILLSET_OPTIONS = 2
13-
SELECTED_SKILLSETS = 3
14-
SUBMIT = 5
11+
logger = logging.getLogger(__name__)
1512

1613

1714
async def add_volunteer_skillset(action: Action, app: SirBot) -> None:
@@ -37,7 +34,6 @@ async def submit_mentor_volunteer(action: Action, app: SirBot) -> None:
3734
slack = app.plugins["slack"].api
3835
admin_slack = app.plugins["admin_slack"].api
3936
airtable = app.plugins["airtable"].api
40-
bot_user_id = action["user"]["id"]
4137

4238
request = MentorVolunteer(action)
4339

@@ -58,13 +54,14 @@ async def submit_mentor_volunteer(action: Action, app: SirBot) -> None:
5854
request.airtable_error(airtable_response)
5955
else:
6056

61-
# checks if the user submitting the form owns the admin token used for the bot
62-
# stops an exception being being raised if a user tries to invite themselves to a channel
63-
if bot_user_id != user_id:
57+
try:
6458
await admin_slack.query(
6559
methods.CONVERSATIONS_INVITE,
6660
{"channel": MENTOR_CHANNEL, "users": [user_id]},
6761
)
62+
except SlackAPIError as error:
63+
logger.debug("Error during mentor channel invite %s", error.data["errors"])
64+
6865
request.on_submit_success()
6966

7067
await request.update_message(slack)

0 commit comments

Comments
 (0)