Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F162767
rich_media_worker.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
rich_media_worker.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Workers.RichMediaWorker
do
alias
Pleroma.Config
alias
Pleroma.Web.RichMedia.Backfill
alias
Pleroma.Web.RichMedia.Card
use
Oban.Worker
,
queue
:
:background
,
max_attempts
:
3
,
unique
:
[
period
:
:infinity
]
@impl
true
def
perform
(%
Job
{
args
:
%{
"op"
=>
"expire"
,
"url"
=>
url
}
=
_args
})
do
Card
.
delete
(
url
)
end
def
perform
(%
Job
{
args
:
%{
"op"
=>
"backfill"
,
"url"
=>
_url
}
=
args
})
do
case
Backfill
.
run
(
args
)
do
:ok
->
:ok
{
:error
,
type
}
when
type
in
[
:invalid_metadata
,
:body_too_large
,
:content_type
,
:validate
,
:get
,
:head
]
->
{
:cancel
,
type
}
error
->
{
:error
,
error
}
end
end
# There is timeout value enforced by Tesla.Middleware.Timeout
# which can be found in the RichMedia.Helpers module to allow us to detect
# a slow/infinite data stream and insert a negative cache entry for the URL
# We pad it by 2 seconds to be certain a slow connection is detected and we
# can inject a negative cache entry for the URL
@impl
true
def
timeout
(
_job
)
do
Config
.
get!
([
:rich_media
,
:timeout
])
+
:timer
.
seconds
(
2
)
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Fri, Feb 21, 6:01 PM (13 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
66844
Default Alt Text
rich_media_worker.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment