Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kaniini
pleroma
Commits
bda389d7
Commit
bda389d7
authored
7 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
Subscribe to remote users on following.
parent
9cafb67f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/pleroma/user.ex
+5
-1
5 additions, 1 deletion
lib/pleroma/user.ex
lib/pleroma/web/websub/websub.ex
+1
-1
1 addition, 1 deletion
lib/pleroma/web/websub/websub.ex
test/user_test.exs
+21
-3
21 additions, 3 deletions
test/user_test.exs
with
27 additions
and
5 deletions
lib/pleroma/user.ex
+
5
−
1
View file @
bda389d7
...
...
@@ -4,7 +4,7 @@ defmodule Pleroma.User do
import
Ecto
.
{
Changeset
,
Query
}
alias
Pleroma
.
{
Repo
,
User
,
Object
,
Web
}
alias
Comeonin
.
Pbkdf2
alias
Pleroma
.
Web
.
OStatus
alias
Pleroma
.
Web
.
{
OStatus
,
Websub
}
schema
"users"
do
field
:bio
,
:string
...
...
@@ -88,6 +88,10 @@ defmodule Pleroma.User do
{
:error
,
"Could not follow user:
#{
followed
.
nickname
}
is already on your list."
}
else
if
!followed
.
local
do
Websub
.
subscribe
(
follower
,
followed
)
end
following
=
[
ap_followers
|
follower
.
following
]
|>
Enum
.
uniq
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/web/websub/websub.ex
+
1
−
1
View file @
bda389d7
...
...
@@ -126,7 +126,7 @@ defmodule Pleroma.Web.Websub do
topic
=
subscribed
.
info
[
"topic"
]
# FIXME: Race condition, use transactions
{
:ok
,
subscription
}
=
with
subscription
when
not
is_nil
(
subscription
)
<-
Repo
.
get_by
(
WebsubClientSubscription
,
topic:
topic
)
do
subscribers
=
[
subscriber
.
ap_id
,
subscription
.
subscribers
]
|>
Enum
.
uniq
subscribers
=
[
subscriber
.
ap_id
|
subscription
.
subscribers
]
|>
Enum
.
uniq
change
=
Ecto
.
Changeset
.
change
(
subscription
,
%{
subscribers:
subscribers
})
Repo
.
update
(
change
)
else
_e
->
...
...
This diff is collapsed.
Click to expand it.
test/user_test.exs
+
21
−
3
View file @
bda389d7
defmodule
Pleroma
.
UserTest
do
alias
Pleroma
.
Builders
.
UserBuilder
alias
Pleroma
.
User
alias
Pleroma
.
{
User
,
Repo
}
alias
Pleroma
.
Web
.
OStatus
alias
Pleroma
.
Web
.
Websub
.
WebsubClientSubscription
use
Pleroma
.
DataCase
import
Pleroma
.
Factory
import
Ecto
.
Query
test
"ap_id returns the activity pub id for the user"
do
host
=
...
...
@@ -30,13 +33,29 @@ defmodule Pleroma.UserTest do
user
=
insert
(
:user
)
followed
=
insert
(
:user
)
{
:ok
,
user
}
=
User
.
follow
(
user
,
followed
)
{
:ok
,
user
}
=
User
.
follow
(
user
,
followed
)
user
=
Repo
.
get
(
User
,
user
.
id
)
assert
user
.
following
==
[
User
.
ap_followers
(
followed
)]
end
test
"following a remote user will ensure a websub subscription is present"
do
user
=
insert
(
:user
)
{
:ok
,
followed
}
=
OStatus
.
make_user
(
"shp@social.heldscal.la"
)
assert
followed
.
local
==
false
{
:ok
,
user
}
=
User
.
follow
(
user
,
followed
)
assert
user
.
following
==
[
User
.
ap_followers
(
followed
)]
query
=
from
w
in
WebsubClientSubscription
,
where:
w
.
topic
==
^
followed
.
info
[
"topic"
]
websub
=
Repo
.
one
(
query
)
assert
websub
end
test
"unfollow takes a user and another user"
do
followed
=
insert
(
:user
)
user
=
insert
(
:user
,
%{
following:
[
User
.
ap_followers
(
followed
)]})
...
...
@@ -95,7 +114,6 @@ defmodule Pleroma.UserTest do
assert
user
==
fetched_user
end
# TODO: Make the test local.
test
"fetches an external user via ostatus if no user exists"
do
fetched_user
=
User
.
get_or_fetch_by_nickname
(
"shp@social.heldscal.la"
)
assert
fetched_user
.
nickname
==
"shp@social.heldscal.la"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment