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
jeff
pleroma
Commits
32d4630c
Commit
32d4630c
authored
5 years ago
by
kaniini
Browse files
Options
Downloads
Patches
Plain Diff
user: move initial post fetching to job queue
parent
b14a314c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/pleroma/user.ex
+18
-13
18 additions, 13 deletions
lib/pleroma/user.ex
with
18 additions
and
13 deletions
lib/pleroma/user.ex
+
18
−
13
View file @
32d4630c
...
...
@@ -552,8 +552,7 @@ defmodule Pleroma.User do
with
[
_nick
,
_domain
]
<-
String
.
split
(
nickname
,
"@"
),
{
:ok
,
user
}
<-
fetch_by_nickname
(
nickname
)
do
if
Pleroma
.
Config
.
get
([
:fetch_initial_posts
,
:enabled
])
do
# TODO turn into job
{
:ok
,
_
}
=
Task
.
start
(
__MODULE__
,
:fetch_initial_posts
,
[
user
])
fetch_initial_posts
(
user
)
end
{
:ok
,
user
}
...
...
@@ -564,15 +563,8 @@ defmodule Pleroma.User do
end
@doc
"Fetch some posts when the user has just been federated with"
def
fetch_initial_posts
(
user
)
do
pages
=
Pleroma
.
Config
.
get!
([
:fetch_initial_posts
,
:pages
])
Enum
.
each
(
# Insert all the posts in reverse order, so they're in the right order on the timeline
Enum
.
reverse
(
Utils
.
fetch_ordered_collection
(
user
.
info
.
source_data
[
"outbox"
],
pages
)),
&
Pleroma
.
Web
.
Federator
.
incoming_ap_doc
/
1
)
end
def
fetch_initial_posts
(
user
),
do
:
PleromaJobQueue
.
enqueue
(
:background
,
__MODULE__
,
[
:fetch_initial_posts
,
user
])
@spec
get_followers_query
(
User
.
t
(),
pos_integer
()
|
nil
)
::
Ecto
.
Query
.
t
()
def
get_followers_query
(%
User
{}
=
user
,
nil
)
do
...
...
@@ -1077,6 +1069,19 @@ defmodule Pleroma.User do
delete_user_activities
(
user
)
end
@spec
perform
(
atom
(),
User
.
t
())
::
{
:ok
,
User
.
t
()}
def
perform
(
:fetch_initial_posts
,
%
User
{}
=
user
)
do
pages
=
Pleroma
.
Config
.
get!
([
:fetch_initial_posts
,
:pages
])
Enum
.
each
(
# Insert all the posts in reverse order, so they're in the right order on the timeline
Enum
.
reverse
(
Utils
.
fetch_ordered_collection
(
user
.
info
.
source_data
[
"outbox"
],
pages
)),
&
Pleroma
.
Web
.
Federator
.
incoming_ap_doc
/
1
)
{
:ok
,
user
}
end
def
delete_user_activities
(%
User
{
ap_id:
ap_id
}
=
user
)
do
stream
=
ap_id
...
...
@@ -1130,8 +1135,8 @@ defmodule Pleroma.User do
resp
=
fetch_by_ap_id
(
ap_id
)
if
should_fetch_initial
do
with
{
:ok
,
%
User
{}
=
user
}
=
resp
do
{
:ok
,
_
}
=
Task
.
start
(
__MODULE__
,
:
fetch_initial_posts
,
[
user
]
)
with
{
:ok
,
%
User
{}
=
user
}
<-
resp
do
fetch_initial_posts
(
user
)
end
end
...
...
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