Add new Emoji Ecto.Type and fix emoji in Question
This commit is contained in:
parent
2ecc7d9230
commit
a142da3e4f
8 changed files with 105 additions and 9 deletions
|
|
@ -69,6 +69,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
|
|||
assert {:ok, object, _meta} = ObjectValidator.validate(valid_chat_message, [])
|
||||
|
||||
assert Map.put(valid_chat_message, "attachment", nil) == object
|
||||
assert match?(%{"firefox" => _}, object["emoji"])
|
||||
end
|
||||
|
||||
test "validates for a basic object with an attachment", %{
|
||||
|
|
|
|||
|
|
@ -106,6 +106,57 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
|
|||
assert Enum.sort(object.data["oneOf"]) == Enum.sort(options)
|
||||
end
|
||||
|
||||
test "Mastodon Question activity with custom emojis" do
|
||||
options = [
|
||||
%{
|
||||
"type" => "Note",
|
||||
"name" => ":blobcat:",
|
||||
"replies" => %{"totalItems" => 0, "type" => "Collection"}
|
||||
},
|
||||
%{
|
||||
"type" => "Note",
|
||||
"name" => ":blobfox:",
|
||||
"replies" => %{"totalItems" => 0, "type" => "Collection"}
|
||||
}
|
||||
]
|
||||
|
||||
tag = [
|
||||
%{
|
||||
"icon" => %{
|
||||
"type" => "Image",
|
||||
"url" => "https://blob.cat/emoji/custom/blobcats/blobcat.png"
|
||||
},
|
||||
"id" => "https://blob.cat/emoji/custom/blobcats/blobcat.png",
|
||||
"name" => ":blobcat:",
|
||||
"type" => "Emoji",
|
||||
"updated" => "1970-01-01T00:00:00Z"
|
||||
},
|
||||
%{
|
||||
"icon" => %{"type" => "Image", "url" => "https://blob.cat/emoji/blobfox/blobfox.png"},
|
||||
"id" => "https://blob.cat/emoji/blobfox/blobfox.png",
|
||||
"name" => ":blobfox:",
|
||||
"type" => "Emoji",
|
||||
"updated" => "1970-01-01T00:00:00Z"
|
||||
}
|
||||
]
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-question-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Kernel.put_in(["object", "oneOf"], options)
|
||||
|> Kernel.put_in(["object", "tag"], tag)
|
||||
|
||||
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
object = Object.normalize(activity, false)
|
||||
|
||||
assert object.data["oneOf"] == options
|
||||
|
||||
assert object.data["emoji"] == %{
|
||||
"blobcat" => "https://blob.cat/emoji/custom/blobcats/blobcat.png",
|
||||
"blobfox" => "https://blob.cat/emoji/blobfox/blobfox.png"
|
||||
}
|
||||
end
|
||||
|
||||
test "returns an error if received a second time" do
|
||||
data = File.read!("test/fixtures/mastodon-question-activity.json") |> Poison.decode!()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue