diff --git a/app/blueprints/api/v1/party_blueprint.rb b/app/blueprints/api/v1/party_blueprint.rb index 395b699..2e8df6b 100644 --- a/app/blueprints/api/v1/party_blueprint.rb +++ b/app/blueprints/api/v1/party_blueprint.rb @@ -52,6 +52,21 @@ module Api include_view :nested_objects # Characters, Weapons, Summons include_view :remix_metadata # Remixes, Source party include_view :job_metadata # Accessory, Skills, Guidebooks + + # Shares (only visible to owner) + field :shares, if: ->(_field_name, party, options) { + options[:current_user] && party.user_id == options[:current_user].id + } do |party| + party.party_shares.includes(:shareable).map do |share| + { + id: share.id, + shareable_type: share.shareable_type.downcase, + shareable_id: share.shareable_id, + shareable_name: share.shareable.try(:name), + created_at: share.created_at + } + end + end end # Primary object associations diff --git a/app/controllers/api/v1/parties_controller.rb b/app/controllers/api/v1/parties_controller.rb index 795377e..d9fa825 100644 --- a/app/controllers/api/v1/parties_controller.rb +++ b/app/controllers/api/v1/parties_controller.rb @@ -64,7 +64,7 @@ module Api end if @party - render json: PartyBlueprint.render(@party, view: :full, root: :party) + render json: PartyBlueprint.render(@party, view: :full, root: :party, current_user: current_user) else render_not_found_response('project') end