Add emoji react api POST method (same PUT)
This commit is contained in:
parent
3747409526
commit
88e9b8d4fa
@ -5,12 +5,16 @@ class Api::V1::Statuses::EmojiReactionsController < Api::BaseController
|
||||
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:emoji_reactions' }
|
||||
before_action :require_user!
|
||||
before_action :set_status, only: [:update]
|
||||
before_action :set_status, only: [:create, :update]
|
||||
before_action :set_status_without_authorize, only: [:destroy]
|
||||
|
||||
def create
|
||||
create_private(params[:emoji])
|
||||
end
|
||||
|
||||
# For compatible with Fedibird API
|
||||
def update
|
||||
create_private
|
||||
create_private(params[:id])
|
||||
end
|
||||
|
||||
def destroy
|
||||
@ -35,8 +39,8 @@ class Api::V1::Statuses::EmojiReactionsController < Api::BaseController
|
||||
|
||||
private
|
||||
|
||||
def create_private
|
||||
EmojiReactService.new.call(current_account, @status, params[:id])
|
||||
def create_private(emoji)
|
||||
EmojiReactService.new.call(current_account, @status, emoji)
|
||||
render json: @status, serializer: REST::StatusSerializer
|
||||
end
|
||||
|
||||
|
@ -217,7 +217,7 @@ export function emojiReact(status, emoji) {
|
||||
return function (dispatch, getState) {
|
||||
dispatch(emojiReactRequest(status, emoji));
|
||||
|
||||
api(getState).put(`/api/v1/statuses/${status.get('id')}/emoji_reactions/${emoji.custom ? (emoji.name + (emoji.domain || '')) : emoji.native}`).then(function (response) {
|
||||
api(getState).post(`/api/v1/statuses/${status.get('id')}/emoji_reactions`, { emoji: emoji.custom ? (emoji.name + (emoji.domain || '')) : emoji.native }).then(function (response) {
|
||||
dispatch(importFetchedStatus(response.data));
|
||||
dispatch(emojiReactSuccess(status, emoji));
|
||||
}).catch(function (error) {
|
||||
|
@ -30,7 +30,7 @@ namespace :api, format: false do
|
||||
|
||||
post :translate, to: 'translations#create'
|
||||
|
||||
resources :emoji_reactions, only: :update, constraints: { id: /[^\/]+/ }
|
||||
resources :emoji_reactions, only: [:create, :update], constraints: { id: /[^\/]+/ }
|
||||
post :emoji_unreaction, to: 'emoji_reactions#destroy'
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user