DEV: Update Discord webhook domain (#106)

discordapp.com is being deprecated and replaced with discord.com - https://github.com/discord/discord-api-docs/discussions/4510
This commit is contained in:
David Taylor
2022-02-15 11:53:53 +00:00
committed by GitHub
parent ddee0c4417
commit 36087f3004
3 changed files with 25 additions and 6 deletions
@@ -0,0 +1,19 @@
# frozen_string_literal: true
class UpdateDiscordWebhookDomains < ActiveRecord::Migration[6.1]
def up
execute <<~SQL
UPDATE plugin_store_rows psr
SET value = REPLACE(value, 'discordapp.com', 'discord.com')
WHERE psr.plugin_name = 'discourse-chat-integration'
AND psr.key LIKE 'channel:%'
AND psr.type_name = 'JSON'
AND psr.value::json ->> 'provider' = 'discord'
AND psr.value::json ->> 'data' LIKE '%https://discordapp.com/%'
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end