Add #nsfw tag if sensitive content bit is set
This commit is contained in:
parent
4647bcd6e6
commit
f53cdabcdf
3 changed files with 14 additions and 2 deletions
|
|
@ -7,9 +7,10 @@ defmodule Pleroma.Formatter do
|
|||
end
|
||||
|
||||
@tag_regex ~r/\#\w+/u
|
||||
def parse_tags(text) do
|
||||
def parse_tags(text, data \\ %{}) do
|
||||
Regex.scan(@tag_regex, text)
|
||||
|> Enum.map(fn (["#" <> tag = full_tag]) -> {full_tag, String.downcase(tag)} end)
|
||||
|> (fn map -> if data["sensitive"], do: [{"#nsfw", "nsfw"}] ++ map, else: map end).()
|
||||
end
|
||||
|
||||
def parse_mentions(text) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue