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
normandy
pleroma
Commits
88e32a32
Commit
88e32a32
authored
6 years ago
by
kaniini
Browse files
Options
Downloads
Patches
Plain Diff
mrf: add initial MRF.TagPolicy engine
parent
93e136d7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/pleroma/web/activity_pub/mrf/tag_policy.ex
+54
-0
54 additions, 0 deletions
lib/pleroma/web/activity_pub/mrf/tag_policy.ex
with
54 additions
and
0 deletions
lib/pleroma/web/activity_pub/mrf/tag_policy.ex
0 → 100644
+
54
−
0
View file @
88e32a32
# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma
.
Web
.
ActivityPub
.
MRF
.
TagPolicy
do
alias
Pleroma
.
User
@behaviour
Pleroma
.
Web
.
ActivityPub
.
MRF
defp
get_tags
(%
User
{
tags:
tags
})
when
is_list
(
tags
),
do
:
tags
defp
get_tags
(
_
),
do
:
[]
defp
process_tag
(
"mrf_tag:media-force-nsfw"
,
%{
"type"
=>
"Create"
,
"object"
=>
%{
"attachment"
=>
child_attachment
}
=
object
}
=
message
)
when
length
(
child_attachment
)
>
0
do
tags
=
(
object
[
"tag"
]
||
[])
++
[
"nsfw"
]
object
=
object
|>
Map
.
put
(
"tags"
,
tags
)
|>
Map
.
put
(
"sensitive"
,
true
)
message
=
Map
.
put
(
message
,
"object"
,
object
)
{
:ok
,
message
}
end
defp
process_tag
(
"mrf_tag:media-strip"
,
%{
"type"
=>
"Create"
,
"object"
=>
%{
"attachment"
=>
child_attachment
}
=
object
}
=
message
)
when
length
(
child_attachment
)
>
0
do
object
=
Map
.
delete
(
object
,
"attachment"
)
message
=
Map
.
put
(
message
,
"object"
,
object
)
{
:ok
,
message
}
end
defp
process_tag
(
_
,
message
),
do
:
{
:ok
,
message
}
@impl
true
def
filter
(%{
"actor"
=>
actor
}
=
message
)
do
User
.
get_cached_by_ap_id
(
actor
)
|>
get_tags
()
|>
Enum
.
reduce
({
:ok
,
message
},
fn
tag
,
{
:ok
,
message
}
->
process_tag
(
tag
,
message
)
_
,
error
->
error
end
)
end
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