Class: NewsmastMastodon::Api::V1::CustomStatuses::CustomBoostBotStatusController

Inherits:
Api::BaseController
  • Object
show all
Includes:
Redisable
Defined in:
app/controllers/newsmast_mastodon/api/v1/custom_statuses/custom_boost_bot_status_controller.rb

Constant Summary collapse

RESULTS_LIMIT =
20

Instance Method Summary collapse

Instance Method Details

#add_custom_boost_bot_statusObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/newsmast_mastodon/api/v1/custom_statuses/custom_boost_bot_status_controller.rb', line 9

def add_custom_boost_bot_status
  @status_url = params[:status_url]
  return render json: { error: "Status URL is required" }, status: :bad_request unless @status_url.present?

  @search = Search.new(search_results)

  if @search.statuses.any?
    NewsmastMastodon::CustomTimelineService.new.add_custom_public_status(@search.statuses.first.id)
    render json: @search, serializer: REST::SearchSerializer
  else
    render json: { error: "No status found" }, status: :not_found
  end
end

#remove_custom_boost_bot_statusObject



23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/newsmast_mastodon/api/v1/custom_statuses/custom_boost_bot_status_controller.rb', line 23

def remove_custom_boost_bot_status
  status_id = params[:status_id]
  return render json: { error: "Status ID is required" }, status: :bad_request unless status_id.present?

  status = Status.find(status_id)
  return render json: { error: "Status not found" }, status: :not_found unless status.present?

  NewsmastMastodon::CustomTimelineService.new.remove_custom_public_status(status_id)
  render json: { message: "Status removed from custom boost bot timeline" }
end