Skip to content

Conversation

artcz
Copy link
Contributor

@artcz artcz commented Jan 26, 2025

Initial version of routing discord messages to different channels depending on the details of the github webhook.
Designed to be extendible with different types/sources of webhooks.

It's still a little bit WiP, but the tests are passing.

@artcz artcz self-assigned this Jan 26, 2025
@artcz artcz requested review from cybit and egeakman January 26, 2025 21:36
Copy link
Member

@egeakman egeakman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the previous comment, nothing catches my eye. I didn't go through the code line by line though.

else:
warnings.warn(f"{name} not set")

return value or ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bot hard for me to understand. Can we make it a bit easier for novices to get the logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll think about this. I'll leave it as-is for now, but there is probably a better way of doing it.
The gist is that on prod we want to force all of those, in other environments they are optional.
I totally agree that there must be a better way to do it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crazy idea:
(Data)classes with inheritance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For environments, or for individual settings?

Comment on lines +152 to +153
DISCORD_EP2025_CHANNEL_ID = get("DISCORD_EP2025_CHANNEL_ID")
DISCORD_EP2025_CHANNEL_NAME = get("DISCORD_EP2025_CHANNEL_NAME")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please not fix this on 2025? But in a general "organisers" channel or "current conference" channel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to keep it explicit :) I would actually think those are mostly constant and won't change, so in the future instead of changing settings for current/future conf, we just update the code and have another 1:1 mapping from project ID to channel ID. (and optionally delete old ones or just keep them around unused)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about it the less I like the hardcoded part.
It should be some kind of extracted config structure that allows the allocation.
{ "channel_type" : {"name" : "", "discord_id" : 000, "github_id" : [00, 01]}}
(And I am pretty sure that the order in my example is the wrong one.)

GITHUB_EP2025_PROJECT_ID = get("GITHUB_EP2025_PROJECT_ID")
GITHUB_EM_PROJECT_ID = get("GITHUB_EM_PROJECT_ID")

if DJANGO_ENV == "dev":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there no DJANGO_ENV prod needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... it is – as in, if we want to deploy on prod they need to be provided. If you want to run tests they are still needed - but overwritten below in the if DJANGO_ENV == test section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you see — makes it hard for me to understand.
There should probably some kind of check around here that tells me that I forgot to inject something in PROD.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a check – on prod it will just not start unless you provide everything. On dev it will start but emit a warning in the console.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rereading the original comment now – I think there might be some confusion that there is no setup for prod – there is one, but it already existed before so it's outside of this diff. :)

else:
warnings.warn(f"{name} not set")

return value or ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crazy idea:
(Data)classes with inheritance?

Comment on lines +152 to +153
DISCORD_EP2025_CHANNEL_ID = get("DISCORD_EP2025_CHANNEL_ID")
DISCORD_EP2025_CHANNEL_NAME = get("DISCORD_EP2025_CHANNEL_NAME")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about it the less I like the hardcoded part.
It should be some kind of extracted config structure that allows the allocation.
{ "channel_type" : {"name" : "", "discord_id" : 000, "github_id" : [00, 01]}}
(And I am pretty sure that the order in my example is the wrong one.)

GITHUB_EP2025_PROJECT_ID = get("GITHUB_EP2025_PROJECT_ID")
GITHUB_EM_PROJECT_ID = get("GITHUB_EM_PROJECT_ID")

if DJANGO_ENV == "dev":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you see — makes it hard for me to understand.
There should probably some kind of check around here that tells me that I forgot to inject something in PROD.

@artcz artcz merged commit bfe9f81 into main Feb 5, 2025
2 checks passed
@artcz artcz deleted the feature/discord-channel-router branch February 5, 2025 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants