mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 08:45:47 +08:00
Remove old web hooks in favor of 'reviewable' web hook (#9776)
* FIX: Emit web hooks for flags * FEATURE: Remove 'flag' web hook in favor of 'reviewable' web hook * FEATURE: Remove 'queued post' web hook in favor of 'reviewable' web hook * FIX: Do not set a default value for web hooks with no events
This commit is contained in:
parent
3aecc1990b
commit
fb15da43da
@ -1,5 +1,4 @@
|
||||
import { get } from "@ember/object";
|
||||
import { isEmpty } from "@ember/utils";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
@ -15,7 +14,7 @@ export default DiscourseRoute.extend({
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
if (model.get("isNew") || isEmpty(model.get("web_hook_event_types"))) {
|
||||
if (model.get("isNew")) {
|
||||
model.set("web_hook_event_types", controller.get("defaultEventTypes"));
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,6 @@ class WebHookEventType < ActiveRecord::Base
|
||||
GROUP = 4
|
||||
CATEGORY = 5
|
||||
TAG = 6
|
||||
FLAG = 7
|
||||
QUEUED_POST = 8
|
||||
REVIEWABLE = 9
|
||||
NOTIFICATION = 10
|
||||
SOLVED = 11
|
||||
|
@ -3598,12 +3598,6 @@ en:
|
||||
tag_event:
|
||||
name: "Tag Event"
|
||||
details: "When a tag is created, updated or destroyed."
|
||||
flag_event:
|
||||
name: "Flag Event"
|
||||
details: "When a flag is created, agreed, disagreed or ignored."
|
||||
queued_post_event:
|
||||
name: "Post Approval Event"
|
||||
details: "When a new queued post is created, approved or rejected."
|
||||
reviewable_event:
|
||||
name: "Reviewable Event"
|
||||
details: "When a new item is ready for review and when its status is updated."
|
||||
|
@ -30,16 +30,6 @@ WebHookEventType.seed do |b|
|
||||
b.name = "tag"
|
||||
end
|
||||
|
||||
WebHookEventType.seed do |b|
|
||||
b.id = WebHookEventType::FLAG
|
||||
b.name = "flag"
|
||||
end
|
||||
|
||||
WebHookEventType.seed do |b|
|
||||
b.id = WebHookEventType::QUEUED_POST
|
||||
b.name = "queued_post"
|
||||
end
|
||||
|
||||
WebHookEventType.seed do |b|
|
||||
b.id = WebHookEventType::REVIEWABLE
|
||||
b.name = "reviewable"
|
||||
|
21
db/migrate/20200514075356_remove_flag_web_hooks.rb
Normal file
21
db/migrate/20200514075356_remove_flag_web_hooks.rb
Normal file
@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemoveFlagWebHooks < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
flag_event_type_id = 7
|
||||
|
||||
DB.exec <<~SQL
|
||||
DELETE FROM web_hook_event_types_hooks
|
||||
WHERE web_hook_event_type_id = #{flag_event_type_id}
|
||||
SQL
|
||||
|
||||
DB.exec <<~SQL
|
||||
DELETE FROM web_hook_event_types
|
||||
WHERE id = #{flag_event_type_id}
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
21
db/migrate/20200514075407_remove_queued_post_web_hooks.rb
Normal file
21
db/migrate/20200514075407_remove_queued_post_web_hooks.rb
Normal file
@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemoveQueuedPostWebHooks < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
queued_post_event_type_id = 8
|
||||
|
||||
DB.exec <<~SQL
|
||||
DELETE FROM web_hook_event_types_hooks
|
||||
WHERE web_hook_event_type_id = #{queued_post_event_type_id}
|
||||
SQL
|
||||
|
||||
DB.exec <<~SQL
|
||||
DELETE FROM web_hook_event_types
|
||||
WHERE id = #{queued_post_event_type_id}
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
@ -71,22 +71,6 @@ Fabricator(:tag_web_hook, from: :web_hook) do
|
||||
end
|
||||
end
|
||||
|
||||
Fabricator(:flag_web_hook, from: :web_hook) do
|
||||
transient flag_hook: WebHookEventType.find_by(name: 'flag')
|
||||
|
||||
after_build do |web_hook, transients|
|
||||
web_hook.web_hook_event_types = [transients[:flag_hook]]
|
||||
end
|
||||
end
|
||||
|
||||
Fabricator(:queued_post_web_hook, from: :web_hook) do
|
||||
transient queued_post_hook: WebHookEventType.find_by(name: 'queued_post')
|
||||
|
||||
after_build do |web_hook, transients|
|
||||
web_hook.web_hook_event_types = [transients[:queued_post_hook]]
|
||||
end
|
||||
end
|
||||
|
||||
Fabricator(:reviewable_web_hook, from: :web_hook) do
|
||||
transient reviewable_hook: WebHookEventType.find_by(name: 'reviewable')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user