Skip to content

Fix invalid role configuration #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions prod-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pretix_cache_file = "pretix_cache.json"
"Personal" = ["Participants", "Onsite Participants"]
"Education" = ["Participants", "Onsite Participants"]
"Community Contributors" = ["Participants", "Onsite Participants"]
"Grant ticket" = ["PARTICIPANTS", "Onsite Participants"]
"Grant ticket" = ["Participants", "Onsite Participants"]
# remote participants
"Remote Participation Ticket" = ["Participants", "Remote Participants"]
"Remote Grant ticket" = ["Participants", "Remote Participants"]
Expand All @@ -27,7 +27,7 @@ pretix_cache_file = "pretix_cache.json"
"Presenter" = ["Participants", "Onsite Participants", "Speakers"]

[registration.variation_to_roles]
"Volunteer" = ["Volunteers"]
"Volunteer" = ["Volunteers", "Onsite Volunteers"]

[program_notifications]
# UTC offset in hours (e.g. 2 for CEST)
Expand Down
6 changes: 6 additions & 0 deletions src/europython_discord/registration/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ async def on_submit(self, interaction: discord.Interaction) -> None:
await interaction.user.edit(nick=nickname)

roles = [discord_get(interaction.guild.roles, name=role_name) for role_name in role_names]
if any(role is None for role in roles):
await self.log_error_to_user(interaction, "Internal error, please contact us.")
await self.log_error_to_channel(interaction, f"Found invalid role in {role_names}")
_logger.error("At least one of the role names %s is invalid", role_names)
return

_logger.info("Assigning %r role_names=%r", name, role_names)
await interaction.user.add_roles(*roles)

Expand Down
4 changes: 2 additions & 2 deletions test-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pretix_cache_file = "pretix_cache.json"
"Personal" = ["Participants", "Onsite Participants"]
"Education" = ["Participants", "Onsite Participants"]
"Community Contributors" = ["Participants", "Onsite Participants"]
"Grant ticket" = ["PARTICIPANTS", "Onsite Participants"]
"Grant ticket" = ["Participants", "Onsite Participants"]
# remote participants
"Remote Participation Ticket" = ["Participants", "Remote Participants"]
"Remote Grant ticket" = ["Participants", "Remote Participants"]
Expand All @@ -27,7 +27,7 @@ pretix_cache_file = "pretix_cache.json"
"Presenter" = ["Participants", "Onsite Participants", "Speakers"]

[registration.variation_to_roles]
"Volunteer" = ["Volunteers"]
"Volunteer" = ["Volunteers", "Onsite Volunteers"]

[program_notifications]
# UTC offset in hours (e.g. 2 for CEST)
Expand Down