app/controllers/federails/server/activities_controller.rb in federails-0.1.0 vs app/controllers/federails/server/activities_controller.rb in federails-0.2.0
- old
+ new
@@ -6,11 +6,11 @@
before_action :set_activity, only: [:show]
# GET /federation/activities
# GET /federation/actors/1/outbox.json
def outbox
- @actor = Actor.find(params[:actor_id])
+ @actor = Actor.find_param(params[:actor_id])
@activities = policy_scope(Federails::Activity, policy_scope_class: Federails::Server::ActivityPolicy::Scope).where(actor: @actor).order(created_at: :desc)
@total_activities = @activities.count
@activities = @activities.page(params[:page])
end
@@ -18,23 +18,23 @@
def show; end
# POST /federation/actors/1/inbox
def create
payload = payload_from_params
- return render json: {}, status: :unprocessable_entity unless payload
+ return head :unprocessable_entity unless payload
if Fediverse::Inbox.dispatch_request(payload)
- render json: {}, status: :created
+ head :created
else
- render json: {}, status: :unprocessable_entity
+ head :unprocessable_entity
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_activity
- @activity = Activity.find_by!(actor_id: params[:actor_id], id: params[:id])
+ @activity = Actor.find_param(params[:actor_id]).activities.find_param(params[:id])
end
# Only allow a list of trusted parameters through.
def activity_params
params.fetch(:activity, {})