forked from AkkomaGang/akkoma
Transmogrify outgoing nsfw.
This commit is contained in:
parent
8ca66b5961
commit
20e6190ead
2 changed files with 15 additions and 0 deletions
|
@ -100,6 +100,7 @@ def get_obj_helper(id) do
|
||||||
"""
|
"""
|
||||||
def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do
|
def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do
|
||||||
object = object
|
object = object
|
||||||
|
|> set_sensitive
|
||||||
|> add_hashtags
|
|> add_hashtags
|
||||||
|> add_mention_tags
|
|> add_mention_tags
|
||||||
|> add_attributed_to
|
|> add_attributed_to
|
||||||
|
@ -144,6 +145,11 @@ def set_conversation(object) do
|
||||||
Map.put(object, "conversation", object["context"])
|
Map.put(object, "conversation", object["context"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_sensitive(object) do
|
||||||
|
tags = object["tag"] || []
|
||||||
|
Map.put(object, "sensitive", "nsfw" in tags)
|
||||||
|
end
|
||||||
|
|
||||||
def add_attributed_to(object) do
|
def add_attributed_to(object) do
|
||||||
attributedTo = object["attributedTo"] || object["actor"]
|
attributedTo = object["attributedTo"] || object["actor"]
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,15 @@ test "it turns mentions into tags" do
|
||||||
assert Enum.member?(object["tag"], expected_mention)
|
assert Enum.member?(object["tag"], expected_mention)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it adds the sensitive property" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, activity} = CommonAPI.post(user, %{"status" => "#nsfw hey"})
|
||||||
|
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
||||||
|
|
||||||
|
assert modified["object"]["sensitive"]
|
||||||
|
end
|
||||||
|
|
||||||
test "it adds the json-ld context and the conversation property" do
|
test "it adds the json-ld context and the conversation property" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue