pymedusa / Medusa

Automatic Video Library Manager for TV Shows. It watches for new episodes of your favorite shows, and when they are posted it does its magic.
https://pymedusa.com
GNU General Public License v3.0
1.74k stars 271 forks source link

Slack Notifications (to RocketChat) are no longer working #11642

Open LeeThompson opened 4 months ago

LeeThompson commented 4 months ago

Describe the bug I have been using RocketChat for a few years with Medusa sending notifications to it via the "Slack" notification service (the webhooks are interchangeable) but recently, Medusa puts this in the log (and nothing else):

2024-02-29 17:13:31 WARNING Thread :: [e094759] The webhook URL (REDACTED) you provided is not valid

To Reproduce Steps to reproduce the behavior:

  1. Create an incoming webhook in RocketChat, ensure it's Enabled
  2. In Medusa under notifications/social add Slack notifications using the webhook from step 1.
  3. Save and click "Test Slack"

Expected behavior It used to work, it would be nice if it worked again; or at least gave an error or something I could troubleshoot with.

Medusa (please complete the following information):

Debug logs (at least 50 lines):

`2024-02-29 17:22:06 WARNING Thread :: [e094759] The webhook URL (REDACTED) you provided is not valid`

Additional context I've tried generating a new webhook, changing the URL to refer to the rocketchat host by IP address, etc, no changes. Slack webhooks with RocketChat continue to work with Mylar, Radarr and other applications. If only Medusa would actually indicate what the issue is...

medariox commented 4 months ago

What does the webhook URL look like (remove the sensitive parts)?

LeeThompson commented 4 months ago

I've randomized the sensitive bits. NOTE: I've tried with and without a trailing /

http://rocketchat.abc.defg.hij:3000/hooks/56305c4ab173e84efb916e6c/jRpTnrtGnBErdTmbkMwMbbyoSMknGiy4JyqcSxWBR373Z2R4

medariox commented 4 months ago

Webhook URLs need to be validated for security reasons, see: https://github.com/pymedusa/Medusa/pull/11565 What is the Webhook pattern we need to support for Rocketchat?

LeeThompson commented 4 months ago

(from the PR) WEBHOOK_PATTERN = r'https://hooks\.slack\.com/services/.*' This definitely isn't going to work with RocketChat since it can be self-hosted (as it is in my case) so it will never be on slack.com

I'm not familiar with the Python RegEx syntax but it's basically http or https:// with a host.domain (with optional port) and then /hooks/' and the token which is generated, here is one I generated for an example (it's a real one that I'm deleting right away)65e1f75c00ab53363395d0aa/2yXaxN6k566kPLAvmsKxeSE4L6mxLfzgi6GKovaSC2kE7GJk`

https://rocketchat.domain/hooks/65e1f75c00ab53363395d0aa/2yXaxN6k566kPLAvmsKxeSE4L6mxLfzgi6GKovaSC2kE7GJk
http://rocketchat.domain:port/hooks/65e1f75c00ab53363395d0aa/2yXaxN6k566kPLAvmsKxeSE4L6mxLfzgi6GKovaSC2kE7GJk

Docs on RocketChat integrations, message syntax can be identical to Slack's but it also supports additional features. https://docs.rocket.chat/use-rocket.chat/workspace-administration/integrations

medariox commented 4 months ago

I think the best solution is to add a domain whitelist for the webhook requests. I will get to it when I have some time or maybe someone else can pick this up and submit a PR.