Skip to content

Commit

Permalink
Merge branch 'main' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
minkhantkyaw35 committed Feb 18, 2025
2 parents e4140ad + ee50894 commit 9cb0f07
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions app/serializers/api/v1/channel_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class Api::V1::ChannelSerializer
end

attribute :follower do |object|
object.community_admins.last.account.follower_count
object&.community_admins&.last&.account&.follower_count
end

attribute :admin_following_count do |object|
object.community_admins.last.account.following_ids.count
object&.community_admins&.last&.account&.following_ids&.count
end

attribute :no_of_admins do |object|
Expand All @@ -42,4 +42,25 @@ class Api::V1::ChannelSerializer
params[:current_account] ? JoinedCommunity.exists?(patchwork_community_id: object.id, account_id: params[:current_account]['id']) : false
end

attribute :community_admin do |object|
community_admin = object&.community_admins&.first
community_admin ? {
id: community_admin.id,
username: community_admin&.account&.username ? "@#{community_admin&.account&.username}@#{self.default_domain}" : "",
} : {}
end

private

def self.default_domain
case ENV.fetch('RAILS_ENV', nil)
when 'staging'
'staging.patchwork.online'
when 'production'
'channel.org'
else
'localhost.3000'
end
end

end

0 comments on commit 9cb0f07

Please sign in to comment.