Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
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
Steven Fuchs
pleroma
Commits
b2713357
Commit
b2713357
authored
2 years ago
by
Haelwenn
Browse files
Options
Downloads
Patches
Plain Diff
Object.Fetcher: Set reachable on successful fetch
parent
39a96876
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/pleroma/object/fetcher.ex
+5
-0
5 additions, 0 deletions
lib/pleroma/object/fetcher.ex
test/pleroma/object/fetcher_test.exs
+12
-0
12 additions, 0 deletions
test/pleroma/object/fetcher_test.exs
with
17 additions
and
0 deletions
lib/pleroma/object/fetcher.ex
+
5
−
0
View file @
b2713357
...
...
@@ -4,6 +4,7 @@
defmodule
Pleroma
.
Object
.
Fetcher
do
alias
Pleroma
.
HTTP
alias
Pleroma
.
Instances
alias
Pleroma
.
Maps
alias
Pleroma
.
Object
alias
Pleroma
.
Object
.
Containment
...
...
@@ -234,6 +235,10 @@ def fetch_and_contain_remote_object_from_id(id) when is_binary(id) do
{
:ok
,
body
}
<-
get_object
(
id
),
{
:ok
,
data
}
<-
safe_json_decode
(
body
),
:ok
<-
Containment
.
contain_origin_from_id
(
id
,
data
)
do
if
not
Instances
.
reachable?
(
id
)
do
Instances
.
set_reachable
(
id
)
end
{
:ok
,
data
}
else
{
:scheme
,
_
}
->
...
...
This diff is collapsed.
Click to expand it.
test/pleroma/object/fetcher_test.exs
+
12
−
0
View file @
b2713357
...
...
@@ -6,6 +6,7 @@ defmodule Pleroma.Object.FetcherTest do
use
Pleroma
.
DataCase
alias
Pleroma
.
Activity
alias
Pleroma
.
Instances
alias
Pleroma
.
Object
alias
Pleroma
.
Object
.
Fetcher
...
...
@@ -159,6 +160,17 @@ test "it does not fetch a spoofed object uploaded on an instance as an attachmen
"https://patch.cx/media/03ca3c8b4ac3ddd08bf0f84be7885f2f88de0f709112131a22d83650819e36c2.json"
)
end
test
"it resets instance reachability on successful fetch"
do
id
=
"http://mastodon.example.org/@admin/99541947525187367"
Instances
.
set_consistently_unreachable
(
id
)
refute
Instances
.
reachable?
(
id
)
{
:ok
,
object
}
=
Fetcher
.
fetch_object_from_id
(
"http://mastodon.example.org/@admin/99541947525187367"
)
assert
Instances
.
reachable?
(
id
)
end
end
describe
"implementation quirks"
do
...
...
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