mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-02-21 20:20:34 +09:00
25 lines
471 B
Ruby
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
|