diff options
author | Surinna Curtis <ekiru.0@gmail.com> | 2017-09-02 13:10:10 -0500 |
---|---|---|
committer | Surinna Curtis <ekiru.0@gmail.com> | 2017-09-13 21:47:30 -0500 |
commit | af2d793398343dbd171a093e521ec449aaa0579b (patch) | |
tree | c89edc9753022b5f1c003a43d598d8ee45634a41 | |
parent | 70592cdaba18f97bc4ba492445b1800033c58619 (diff) |
Define a serializer for /api/v1/mutes/details
-rw-r--r-- | app/controllers/api/v1/mutes_controller.rb | 8 | ||||
-rw-r--r-- | app/serializers/rest/mute_serializer.rb | 15 |
2 files changed, 21 insertions, 2 deletions
diff --git a/app/controllers/api/v1/mutes_controller.rb b/app/controllers/api/v1/mutes_controller.rb index 2118b4c40..92ad251ef 100644 --- a/app/controllers/api/v1/mutes_controller.rb +++ b/app/controllers/api/v1/mutes_controller.rb @@ -13,8 +13,8 @@ class Api::V1::MutesController < Api::BaseController end def details - @data = @mutes = paginated_mutes - render json: @mutes + @data = @mutes = load_mutes + render json: @mutes, each_serializer: REST::MuteSerializer end private @@ -27,6 +27,10 @@ class Api::V1::MutesController < Api::BaseController Account.includes(:muted_by).references(:muted_by) end + def load_mutes + paginated_mutes.includes(:account, :target_account).to_a + end + def paginated_mutes Mute.where(account: current_account).paginate_by_max_id( limit_param(DEFAULT_ACCOUNTS_LIMIT), diff --git a/app/serializers/rest/mute_serializer.rb b/app/serializers/rest/mute_serializer.rb new file mode 100644 index 000000000..043a2f059 --- /dev/null +++ b/app/serializers/rest/mute_serializer.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class REST::MuteSerializer < ActiveModel::Serializer + include RoutingHelper + + attributes :id, :account, :target_account, :created_at, :hide_notifications + + def account + REST::AccountSerializer.new(object.account) + end + + def target_account + REST::AccountSerializer.new(object.target_account) + end +end \ No newline at end of file |