Class: NewsmastMastodon::Api::V1::DraftedStatusesController
- Inherits:
-
Api::BaseController
- Object
- Api::BaseController
- NewsmastMastodon::Api::V1::DraftedStatusesController
- Includes:
- Authorization
- Defined in:
- app/controllers/newsmast_mastodon/api/v1/drafted_statuses_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #publish ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/newsmast_mastodon/api/v1/drafted_statuses_controller.rb', line 16 def create @status = post_status_service render json: @status, serializer: LongPost::DraftedStatusSerializer rescue PostStatusService::UnexpectedMentionsError => e unexpected_accounts = ActiveModel::Serializer::CollectionSerializer.new( e.accounts, serializer: REST::AccountSerializer ) render json: { error: e., unexpected_accounts: unexpected_accounts }, status: 422 end |
#destroy ⇒ Object
49 50 51 52 |
# File 'app/controllers/newsmast_mastodon/api/v1/drafted_statuses_controller.rb', line 49 def destroy @status.destroy! render_empty end |
#index ⇒ Object
28 29 30 |
# File 'app/controllers/newsmast_mastodon/api/v1/drafted_statuses_controller.rb', line 28 def index render json: render_custom_grouped_dates end |
#publish ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/newsmast_mastodon/api/v1/drafted_statuses_controller.rb', line 54 def publish @status.destroy! @status = post_status_service(is_draft: false) render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer rescue PostStatusService::UnexpectedMentionsError => e unexpected_accounts = ActiveModel::Serializer::CollectionSerializer.new( e.accounts, serializer: REST::AccountSerializer ) render json: { error: e., unexpected_accounts: unexpected_accounts }, status: 422 end |
#show ⇒ Object
32 33 34 |
# File 'app/controllers/newsmast_mastodon/api/v1/drafted_statuses_controller.rb', line 32 def show render json: @status, serializer: LongPost::DraftedStatusSerializer end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/newsmast_mastodon/api/v1/drafted_statuses_controller.rb', line 36 def update @status.destroy! @status = post_status_service render json: @status, serializer: LongPost::DraftedStatusSerializer rescue PostStatusService::UnexpectedMentionsError => e unexpected_accounts = ActiveModel::Serializer::CollectionSerializer.new( e.accounts, serializer: REST::AccountSerializer ) render json: { error: e., unexpected_accounts: unexpected_accounts }, status: 422 end |