forked from AkkomaGang/akkoma
Refactor unfollow/2
This commit is contained in:
parent
01901d9835
commit
b248fc7dfb
1 changed files with 4 additions and 12 deletions
|
@ -124,24 +124,16 @@ def follow(%User{} = follower, params) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unfollow(%User{} = follower, %{ "user_id" => followed_id }) do
|
def unfollow(%User{} = follower, params) do
|
||||||
with %User{} = followed <- Repo.get(User, followed_id),
|
with { :ok, %User{} = unfollowed } <- get_user(params),
|
||||||
{ :ok, follower } <- User.unfollow(follower, followed)
|
{ :ok, follower } <- User.unfollow(follower, unfollowed)
|
||||||
do
|
do
|
||||||
{ :ok, follower, followed }
|
{ :ok, follower, unfollowed}
|
||||||
else
|
else
|
||||||
err -> err
|
err -> err
|
||||||
end
|
end
|
||||||
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
|
def favorite(%User{} = user, %Activity{data: %{"object" => object}} = activity) do
|
||||||
object = Object.get_by_ap_id(object["id"])
|
object = Object.get_by_ap_id(object["id"])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue