mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-02 15:48:00 +01:00
reveal anon
This commit is contained in:
parent
64d789c357
commit
2d9d32af81
4 changed files with 13 additions and 4 deletions
|
@ -56,6 +56,9 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do
|
||||||
def can?(%User{role: "moderator"}, :edit, %UserLink{}), do: true
|
def can?(%User{role: "moderator"}, :edit, %UserLink{}), do: true
|
||||||
def can?(%User{role: "moderator"}, :index, UserLink), do: true
|
def can?(%User{role: "moderator"}, :index, UserLink), do: true
|
||||||
|
|
||||||
|
# Reveal anon users
|
||||||
|
def can?(%User{role: "moderator"}, :reveal_anon, %User{}), do: true
|
||||||
|
|
||||||
#
|
#
|
||||||
# Assistants can...
|
# Assistants can...
|
||||||
#
|
#
|
||||||
|
|
|
@ -5,4 +5,7 @@
|
||||||
= render PhilomenaWeb.ProfileView, "_awards.html", awards: @object.user.awards
|
= render PhilomenaWeb.ProfileView, "_awards.html", awards: @object.user.awards
|
||||||
- else
|
- else
|
||||||
strong<>
|
strong<>
|
||||||
= anonymous_name(@object)
|
= if can?(@conn, :reveal_anon, @object) do
|
||||||
|
= link(anonymous_name(@object, true), to: Routes.profile_path(@conn, :show, @object.user))
|
||||||
|
- else
|
||||||
|
= anonymous_name(@object)
|
||||||
|
|
|
@ -7,7 +7,7 @@ defmodule PhilomenaWeb.UserAttributionView do
|
||||||
Attribution.anonymous?(object)
|
Attribution.anonymous?(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def anonymous_name(object) do
|
def anonymous_name(object, reveal_anon? \\ false) do
|
||||||
salt = anonymous_name_salt()
|
salt = anonymous_name_salt()
|
||||||
id = Attribution.object_identifier(object)
|
id = Attribution.object_identifier(object)
|
||||||
user_id = Attribution.best_user_identifier(object)
|
user_id = Attribution.best_user_identifier(object)
|
||||||
|
@ -17,7 +17,10 @@ defmodule PhilomenaWeb.UserAttributionView do
|
||||||
|> Integer.to_string(16)
|
|> Integer.to_string(16)
|
||||||
|> String.pad_leading(4, "0")
|
|> String.pad_leading(4, "0")
|
||||||
|
|
||||||
"Background Pony ##{hash}"
|
case reveal_anon? do
|
||||||
|
true -> "#{object.user.name} (##{hash}, hidden)"
|
||||||
|
false -> "Background Pony ##{hash}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def anonymous_avatar(_object, class \\ "avatar--100px") do
|
def anonymous_avatar(_object, class \\ "avatar--100px") do
|
||||||
|
|
Loading…
Reference in a new issue