forked from GithubBackups/healthchecks
Updated Discord integration to use discord.com instead of discordapp.com
This commit is contained in:
parent
f814035f03
commit
589c0c0363
@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Indicate a started check with a progress spinner under status icon (#338)
|
- Indicate a started check with a progress spinner under status icon (#338)
|
||||||
- Added "Docs > Reliability Tips" page
|
- Added "Docs > Reliability Tips" page
|
||||||
- Spike.sh integration (#402)
|
- Spike.sh integration (#402)
|
||||||
|
- Updated Discord integration to use discord.com instead of discordapp.com
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
- Removing Pager Team integration, project appears to be discontinued
|
- Removing Pager Team integration, project appears to be discontinued
|
||||||
|
@ -585,7 +585,14 @@ class Channel(models.Model):
|
|||||||
def discord_webhook_url(self):
|
def discord_webhook_url(self):
|
||||||
assert self.kind == "discord"
|
assert self.kind == "discord"
|
||||||
doc = json.loads(self.value)
|
doc = json.loads(self.value)
|
||||||
return doc["webhook"]["url"]
|
url = doc["webhook"]["url"]
|
||||||
|
|
||||||
|
# Discord migrated to discord.com,
|
||||||
|
# and is dropping support for discordapp.com on 7 November 2020
|
||||||
|
if url.startswith("https://discordapp.com/"):
|
||||||
|
url = "https://discord.com/" + url[23:]
|
||||||
|
|
||||||
|
return url
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def discord_webhook_id(self):
|
def discord_webhook_id(self):
|
||||||
|
@ -569,6 +569,22 @@ class NotifyTestCase(BaseTestCase):
|
|||||||
fields = {f["title"]: f["value"] for f in attachment["fields"]}
|
fields = {f["title"]: f["value"] for f in attachment["fields"]}
|
||||||
self.assertEqual(fields["Last Ping"], "an hour ago")
|
self.assertEqual(fields["Last Ping"], "an hour ago")
|
||||||
|
|
||||||
|
@patch("hc.api.transports.requests.request")
|
||||||
|
def test_discord_rewrites_discordapp_com(self, mock_post):
|
||||||
|
v = json.dumps({"webhook": {"url": "https://discordapp.com/foo"}})
|
||||||
|
self._setup_data("discord", v)
|
||||||
|
mock_post.return_value.status_code = 200
|
||||||
|
|
||||||
|
self.channel.notify(self.check)
|
||||||
|
assert Notification.objects.count() == 1
|
||||||
|
|
||||||
|
args, kwargs = mock_post.call_args
|
||||||
|
url = args[1]
|
||||||
|
|
||||||
|
# discordapp.com is deprecated. For existing webhook URLs, wwe should
|
||||||
|
# rewrite discordapp.com to discord.com:
|
||||||
|
self.assertEqual(url, "https://discord.com/foo/slack")
|
||||||
|
|
||||||
@patch("hc.api.transports.requests.request")
|
@patch("hc.api.transports.requests.request")
|
||||||
def test_pushbullet(self, mock_post):
|
def test_pushbullet(self, mock_post):
|
||||||
self._setup_data("pushbullet", "fake-token")
|
self._setup_data("pushbullet", "fake-token")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user