Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F12554226
subchain_policy.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
subchain_policy.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.Web.ActivityPub.MRF.SubchainPolicy
do
alias
Pleroma.Config
alias
Pleroma.Web.ActivityPub.MRF
require
Logger
@behaviour
Pleroma.Web.ActivityPub.MRF.Policy
defp
lookup_subchain
(
actor
)
do
with
matches
<-
Config
.
get
([
:mrf_subchain
,
:match_actor
]),
{
match
,
subchain
}
<-
Enum
.
find
(
matches
,
fn
{
k
,
_v
}
->
String
.
match?
(
actor
,
k
)
end
)
do
{
:ok
,
match
,
subchain
}
else
_e
->
{
:error
,
:notfound
}
end
end
@impl
true
def
filter
(%{
"actor"
=>
actor
}
=
activity
)
do
with
{
:ok
,
match
,
subchain
}
<-
lookup_subchain
(
actor
)
do
Logger
.
debug
(
"[SubchainPolicy] Matched
#{
actor
}
against
#{
inspect
(
match
)
}
with subchain
#{
inspect
(
subchain
)
}
"
)
MRF
.
filter
(
subchain
,
activity
)
else
_e
->
{
:ok
,
activity
}
end
end
@impl
true
def
filter
(
activity
),
do
:
{
:ok
,
activity
}
@impl
true
def
describe
,
do
:
{
:ok
,
%{}}
@impl
true
def
config_description
do
%{
key
:
:mrf_subchain
,
related_policy
:
"Pleroma.Web.ActivityPub.MRF.SubchainPolicy"
,
label
:
"MRF Subchain"
,
description
:
"This policy processes activities through an alternate pipeline when a given activity matches certain criteria."
<>
" All criteria are configured as a map of regular expressions to lists of policy modules."
,
children
:
[
%{
key
:
:match_actor
,
type
:
{
:map
,
{
:list
,
:string
}},
description
:
"Matches a series of regular expressions against the actor field"
,
suggestions
:
[
%{
~r/https:\/\/example.com/s
=>
[
Pleroma.Web.ActivityPub.MRF.DropPolicy
]
}
]
}
]
}
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sat, Nov 15, 3:13 AM (3 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
632256
Default Alt Text
subchain_policy.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment