Newer
Older
# frozen_string_literal: true
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class PostsController < ApplicationController
before_action :authenticate_user!, only: %i(destroy mentionable)
before_action :set_format_if_malformed_from_status_net, only: :show
rescue_from Diaspora::NonPublic do
end
rescue_from Diaspora::NotMine do
render plain: I18n.t("posts.show.forbidden"), status: 403
presenter = PostPresenter.new(post, current_user)
gon.post = presenter.with_initial_interactions
format.json { render json: presenter.with_interactions }
Raphael Sofaer
a validé
end
end
def oembed
post_id = OEmbedPresenter.id_from_url(params.delete(:url))
oembed = params.slice(:format, :maxheight, :minheight)
render json: OEmbedPresenter.new(post, oembed)
rescue
def mentionable
respond_to do |format|
format.json {
if params[:id].present? && params[:q].present?
render json: post_service.mentionable_in_comment(params[:id], params[:q])
else
format.any { head :not_acceptable }
end
rescue ActiveRecord::RecordNotFound
format.json { head :no_content }
def post_service
@post_service ||= PostService.new(current_user)
end
def set_format_if_malformed_from_status_net
request.format = :html if request.format == "application/html+xml"
Maxwell Salzberg
a validé
end