forked from e621ng/e621ng
Add discord server support
This commit is contained in:
parent
6841a2a333
commit
f19c3e408b
@ -18,4 +18,20 @@ class StaticController < ApplicationController
|
||||
|
||||
def site_map
|
||||
end
|
||||
|
||||
def discord
|
||||
unless CurrentUser.can_discord?
|
||||
access_denied message: "You must have an account for at least one week in order to join the Discord server."
|
||||
return
|
||||
end
|
||||
if request.post?
|
||||
time = (Time.now + 5.minute).to_i
|
||||
secret = Danbooru.config.discord_secret
|
||||
# TODO: Proper HMAC
|
||||
hashed_values = Digest::SHA256.hexdigest("#{CurrentUser.name} #{CurrentUser.id} #{time} #{secret}")
|
||||
user_hash = "?user_id=#{CurrentUser.id}&username=#{CurrentUser.name}&time=#{time}&hash=#{hashed_values}"
|
||||
|
||||
redirect_to(Danbooru.config.discord_site + user_hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -505,6 +505,10 @@ class User < ApplicationRecord
|
||||
older_than 7.days
|
||||
end
|
||||
|
||||
def can_discord?
|
||||
older_than 7.days
|
||||
end
|
||||
|
||||
def can_view_flagger?(flagger_id)
|
||||
is_moderator? || flagger_id == id
|
||||
end
|
||||
|
@ -9,10 +9,6 @@
|
||||
<%= nav_link_to("Artists", artists_path) %>
|
||||
<%= nav_link_to("Tags", tags_path) %>
|
||||
<%= nav_link_to("Blips", blips_path) %>
|
||||
<% if CurrentUser.is_janitor? %>
|
||||
<%= nav_link_to("Aliases", tag_aliases_path) %>
|
||||
<%= nav_link_to("Implications", tag_implications_path) %>
|
||||
<% end %>
|
||||
<%= nav_link_to("Pools", pools_path) %>
|
||||
<%= nav_link_to("Sets", post_sets_path) %>
|
||||
<%= nav_link_to("Wiki", wiki_pages_path(:title => "help:home")) %>
|
||||
@ -20,5 +16,6 @@
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
<%= nav_link_to("Dashboard", moderator_dashboard_path) %>
|
||||
<% end %>
|
||||
<%= nav_link_to("Discord", discord_get_path) %>
|
||||
<%= nav_link_to("More »", site_map_path) %>
|
||||
</menu>
|
||||
|
@ -293,6 +293,14 @@ fart'
|
||||
false
|
||||
end
|
||||
|
||||
def discord_site
|
||||
""
|
||||
end
|
||||
|
||||
def discord_secret
|
||||
""
|
||||
end
|
||||
|
||||
# Maximum size of an upload. If you change this, you must also change
|
||||
# `client_max_body_size` in your nginx.conf.
|
||||
def max_file_size
|
||||
|
@ -477,6 +477,8 @@ Rails.application.routes.draw do
|
||||
get "/static/terms_of_service" => "static#terms_of_service", :as => "terms_of_service"
|
||||
post "/static/accept_terms_of_service" => "static#accept_terms_of_service", :as => "accept_terms_of_service"
|
||||
get "/static/contact" => "static#contact", :as => "contact"
|
||||
get "/static/discord" => "static#discord", as: "discord_get"
|
||||
post "/static/discord" => "static#discord", as: "discord_post"
|
||||
get "/meta_searches/tags" => "meta_searches#tags", :as => "meta_searches_tags"
|
||||
|
||||
get "/intro" => redirect("/explore/posts/intro")
|
||||
|
Loading…
Reference in New Issue
Block a user