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
b666f11d
Commit
b666f11d
authored
Apr 12, 2017
by
lain
Browse files
Add max_id fetching to activity fetching.
parent
6a179a44
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/activity_pub/activity_pub.ex
View file @
b666f11d
...
...
@@ -54,6 +54,12 @@ def fetch_activities(recipients, opts \\ %{}) do
query
=
from
activity
in
query
,
where:
activity
.
id
>
^
since_id
query
=
if
opts
[
"max_id"
]
do
from
activity
in
query
,
where:
activity
.
id
<
^
opts
[
"max_id"
]
else
query
end
Repo
.
all
(
query
)
|>
Enum
.
reverse
end
...
...
test/web/activity_pub/activity_pub_test.exs
View file @
b666f11d
...
...
@@ -94,6 +94,20 @@ test "retrieves ids starting from a since_id" do
assert
length
(
activities
)
==
10
assert
last
==
last_expected
end
test
"retrieves ids up to max_id"
do
_first_activities
=
ActivityBuilder
.
insert_list
(
10
)
activities
=
ActivityBuilder
.
insert_list
(
20
)
later_activities
=
ActivityBuilder
.
insert_list
(
10
)
max_id
=
List
.
first
(
later_activities
)
.
id
last_expected
=
List
.
last
(
activities
)
activities
=
ActivityPub
.
fetch_public_activities
(%{
"max_id"
=>
max_id
})
last
=
List
.
last
(
activities
)
assert
length
(
activities
)
==
20
assert
last
==
last_expected
end
end
describe
"uploading files"
do
...
...
Write
Preview
Supports
Markdown
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