Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
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
Ivan Tashkinov
pleroma
Commits
e0b8c0cc
Commit
e0b8c0cc
authored
6 years ago
by
kaniini
Browse files
Options
Downloads
Patches
Plain Diff
MRF: reject non-public: use pattern match to remove unnecessary if block
parent
88094c26
Branches
feature/staff-discovery-api
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/pleroma/web/activity_pub/mrf/reject_non_public.ex
+32
-33
32 additions, 33 deletions
lib/pleroma/web/activity_pub/mrf/reject_non_public.ex
with
32 additions
and
33 deletions
lib/pleroma/web/activity_pub/mrf/reject_non_public.ex
+
32
−
33
View file @
e0b8c0cc
...
...
@@ -7,43 +7,42 @@ defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do
@allow_direct
Keyword
.
get
(
@mrf_rejectnonpublic
,
:allow_direct
)
@impl
true
def
filter
(
object
)
do
if
object
[
"type"
]
==
"Create"
do
user
=
User
.
get_cached_by_ap_id
(
object
[
"actor"
])
public
=
"https://www.w3.org/ns/activitystreams#Public"
# Determine visibility
visibility
=
cond
do
public
in
object
[
"to"
]
->
"public"
public
in
object
[
"cc"
]
->
"unlisted"
user
.
follower_address
in
object
[
"to"
]
->
"followers"
true
->
"direct"
end
def
filter
(%{
"type"
=>
"Create"
}
=
object
)
do
user
=
User
.
get_cached_by_ap_id
(
object
[
"actor"
])
public
=
"https://www.w3.org/ns/activitystreams#Public"
case
visibility
do
"public"
->
{
:ok
,
object
}
# Determine visibility
visibility
=
cond
do
public
in
object
[
"to"
]
->
"public"
public
in
object
[
"cc"
]
->
"unlisted"
user
.
follower_address
in
object
[
"to"
]
->
"followers"
true
->
"direct"
end
"unlisted"
->
case
visibility
do
"public"
->
{
:ok
,
object
}
"unlisted"
->
{
:ok
,
object
}
"followers"
->
with
true
<-
@allow_followersonly
do
{
:ok
,
object
}
else
_e
->
{
:reject
,
nil
}
end
"followers"
->
with
true
<-
@allow_followersonly
do
{
:ok
,
object
}
else
_e
->
{
:reject
,
nil
}
end
"direct"
->
with
true
<-
@allow_direct
do
{
:ok
,
object
}
else
_e
->
{
:reject
,
nil
}
end
end
else
{
:ok
,
object
}
"direct"
->
with
true
<-
@allow_direct
do
{
:ok
,
object
}
else
_e
->
{
:reject
,
nil
}
end
end
end
@impl
true
def
filter
(
object
),
do
:
{
:ok
,
object
}
end
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