Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85158339
publisher.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
publisher.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.Federator.Publisher
do
alias
Pleroma.Web.Federator.RetryQueue
require
Logger
@moduledoc
"""
Defines the contract used by federation implementations to publish messages to
their peers.
"""
@doc
"""
Determine whether an activity can be relayed using the federation module.
"""
@callback
is_representable?
(
Pleroma.Activity
.
t
())
::
boolean
()
@doc
"""
Relays an activity to a specified peer, determined by the parameters. The
parameters used are controlled by the federation module.
"""
@callback
publish_one
(
Map
.
t
())
::
{
:ok
,
Map
.
t
()}
|
{
:error
,
any
()}
@doc
"""
Relays an activity to all specified peers.
"""
@callback
publish
(
Pleroma.User
.
t
(),
Pleroma.Activity
.
t
())
::
:ok
|
{
:error
,
any
()}
@doc
"""
Enqueue publishing a single activity.
"""
@spec
enqueue_one
(
module
(),
Map
.
t
())
::
:ok
def
enqueue_one
(
module
,
%{}
=
params
),
do
:
PleromaJobQueue
.
enqueue
(
:federation_outgoing
,
__MODULE__
,
[
:publish_one
,
module
,
params
])
@spec
perform
(
atom
(),
module
(),
any
())
::
{
:ok
,
any
()}
|
{
:error
,
any
()}
def
perform
(
:publish_one
,
module
,
params
)
do
case
apply
(
module
,
:publish_one
,
[
params
])
do
{
:ok
,
_
}
->
:ok
{
:error
,
_
}
->
RetryQueue
.
enqueue
(
params
,
module
)
end
end
def
perform
(
type
,
_
,
_
)
do
Logger
.
debug
(
"Unknown task:
#{
type
}
"
)
{
:error
,
"Don't know what to do with this"
}
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sun, Jun 28, 5:57 AM (17 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1630691
Default Alt Text
publisher.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment