Commiting

This commit is contained in:
mgabdev
2020-11-25 15:22:37 -06:00
parent fb612f60c8
commit b4e370d3d3
136 changed files with 4171 additions and 3231 deletions

View File

@@ -9,14 +9,15 @@ class Api::V1::Statuses::BookmarksController < Api::BaseController
def create
if current_user.account.is_pro
@status = bookmarked_status
render json: @status, serializer: REST::StatusSerializer
render json: @status, serializer: REST::StatusBookmarkedSerializer
else
render json: { error: 'You need to be a GabPRO member to access this' }, status: 422
end
end
def show
# is status bookmarked by user?
@status = requested_status
render json: @status, serializer: REST::StatusBookmarkedSerializer
end
def destroy
@@ -27,7 +28,7 @@ class Api::V1::Statuses::BookmarksController < Api::BaseController
bookmark = StatusBookmark.find_by!(account: current_user.account, status: @status)
bookmark.destroy!
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, bookmarks_map: @bookmarks_map)
render json: @status, serializer: REST::StatusBookmarkedSerializer
else
render json: { error: 'You need to be a GabPRO member to access this' }, status: 422
end

View File

@@ -8,7 +8,6 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController
def create
@status = favourited_status
puts "tilly -- status: " + @status.inspect
render json: @status, serializer: REST::StatusStatSerializer
end
@@ -18,7 +17,10 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController
UnfavouriteWorker.perform_async(current_user.account_id, @status.id)
render json: @status, serializer: REST::StatusStatSerializer, unfavourite: true, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, favourites_map: @favourites_map)
render json: @status,
serializer: REST::StatusStatSerializer,
unfavourite: true,
relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, favourites_map: @favourites_map)
end
private

View File

@@ -8,12 +8,17 @@ class Api::V1::Statuses::PinsController < Api::BaseController
before_action :set_status
def create
StatusPin.create!(account: current_account, status: @status)
render json: @status, serializer: REST::StatusSerializer
pin = StatusPin.find_by(account: current_account, status: @status)
if pin.nil?
StatusPin.create!(account: current_account, status: @status)
render json: @status, serializer: REST::StatusPinnedSerializer
else
return render json: { error: 'Status is already pinned' }, status: 500
end
end
def show
# is status pinned by user?
render json: @status, serializer: REST::StatusPinnedSerializer
end
def destroy
@@ -23,7 +28,7 @@ class Api::V1::Statuses::PinsController < Api::BaseController
pin.destroy!
end
render json: @status, serializer: REST::StatusSerializer
render json: @status, serializer: REST::StatusPinnedSerializer
end
private

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
class Api::V1::Statuses::RepostedByAccountsController < Api::BaseController
class Api::V1::Statuses::RebloggedByAccountsController < Api::BaseController
include Authorization
before_action -> { authorize_if_got_token! :read, :'read:accounts' }
@@ -36,13 +36,13 @@ class Api::V1::Statuses::RepostedByAccountsController < Api::BaseController
def next_path
if records_continue?
api_v1_status_reposted_by_index_url pagination_params(max_id: pagination_max_id)
api_v1_status_reblogged_by_index_url pagination_params(max_id: pagination_max_id)
end
end
def prev_path
unless @accounts.empty?
api_v1_status_reposted_by_index_url pagination_params(since_id: pagination_since_id)
api_v1_status_reblogged_by_index_url pagination_params(since_id: pagination_since_id)
end
end

View File

@@ -7,22 +7,25 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController
before_action :require_user!
def create
if !current_user.account.local? || !status_for_reblog.local
return render json: { error: 'Invalid action' }, status: 422
end
@status = ReblogService.new.call(current_user.account, status_for_reblog, reblog_params)
render json: @status, serializer: REST::StatusSerializer
@relog = status_for_reblog
ReblogService.new.call(current_user.account, @relog, reblog_params)
render json: @relog, serializer: REST::StatusStatSerializer
end
def destroy
@status = status_for_destroy.reblog
@reblogs_map = { @status.id => false }
@my_relog = status_for_destroy
@original_status = @my_relog.reblog
authorize status_for_destroy, :unreblog?
RemovalWorker.perform_async(status_for_destroy.id)
authorize @my_relog, :unreblog?
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, reblogs_map: @reblogs_map)
RemovalWorker.perform_async(@my_relog.id)
@reblogs_map = { @original_status.id => false }
render json: @original_status,
serializer: REST::StatusStatSerializer,
unreblog: true,
relationships: StatusRelationshipsPresenter.new([@original_status], current_user&.account_id, reblogs_map: @reblogs_map)
end
private