From 04926ae0c6f76daf17fa03e6a174ede1fd57e45d Mon Sep 17 00:00:00 2001 From: r888888888 Date: Sun, 3 Jan 2016 00:02:37 -0800 Subject: [PATCH] add api endpoint for updating a tag's related tags --- app/controllers/related_tags_controller.rb | 11 +++++++++++ config/routes.rb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/related_tags_controller.rb b/app/controllers/related_tags_controller.rb index 921ca7d37..1110920f3 100644 --- a/app/controllers/related_tags_controller.rb +++ b/app/controllers/related_tags_controller.rb @@ -9,4 +9,15 @@ class RelatedTagsController < ApplicationController end end end + + def update + render(text: "forbidden", status: 403) && return false unless params[:key] == Danbooru.config.shared_remote_key + + @tag = Tag.find_by_name(params[:name]) + @tag.related_tags = params[:related_tags].scan(/\S+/).in_groups_of(2) + @tag.related_tags_updated_at = Time.now + @tag.save + + render nothing: true + end end diff --git a/config/routes.rb b/config/routes.rb index c2c7830f7..a685036dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -218,7 +218,7 @@ Rails.application.routes.draw do end end resources :artist_commentary_versions, :only => [:index] - resource :related_tag, :only => [:show] + resource :related_tag, :only => [:show, :update] get "reports/user_promotions" => "reports#user_promotions" get "reports/janitor_trials" => "reports#janitor_trials" get "reports/contributors" => "reports#contributors"