]> cat aescling's git repositories - mastodon.git/commitdiff
Add API method to remove a suggestion (#7978)
authorEugen Rochko <eugen@zeonfederated.com>
Sat, 7 Jul 2018 19:09:54 +0000 (21:09 +0200)
committerGitHub <noreply@github.com>
Sat, 7 Jul 2018 19:09:54 +0000 (21:09 +0200)
DELETE /api/v1/suggestions/:account_id

When blocking, remove suggestion from both sides. Muting not affected,
since muting is supposed to be invisible to the target.

app/controllers/api/v1/suggestions_controller.rb
app/models/concerns/account_interactions.rb
config/routes.rb

index 3abccedd5de317e7e1bbc35749a01fa0e98ff5b3..9da2b60ae206e74c9f5e74f0c4cf4e901689b7d3 100644 (file)
@@ -13,6 +13,11 @@ class Api::V1::SuggestionsController < Api::BaseController
     render json: @accounts, each_serializer: REST::AccountSerializer
   end
 
+  def destroy
+    PotentialFriendshipTracker.remove(current_account.id, params[:id])
+    render_empty
+  end
+
   private
 
   def set_accounts
index ee435f956f38442c59df640ad0b1af4fe5d49999..e14e041f614afe70159baedcb738845e303f9beb 100644 (file)
@@ -203,7 +203,8 @@ module AccountInteractions
 
   private
 
-  def remove_potential_friendship(other_account)
+  def remove_potential_friendship(other_account, mutual = false)
     PotentialFriendshipTracker.remove(id, other_account.id)
+    PotentialFriendshipTracker.remove(other_account.id, id) if mutual
   end
 end
index e593259646d8470984767adf2b3af62c09f9574d..fd26b4aa74cac3105f5e2c8108fe0d1c64e4e4ca 100644 (file)
@@ -246,7 +246,7 @@ Rails.application.routes.draw do
 
       resources :streaming, only: [:index]
       resources :custom_emojis, only: [:index]
-      resources :suggestions, only: [:index]
+      resources :suggestions, only: [:index, :destroy]
 
       get '/search', to: 'search#index', as: :search