Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
a78ae2a6
Commit
a78ae2a6
authored
Dec 07, 2017
by
lain
Browse files
Don't follow deactivated users.
parent
b727ecc5
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/user.ex
View file @
a78ae2a6
...
@@ -142,9 +142,9 @@ def register_changeset(struct, params \\ %{}) do
...
@@ -142,9 +142,9 @@ def register_changeset(struct, params \\ %{}) do
end
end
end
end
def
follow
(%
User
{}
=
follower
,
%
User
{}
=
followed
)
do
def
follow
(%
User
{}
=
follower
,
%
User
{
info:
info
}
=
followed
)
do
ap_followers
=
followed
.
follower_address
ap_followers
=
followed
.
follower_address
if
following?
(
follower
,
followed
)
do
if
following?
(
follower
,
followed
)
or
info
[
"deactivated"
]
do
{
:error
,
{
:error
,
"Could not follow user:
#{
followed
.
nickname
}
is already on your list."
}
"Could not follow user:
#{
followed
.
nickname
}
is already on your list."
}
else
else
...
...
test/user_test.exs
View file @
a78ae2a6
...
@@ -39,6 +39,13 @@ test "follow takes a user and another user" do
...
@@ -39,6 +39,13 @@ test "follow takes a user and another user" do
assert
User
.
ap_followers
(
followed
)
in
user
.
following
assert
User
.
ap_followers
(
followed
)
in
user
.
following
end
end
test
"can't follow a deactivated users"
do
user
=
insert
(
:user
)
followed
=
insert
(
:user
,
info:
%{
"deactivated"
=>
true
})
{
:error
,
_
}
=
User
.
follow
(
user
,
followed
)
end
test
"following a remote user will ensure a websub subscription is present"
do
test
"following a remote user will ensure a websub subscription is present"
do
user
=
insert
(
:user
)
user
=
insert
(
:user
)
{
:ok
,
followed
}
=
OStatus
.
make_user
(
"shp@social.heldscal.la"
)
{
:ok
,
followed
}
=
OStatus
.
make_user
(
"shp@social.heldscal.la"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment