gab-social/app/serializers/rest/group_serializer.rb

26 lines
591 B
Ruby
Raw Normal View History

2019-07-02 08:10:25 +01:00
# frozen_string_literal: true
class REST::GroupSerializer < ActiveModel::Serializer
include RoutingHelper
2020-04-28 06:33:58 +01:00
attributes :id, :title, :description, :cover_image_url, :is_archived, :member_count, :created_at
2019-07-02 08:10:25 +01:00
def id
object.id.to_s
end
2019-07-15 14:47:05 +01:00
def clean_migrated_url
object
.cover_image_file_name
.sub("gab://groups/", "https://gab.com/media/user/")
end
2019-07-02 08:10:25 +01:00
def cover_image_url
2019-07-15 14:47:05 +01:00
if object.cover_image_file_name and object.cover_image_file_name.start_with? "gab://groups/"
return clean_migrated_url
end
2019-07-02 08:10:25 +01:00
full_asset_url(object.cover_image.url)
end
end