|
3 | 3 | class Api::V1::StatusesController < Api::BaseController |
4 | 4 | include Authorization |
5 | 5 |
|
6 | | - before_action -> { authorize_if_got_token! :read, :'read:statuses' }, except: [:create, :destroy] |
7 | | - before_action -> { doorkeeper_authorize! :write, :'write:statuses' }, only: [:create, :destroy] |
| 6 | + before_action -> { authorize_if_got_token! :read, :'read:statuses' }, except: [:create, :update, :destroy] |
| 7 | + before_action -> { doorkeeper_authorize! :write, :'write:statuses' }, only: [:create, :update, :destroy] |
8 | 8 | before_action :require_user!, except: [:index, :show, :context, :updated] |
9 | 9 | before_action :set_statuses, only: [:index] |
10 | 10 | before_action :set_updated_statuses, only: [:updated] |
11 | | - before_action :set_status, only: [:show, :context] |
| 11 | + before_action :set_status, only: [:show, :context, :update] |
12 | 12 | before_action :set_thread, only: [:create] |
13 | 13 | before_action :set_circle, only: [:create] |
14 | 14 | before_action :set_schedule, only: [:create] |
@@ -83,11 +83,27 @@ def create |
83 | 83 | status_reference_urls: status_params[:status_reference_urls] || [], |
84 | 84 | searchability: status_params[:searchability] |
85 | 85 | ) |
86 | | - |
87 | 86 |
|
88 | 87 | render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer |
89 | 88 | end |
90 | 89 |
|
| 90 | + def update |
| 91 | + @status = Status.where(account: current_account).find(params[:id]) |
| 92 | + authorize @status, :update? |
| 93 | + |
| 94 | + UpdateStatusService.new.call( |
| 95 | + @status, |
| 96 | + current_account.id, |
| 97 | + text: status_params[:status], |
| 98 | + media_ids: status_params[:media_ids], |
| 99 | + sensitive: status_params[:sensitive], |
| 100 | + spoiler_text: status_params[:spoiler_text], |
| 101 | + poll: status_params[:poll] |
| 102 | + ) |
| 103 | + |
| 104 | + render json: @status, serializer: REST::StatusSerializer |
| 105 | + end |
| 106 | + |
91 | 107 | def destroy |
92 | 108 | @status = Status.include_expired.where(account_id: current_account.id).find(status_params[:id]) |
93 | 109 | authorize @status, :destroy? |
|
0 commit comments