docbrown/app/serializers/webhook/article_serializer.rb
Andy Zhao c42fd3461e
[deploy] Rename positive_reactions_count to public_reactions_count in logic (#7926)
* Rename positive_reactions_count to public_reactions_count

* Add positive reactions count back in so we can remove it

* Use public_category method for reactions

* Add positive_reactions_count in case any old caches rely on it

* Add positive_rxn_count to account for API endpoints

* Remove unused method

* One more spot...

* Add method back in because of caches

* Update specs to match new functionality

* Fix typo

* Remove unused methods
2020-05-26 12:36:28 -04:00

36 lines
1 KiB
Ruby

module Webhook
class ArticleSerializer
include FastJsonapi::ObjectSerializer
set_type :article
attributes :title, :description, :readable_publish_date, :cached_tag_list, :cached_tag_list_array,
:slug, :path, :url, :comments_count, :public_reactions_count, :body_markdown
attribute :canonical_url, &:processed_canonical_url
attribute :body_html, &:processed_html
attribute :created_at do |a|
a.created_at.utc.iso8601
end
attribute :edited_at do |a|
a.edited_at&.utc&.iso8601
end
attribute :crossposted_at do |a|
a.crossposted_at&.utc&.iso8601
end
attribute :published_at do |a|
a.published_at&.utc&.iso8601
end
attribute :last_comment_at do |a|
a.last_comment_at&.utc&.iso8601
end
attribute :cover_image do |a|
CloudCoverUrl.new(a.url).call
end
attribute :social_image do |article|
Articles::SocialImage.new(article).url
end
attribute :user do |a|
UserSerializer.new(a.user).serializable_hash
end
end
end