Files
once-campfire/app/controllers/messages/by_bots_controller.rb
Kevin McConnell df76a227dc Hello world
First open source release of Campfire 🎉
2025-08-21 09:31:59 +01:00

25 lines
471 B
Ruby

class Messages::ByBotsController < MessagesController
allow_bot_access only: :create
def create
super
head :created, location: message_url(@message)
end
private
def message_params
if params[:attachment]
params.permit(:attachment)
else
reading(request.body) { |body| { body: body } }
end
end
def reading(io)
io.rewind
yield io.read.force_encoding("UTF-8")
ensure
io.rewind
end
end