Progress
This commit is contained in:
@@ -49,6 +49,7 @@ class AccountsController < ReactController
|
||||
statuses.merge!(hashtag_scope) if tag_requested?
|
||||
statuses.merge!(only_media_scope) if media_requested?
|
||||
statuses.merge!(no_replies_scope) unless replies_requested?
|
||||
statuses.merge!(only_replies_scope) unless comments_only_requested?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,6 +69,10 @@ class AccountsController < ReactController
|
||||
Status.without_replies
|
||||
end
|
||||
|
||||
def only_replies_scope
|
||||
Status.only_replies
|
||||
end
|
||||
|
||||
def hashtag_scope
|
||||
tag = Tag.find_normalized(params[:tag])
|
||||
|
||||
@@ -97,6 +102,8 @@ class AccountsController < ReactController
|
||||
short_account_media_url(@account, max_id: max_id, min_id: min_id)
|
||||
elsif replies_requested?
|
||||
short_account_with_replies_url(@account, max_id: max_id, min_id: min_id)
|
||||
elsif comments_only_requested?
|
||||
short_account_comments_only_url(@account, max_id: max_id, min_id: min_id)
|
||||
else
|
||||
short_account_url(@account, max_id: max_id, min_id: min_id)
|
||||
end
|
||||
@@ -110,6 +117,10 @@ class AccountsController < ReactController
|
||||
request.path.ends_with?('/with_replies')
|
||||
end
|
||||
|
||||
def comments_only_requested?
|
||||
request.path.ends_with?('/comments_only')
|
||||
end
|
||||
|
||||
def tag_requested?
|
||||
request.path.ends_with?(Addressable::URI.parse("/tagged/#{params[:tag]}").normalize)
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
class Api::V1::AccountByUsernameController < Api::BaseController
|
||||
before_action :set_account
|
||||
before_action :check_account_suspension
|
||||
before_action :check_account_local
|
||||
|
||||
respond_to :json
|
||||
|
||||
@@ -17,4 +18,9 @@ class Api::V1::AccountByUsernameController < Api::BaseController
|
||||
def check_account_suspension
|
||||
gone if @account.suspended?
|
||||
end
|
||||
|
||||
# if not our domain don't display
|
||||
def check_account_local
|
||||
gone unless @account.local?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,6 +32,7 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||
|
||||
statuses.merge!(only_media_scope) if truthy_param?(:only_media)
|
||||
statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies)
|
||||
statuses.merge!(only_replies_scope) if truthy_param?(:only_comments)
|
||||
statuses.merge!(no_reblogs_scope) if truthy_param?(:exclude_reblogs)
|
||||
statuses.merge!(hashtag_scope) if params[:tagged].present?
|
||||
|
||||
@@ -64,6 +65,10 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||
Status.without_replies
|
||||
end
|
||||
|
||||
def only_replies_scope
|
||||
Status.only_replies
|
||||
end
|
||||
|
||||
def no_reblogs_scope
|
||||
Status.without_reblogs
|
||||
end
|
||||
@@ -79,7 +84,7 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||
end
|
||||
|
||||
def pagination_params(core_params)
|
||||
params.slice(:limit, :only_media, :exclude_replies).permit(:limit, :only_media, :exclude_replies).merge(core_params)
|
||||
params.slice(:limit, :only_media, :exclude_replies, :only_comments).permit(:limit, :only_media, :exclude_replies, :only_comments).merge(core_params)
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
|
||||
@@ -1,14 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::GifsController < Api::BaseController
|
||||
before_action :require_user!
|
||||
|
||||
respond_to :json
|
||||
|
||||
skip_before_action :set_cache_headers
|
||||
|
||||
def index
|
||||
def categories
|
||||
uri = URI('https://api.tenor.com/v1/categories')
|
||||
params = { :key => "QHFJ0C5EWGBH" }
|
||||
uri.query = URI.encode_www_form(params)
|
||||
theOptions = { :key => "QHFJ0C5EWGBH" }
|
||||
uri.query = URI.encode_www_form(theOptions)
|
||||
|
||||
res = Net::HTTP.get_response(uri)
|
||||
render json: res.body if res.is_a?(Net::HTTPSuccess)
|
||||
end
|
||||
|
||||
def search
|
||||
uri = URI('https://api.tenor.com/v1/search')
|
||||
theOptions = {
|
||||
:key => "QHFJ0C5EWGBH",
|
||||
:media_filter => "minimal",
|
||||
:limit => 30,
|
||||
:q => params[:search],
|
||||
:pos => params[:next] || 0
|
||||
}
|
||||
uri.query = URI.encode_www_form(theOptions)
|
||||
|
||||
res = Net::HTTP.get_response(uri)
|
||||
render json: res.body if res.is_a?(Net::HTTPSuccess)
|
||||
|
||||
@@ -4,6 +4,7 @@ class Api::V1::NotificationsController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :read, :'read:notifications' }, except: [:clear, :dismiss, :mark_read]
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:notifications' }, only: [:clear, :dismiss, :mark_read]
|
||||
before_action :require_user!
|
||||
before_action :set_filter_params
|
||||
after_action :insert_pagination_headers, only: :index
|
||||
|
||||
respond_to :json
|
||||
@@ -49,7 +50,7 @@ class Api::V1::NotificationsController < Api::BaseController
|
||||
end
|
||||
|
||||
def browserable_account_notifications
|
||||
current_account.notifications.browserable(exclude_types, from_account)
|
||||
current_account.notifications.browserable(exclude_types, from_account, params[:only_verified], params[:only_following])
|
||||
end
|
||||
|
||||
def target_statuses_from_notifications
|
||||
@@ -86,6 +87,13 @@ class Api::V1::NotificationsController < Api::BaseController
|
||||
val
|
||||
end
|
||||
|
||||
def set_filter_params
|
||||
params.permit(
|
||||
:only_verified,
|
||||
:only_following
|
||||
)
|
||||
end
|
||||
|
||||
def from_account
|
||||
params[:account_id]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user