2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-04 01:15:08 +08:00
discourse/app/serializers/admin_web_hook_serializer.rb
Natalie Tay 69af7d62ae
FIX: Allow selecting tags when creating or editing webhooks (#37942)
Commit 9e99066b07 changed TagChooser to pass tag objects instead of tag
name strings, but the webhook model sends these objects directly to the
backend, where `permit(tag_names: [])` silently stripped the non-scalar
values, so no tags were saved.

We'll still be taking in `tag_names` on the API, with a deprecation
note. The frontend should start sending `tag_ids` which is the new way
forward.

<img width="351" height="156" alt="Screenshot 2026-02-20 at 4 10 58 PM"
src="https://github.com/user-attachments/assets/9afb6fbe-d676-43d4-a0ff-29cbc1bcd377"
/>

meta:
https://meta.discourse.org/t/webhook-not-accepting-private-tags/396521
2026-02-20 23:00:50 +08:00

24 lines
801 B
Ruby

# frozen_string_literal: true
class AdminWebHookSerializer < ApplicationSerializer
attributes :id,
:payload_url,
:content_type,
:last_delivery_status,
:secret,
:wildcard_web_hook,
:verify_certificate,
:active
has_many :categories, serializer: BasicCategorySerializer, embed: :ids, include: true
has_many :tags, serializer: TagSerializer, embed: :objects
has_many :groups, serializer: BasicGroupSerializer, embed: :ids, include: false
has_many :web_hook_event_types,
serializer: WebHookEventTypeSerializer,
root: false,
embed: :objects
def last_delivery_status
object.active ? object.last_delivery_status : WebHook.last_delivery_statuses[:disabled]
end
end