"""
def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do
object = object
+ |> set_sensitive
|> add_hashtags
|> add_mention_tags
|> add_attributed_to
Map.put(object, "conversation", object["context"])
end
+ def set_sensitive(object) do
+ tags = object["tag"] || []
+ Map.put(object, "sensitive", "nsfw" in tags)
+ end
+
def add_attributed_to(object) do
attributedTo = object["attributedTo"] || object["actor"]
assert Enum.member?(object["tag"], expected_mention)
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
user = insert(:user)