Commit b248fc7d authored by dtluna's avatar dtluna
Browse files

Refactor unfollow/2

parent 01901d98
......@@ -124,24 +124,16 @@ def follow(%User{} = follower, params) do
end
end
def unfollow(%User{} = follower, %{ "user_id" => followed_id }) do
with %User{} = followed <- Repo.get(User, followed_id),
{ :ok, follower } <- User.unfollow(follower, followed)
def unfollow(%User{} = follower, params) do
with { :ok, %User{} = unfollowed } <- get_user(params),
{ :ok, follower } <- User.unfollow(follower, unfollowed)
do
{ :ok, follower, followed }
{ :ok, follower, unfollowed}
else
err -> err
end
end
def unfollow(%User{} = follower, %{ "screen_name" => followed_name }) do
with %User{} = followed <- Repo.get_by(User, nickname: followed_name),
{ :ok, follower } <- User.unfollow(follower, followed)
do
{ :ok, follower, followed }
end
end
def favorite(%User{} = user, %Activity{data: %{"object" => object}} = activity) do
object = Object.get_by_ap_id(object["id"])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment