rename some config keys to clarify what they are
This commit is contained in:
@@ -32,8 +32,8 @@ protected
|
|||||||
response.headers["Access-Control-Allow-Origin"] = "*"
|
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_shared_key
|
def require_reportbooru_key
|
||||||
unless params[:key] == Danbooru.config.shared_remote_key
|
unless params[:key] == Danbooru.config.reportbooru_key
|
||||||
render(text: "forbidden", status: 403)
|
render(text: "forbidden", status: 403)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class RelatedTagsController < ApplicationController
|
class RelatedTagsController < ApplicationController
|
||||||
respond_to :json
|
respond_to :json
|
||||||
before_filter :require_shared_key, only: [:update]
|
before_filter :require_reportbooru_key, only: [:update]
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@query = RelatedTagQuery.new(params[:query].to_s.downcase, params[:category])
|
@query = RelatedTagQuery.new(params[:query].to_s.downcase, params[:category])
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module PostsHelper
|
|||||||
if params[:ms] == "1" && @post_set.post_count == 0 && @post_set.is_single_tag?
|
if params[:ms] == "1" && @post_set.post_count == 0 && @post_set.is_single_tag?
|
||||||
session_id = session.id
|
session_id = session.id
|
||||||
digest = OpenSSL::Digest.new("sha256")
|
digest = OpenSSL::Digest.new("sha256")
|
||||||
sig = OpenSSL::HMAC.hexdigest(digest, Danbooru.config.shared_remote_key, ",#{session_id}")
|
sig = OpenSSL::HMAC.hexdigest(digest, Danbooru.config.reportbooru_key, ",#{session_id}")
|
||||||
return render("posts/partials/index/missed_search_count", session_id: session_id, sig: sig)
|
return render("posts/partials/index/missed_search_count", session_id: session_id, sig: sig)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -20,7 +20,7 @@ module PostsHelper
|
|||||||
key = "ps-#{tags}"
|
key = "ps-#{tags}"
|
||||||
value = session.id
|
value = session.id
|
||||||
digest = OpenSSL::Digest.new("sha256")
|
digest = OpenSSL::Digest.new("sha256")
|
||||||
sig = OpenSSL::HMAC.hexdigest(digest, Danbooru.config.shared_remote_key, "#{key},#{value}")
|
sig = OpenSSL::HMAC.hexdigest(digest, Danbooru.config.reportbooru_key, "#{key},#{value}")
|
||||||
return render("posts/partials/index/search_count", key: key, value: value, sig: sig)
|
return render("posts/partials/index/search_count", key: key, value: value, sig: sig)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -36,7 +36,7 @@ module PostsHelper
|
|||||||
key = "uid"
|
key = "uid"
|
||||||
value = user.id
|
value = user.id
|
||||||
digest = OpenSSL::Digest.new("sha256")
|
digest = OpenSSL::Digest.new("sha256")
|
||||||
sig = OpenSSL::HMAC.hexdigest(digest, Danbooru.config.shared_remote_key, "#{key},#{value}")
|
sig = OpenSSL::HMAC.hexdigest(digest, Danbooru.config.reportbooru_key, "#{key},#{value}")
|
||||||
render("users/common_searches", user: user, sig: sig)
|
render("users/common_searches", user: user, sig: sig)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class MissedSearchService
|
|||||||
|
|
||||||
def fetch_data
|
def fetch_data
|
||||||
Cache.get("ms", 1.minute) do
|
Cache.get("ms", 1.minute) do
|
||||||
url = URI.parse("#{Danbooru.config.report_server}/missed_searches")
|
url = URI.parse("#{Danbooru.config.reportbooru_server}/missed_searches")
|
||||||
response = ""
|
response = ""
|
||||||
Net::HTTP.start(url.host, url.port, :use_ssl => url.is_a?(URI::HTTPS)) do |http|
|
Net::HTTP.start(url.host, url.port, :use_ssl => url.is_a?(URI::HTTPS)) do |http|
|
||||||
http.read_timeout = 1
|
http.read_timeout = 1
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class PopularSearchService
|
|||||||
dates = date.strftime("%Y-%m-%d")
|
dates = date.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
Cache.get("ps-#{scale}-#{dates}", 1.minute) do
|
Cache.get("ps-#{scale}-#{dates}", 1.minute) do
|
||||||
url = URI.parse("#{Danbooru.config.report_server}/hits/#{scale}?date=#{dates}")
|
url = URI.parse("#{Danbooru.config.reportbooru_server}/hits/#{scale}?date=#{dates}")
|
||||||
response = ""
|
response = ""
|
||||||
Net::HTTP.start(url.host, url.port, :use_ssl => url.is_a?(URI::HTTPS)) do |http|
|
Net::HTTP.start(url.host, url.port, :use_ssl => url.is_a?(URI::HTTPS)) do |http|
|
||||||
http.read_timeout = 1
|
http.read_timeout = 1
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ module Reports
|
|||||||
|
|
||||||
def generate_sig
|
def generate_sig
|
||||||
digest = OpenSSL::Digest.new("sha256")
|
digest = OpenSSL::Digest.new("sha256")
|
||||||
OpenSSL::HMAC.hexdigest(digest, Danbooru.config.shared_remote_key, "#{min_date},#{max_date},#{queries}")
|
OpenSSL::HMAC.hexdigest(digest, Danbooru.config.reportbooru_key, "#{min_date},#{max_date},#{queries}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ module Reports
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch_similar_user_ids(endpoint = "user_similarity")
|
def fetch_similar_user_ids(endpoint = "user_similarity")
|
||||||
return NotImplementedError unless Danbooru.config.report_server
|
return NotImplementedError unless Danbooru.config.reportbooru_server
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
"key" => Danbooru.config.shared_remote_key,
|
"key" => Danbooru.config.reportbooru_key,
|
||||||
"user_id" => user_id
|
"user_id" => user_id
|
||||||
}
|
}
|
||||||
uri = URI.parse("#{Danbooru.config.report_server}/reports/#{endpoint}")
|
uri = URI.parse("#{Danbooru.config.reportbooru_server}/reports/#{endpoint}")
|
||||||
uri.query = URI.encode_www_form(params)
|
uri.query = URI.encode_www_form(params)
|
||||||
|
|
||||||
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.is_a?(URI::HTTPS)) do |http|
|
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.is_a?(URI::HTTPS)) do |http|
|
||||||
|
|||||||
@@ -341,16 +341,6 @@ module Danbooru
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def iqdb_hostname_and_port
|
|
||||||
# ["localhost", 4000]
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def iqdb_file
|
|
||||||
# /var/www/danbooru2/shared/iqdb.db
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def shared_dir_path
|
def shared_dir_path
|
||||||
"/var/www/danbooru2/shared"
|
"/var/www/danbooru2/shared"
|
||||||
end
|
end
|
||||||
@@ -376,16 +366,11 @@ module Danbooru
|
|||||||
def twitter_api_secret
|
def twitter_api_secret
|
||||||
end
|
end
|
||||||
|
|
||||||
def shared_remote_key
|
|
||||||
end
|
|
||||||
|
|
||||||
def report_server
|
|
||||||
end
|
|
||||||
|
|
||||||
def enable_post_search_counts
|
def enable_post_search_counts
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# you should override this
|
||||||
def email_key
|
def email_key
|
||||||
"zDMSATq0W3hmA5p3rKTgD"
|
"zDMSATq0W3hmA5p3rKTgD"
|
||||||
end
|
end
|
||||||
@@ -444,7 +429,14 @@ module Danbooru
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# listbooru options
|
# reportbooru options - see https://github.com/r888888888/reportbooru
|
||||||
|
def reportbooru_server
|
||||||
|
end
|
||||||
|
|
||||||
|
def reportbooru_key
|
||||||
|
end
|
||||||
|
|
||||||
|
# listbooru options - see https://github.com/r888888888/listbooru
|
||||||
def listbooru_enabled?
|
def listbooru_enabled?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
@@ -455,13 +447,21 @@ module Danbooru
|
|||||||
def listbooru_auth_key
|
def listbooru_auth_key
|
||||||
end
|
end
|
||||||
|
|
||||||
# iqdbs options
|
# iqdbs options - see https://github.com/r888888888/iqdbs
|
||||||
def iqdbs_auth_key
|
def iqdbs_auth_key
|
||||||
end
|
end
|
||||||
|
|
||||||
def iqdbs_server
|
def iqdbs_server
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def iqdb_hostname_and_port # TODO: remove
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def iqdb_file # TODO: remove
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
# google api options
|
# google api options
|
||||||
def google_api_project
|
def google_api_project
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user