move webhook and event serializers back (#899)
This commit is contained in:
parent
ed3e4780d2
commit
a9c67e70d4
4 changed files with 19 additions and 27 deletions
|
@ -1,19 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
module Api
|
|
||||||
module V2
|
|
||||||
class EventSerializer < ApplicationSerializer
|
|
||||||
attributes :id, :sequence_id, :kind, :map_id, :created_at
|
|
||||||
|
|
||||||
has_one :actor, serializer: UserSerializer, root: 'users'
|
|
||||||
has_one :map, serializer: MapSerializer
|
|
||||||
|
|
||||||
def actor
|
|
||||||
object.user || object.eventable.try(:user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def map
|
|
||||||
object.eventable.try(:map) || object.eventable.map
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
module Api
|
|
||||||
module V2
|
|
||||||
class WebhookSerializer < ApplicationSerializer
|
|
||||||
attributes :text, :username, :icon_url # , :attachments
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
15
app/serializers/event_serializer.rb
Normal file
15
app/serializers/event_serializer.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
class EventSerializer < ActiveModel::Serializer
|
||||||
|
attributes :id, :sequence_id, :kind, :map_id, :created_at
|
||||||
|
|
||||||
|
has_one :actor, serializer: Api::V2::UserSerializer, root: 'users'
|
||||||
|
has_one :map, serializer: Api::V2::MapSerializer
|
||||||
|
|
||||||
|
def actor
|
||||||
|
object.user || object.eventable.try(:user)
|
||||||
|
end
|
||||||
|
|
||||||
|
def map
|
||||||
|
object.eventable.try(:map) || object.eventable.map
|
||||||
|
end
|
||||||
|
end
|
4
app/serializers/webhook_serializer.rb
Normal file
4
app/serializers/webhook_serializer.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
class WebhookSerializer < ActiveModel::Serializer
|
||||||
|
attributes :text, :username, :icon_url # , :attachments
|
||||||
|
end
|
Loading…
Reference in a new issue