Skip to content

Make events key case insensitive #17

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

Closed
wants to merge 1 commit into from
Closed

Make events key case insensitive #17

wants to merge 1 commit into from

Conversation

paulhennell
Copy link
Contributor

So mailgun appears to be insane and mixes their event names in upper and lowercase. 🤢

For example the event type "clicked" and "opened" are sent as "CLICKED" and "OPENED" while "delivered" and "failed" are just "delivered" and "failed".

This doesn't appear to be clear in mailgun docs or mentioned in the docs here, but the config file is case sensitive so you need the same case as the mailgun event to call the right job type:

        'delivered' => \App\Jobs\Mailgun\HandleDelivered::class,
        'CLICKED' => \App\Jobs\Mailgun\HandleClicks::class,
        'complained' => \App\Jobs\Mailgun\HandleComplaints::class,

Rather then this project trying to advise on what mailgun's current events are, and which case they should be referenced in, this PR sets a fallback event type to use a lowercase version of the event name.

So both the above config and the more natural setup below will work:

        'delivered' => \App\Jobs\Mailgun\HandleDelivered::class,
        'clicked' => \App\Jobs\Mailgun\HandleClicks::class,
        'complained' => \App\Jobs\Mailgun\HandleComplaints::class,

The fallback is a little ugly, but it should avoid breaking changes where people are using the uppercase, but allows others to use lowercase rather then go mad wondering why the one event doesn't work!

Explicitly check for lowercase versions of an event-type.
@paulhennell
Copy link
Contributor Author

So fun fact: mailgun's test webhooks are in capitals. Presumably the real life ones are not, as OPEN, CLICKED etc only worked when changing the config file to use lowercase for real events. 😡

I guess this actually means the fallback isn't really needed - if you have capitals your hooks only work with the testing events, anything live would be in lowercase. So a cleaner config("mailgun-webhooks.jobs.{$jobConfigKey_lower} would be enough, and all configs would have to be in lowercase to work.

Going to go take this argument to mailgun now as what's the benefit of a test system that's different?

@cyrillkalita
Copy link
Member

Addresses, if slightly differently: see 9.0 release notes

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.

2 participants