Merge branch 'validate-user-info' of git.pleroma.social:pleroma/pleroma into validate-user-info

This commit is contained in:
lain 2018-11-20 20:16:16 +01:00
commit 0bea0308f1
4 changed files with 6 additions and 6 deletions

View file

@ -20,7 +20,7 @@ def call(conn, _) do
with token when not is_nil(token) <- token, with token when not is_nil(token) <- token,
%Token{user_id: user_id} <- Repo.get_by(Token, token: token), %Token{user_id: user_id} <- Repo.get_by(Token, token: token),
%User{} = user <- Repo.get(User, user_id), %User{} = user <- Repo.get(User, user_id),
false <- !!user.info["deactivated"] do false <- !!user.info.deactivated do
conn conn
|> assign(:user, user) |> assign(:user, user)
else else

View file

@ -284,7 +284,7 @@ def following?(%User{} = follower, %User{} = followed) do
end end
def locked?(%User{} = user) do def locked?(%User{} = user) do
user.info["locked"] || false user.info.locked || false
end end
def get_by_ap_id(ap_id) do def get_by_ap_id(ap_id) do

View file

@ -173,7 +173,7 @@ def push_to_socket(topics, topic, %Activity{data: %{"type" => "Announce"}} = ite
Enum.each(topics[topic] || [], fn socket -> Enum.each(topics[topic] || [], fn socket ->
# Get the current user so we have up-to-date blocks etc. # Get the current user so we have up-to-date blocks etc.
user = User.get_cached_by_ap_id(socket.assigns[:user].ap_id) user = User.get_cached_by_ap_id(socket.assigns[:user].ap_id)
blocks = user.info["blocks"] || [] blocks = user.info.blocks || []
parent = Object.normalize(item.data["object"]) parent = Object.normalize(item.data["object"])
@ -187,7 +187,7 @@ def push_to_socket(topics, topic, item) do
Enum.each(topics[topic] || [], fn socket -> Enum.each(topics[topic] || [], fn socket ->
# Get the current user so we have up-to-date blocks etc. # Get the current user so we have up-to-date blocks etc.
user = User.get_cached_by_ap_id(socket.assigns[:user].ap_id) user = User.get_cached_by_ap_id(socket.assigns[:user].ap_id)
blocks = user.info["blocks"] || [] blocks = user.info.blocks || []
unless item.actor in blocks do unless item.actor in blocks do
send(socket.transport_pid, {:text, represent_update(item, user)}) send(socket.transport_pid, {:text, represent_update(item, user)})

View file

@ -17,7 +17,7 @@ test "Represent a user account" do
user = user =
insert(:user, %{ insert(:user, %{
info: %{"note_count" => 5, "follower_count" => 3, "source_data" => source_data}, info: %{note_count: 5, follower_count: 3, source_data: source_data},
nickname: "shp@shitposter.club", nickname: "shp@shitposter.club",
name: ":karjalanpiirakka: shp", name: ":karjalanpiirakka: shp",
bio: "<script src=\"invalid-html\"></script><span>valid html</span>", bio: "<script src=\"invalid-html\"></script><span>valid html</span>",
@ -63,7 +63,7 @@ test "Represent a user account" do
test "Represent a Service(bot) account" do test "Represent a Service(bot) account" do
user = user =
insert(:user, %{ insert(:user, %{
info: %{"note_count" => 5, "follower_count" => 3, "source_data" => %{"type" => "Service"}}, info: %{note_count: 5, follower_count: 3, source_data: %{"type" => "Service"}},
nickname: "shp@shitposter.club", nickname: "shp@shitposter.club",
inserted_at: ~N[2017-08-15 15:47:06.597036] inserted_at: ~N[2017-08-15 15:47:06.597036]
}) })