reallyreally / discourse-mailgun

A plugin for Discourse to accept inbound email from a Mailgun webhook
Apache License 2.0
5 stars 9 forks source link

Update for Discourse v2.x #2

Closed jeffbyrnes closed 4 years ago

jeffbyrnes commented 5 years ago

This updates the plugin to work with Discourse v2.x, and cleans up some now-unused config settings as well.

Fixes #1

jeffbyrnes commented 5 years ago

@halkeye yeah it seemed like it would work, and I figured, with the extra few tweaks to clean up the config, it might be nice to kick it back up to the original.

Unfortunately, it seems that the /mailgun/incoming route isn’t added properly (anymore?), so it doesn’t quite work.

Any suggestions?

halkeye commented 5 years ago

I haven't used it in a while, but how are you checking. I can check my install when I get home.

jeffbyrnes commented 5 years ago

So yeah, when I try to add the route to Mailgun, it errors out & says that the forward URL “needs to be publicly accessible”.

When I attempt to curl https://$my_domain/mailgun/incoming, I get a 404. So something is a little different with Discourse, maybe? I’m running Discourse 2.4.0.beta1 (discourse/discourse@4f97f85178b197e99240b3b7f2c2c0c251d4c39b)

halkeye commented 5 years ago

Try curl -X post instead of just curl. I don't think it's exposed on get. Also is your domain publically accessible?

halkeye commented 5 years ago
 (ssh) odin  ~  curl -X POST https://discourse.gavinmogan.com/mailgun/incoming -v 2>&1 | grep HTTP
> POST /mailgun/incoming HTTP/1.1
< HTTP/1.1 401 Unauthorized

 (ssh) odin  ~  curl https://discourse.gavinmogan.com/mailgun/incoming -v 2>&1 | grep HTTP
> GET /mailgun/incoming HTTP/1.1
< HTTP/1.1 404 Not Found
/bin/sh -- -c 'cd /var/www/discourse; rails routes | grep mailgun -i'
                           webhooks_mailgun POST     /webhooks/mailgun(.:format)                                                                   webhooks#mailgun
                          discourse_mailgun          /mailgun                                                                                      DiscourseMailgun::Engine
Routes for DiscourseMailgun::Engine:
incoming POST /incoming(.:format) discourse_mailgun/mailgun#incoming
Time: 0h:00m:04s
jeffbyrnes commented 5 years ago

Heh, yah, POST-ing did the trick; and I forgot about rails routes, thanks for the reminder! Been a while since I dealt with Rails so directly :)

So yeah, the route is there, and I’ve got it all working on my Discourse setup!

So this PR is all good & validated as working.