run mix format

This commit is contained in:
William Pitcock 2018-05-28 18:31:48 +00:00
parent 993312cdb3
commit 5eed1ea181
3 changed files with 31 additions and 18 deletions

View file

@ -364,15 +364,18 @@ def get_friends(user) do
def get_follow_requests_query(%User{} = user) do def get_follow_requests_query(%User{} = user) do
from( from(
a in Activity, a in Activity,
where: fragment( where:
fragment(
"? ->> 'type' = 'Follow'", "? ->> 'type' = 'Follow'",
a.data a.data
), ),
where: fragment( where:
fragment(
"? ->> 'state' = 'pending'", "? ->> 'state' = 'pending'",
a.data a.data
), ),
where: fragment( where:
fragment(
"? @> ?", "? @> ?",
a.data, a.data,
^%{"object" => user.ap_id} ^%{"object" => user.ap_id}
@ -385,9 +388,9 @@ def get_follow_requests(%User{} = user) do
reqs = Repo.all(q) reqs = Repo.all(q)
users = users =
Enum.map(reqs, fn (req) -> req.actor end) Enum.map(reqs, fn req -> req.actor end)
|> Enum.uniq |> Enum.uniq()
|> Enum.map(fn (ap_id) -> get_by_ap_id(ap_id) end) |> Enum.map(fn ap_id -> get_by_ap_id(ap_id) end)
{:ok, users} {:ok, users}
end end

View file

@ -138,7 +138,13 @@ def handle_incoming(
%User{} = follower <- User.get_or_fetch_by_ap_id(follower), %User{} = follower <- User.get_or_fetch_by_ap_id(follower),
{:ok, activity} <- ActivityPub.follow(follower, followed, id, false) do {:ok, activity} <- ActivityPub.follow(follower, followed, id, false) do
if not User.locked?(followed) do if not User.locked?(followed) do
ActivityPub.accept(%{to: [follower.ap_id], actor: followed.ap_id, object: data, local: true}) ActivityPub.accept(%{
to: [follower.ap_id],
actor: followed.ap_id,
object: data,
local: true
})
User.follow(follower, followed) User.follow(follower, followed)
end end

View file

@ -233,7 +233,11 @@ def update_follow_state(%Activity{} = activity, state) do
@doc """ @doc """
Makes a follow activity data for the given follower and followed Makes a follow activity data for the given follower and followed
""" """
def make_follow_data(%User{ap_id: follower_id}, %User{ap_id: followed_id} = followed, activity_id) do def make_follow_data(
%User{ap_id: follower_id},
%User{ap_id: followed_id} = followed,
activity_id
) do
data = %{ data = %{
"type" => "Follow", "type" => "Follow",
"actor" => follower_id, "actor" => follower_id,