diaspora_federation/app/controllers/diaspora_federation/receive_controller.rb
Benjamin Neff 8a8678c97b
Disable forgery protection for ReceiveController
This is enabled by default since rails 5.2, but it doesn't make sense
for the /receive/ routes, because they are called without a session and
without a token.
2022-07-23 02:15:53 +02:00

34 lines
803 B
Ruby

# frozen_string_literal: true
require_dependency "diaspora_federation/application_controller"
module DiasporaFederation
# This controller processes receiving messages.
class ReceiveController < ApplicationController
skip_forgery_protection
# Receives public messages
#
# POST /receive/public
def public
data = request.body.read
logger.debug data
DiasporaFederation.callbacks.trigger(:queue_public_receive, data)
head :accepted
end
# Receives private messages for a user
#
# POST /receive/users/:guid
def private
data = request.body.read
logger.debug data
success = DiasporaFederation.callbacks.trigger(:queue_private_receive, params[:guid], data)
head success ? :accepted : :not_found
end
end
end