Add attachments to the TwAPI.
This commit is contained in:
parent
42c90855ba
commit
73df2f8e5e
7 changed files with 73 additions and 13 deletions
|
|
@ -1,13 +1,27 @@
|
|||
defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
|
||||
use Pleroma.DataCase
|
||||
alias Pleroma.{User, Activity}
|
||||
alias Pleroma.Web.TwitterAPI.Representers.{UserRepresenter, ActivityRepresenter}
|
||||
alias Pleroma.{User, Activity, Object}
|
||||
alias Pleroma.Web.TwitterAPI.Representers.{UserRepresenter, ActivityRepresenter, ObjectRepresenter}
|
||||
alias Pleroma.Builders.UserBuilder
|
||||
|
||||
test "an activity" do
|
||||
{:ok, user} = UserBuilder.insert
|
||||
{:ok, follower} = UserBuilder.insert(%{following: [User.ap_followers(user)]})
|
||||
|
||||
object = %Object{
|
||||
data: %{
|
||||
"type" => "Image",
|
||||
"url" => [
|
||||
%{
|
||||
"type" => "Link",
|
||||
"mediaType" => "image/jpg",
|
||||
"href" => "http://example.org/image.jpg"
|
||||
}
|
||||
],
|
||||
"uuid" => 1
|
||||
}
|
||||
}
|
||||
|
||||
content = "Some content"
|
||||
date = DateTime.utc_now() |> DateTime.to_iso8601
|
||||
|
||||
|
|
@ -19,6 +33,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
|
|||
User.ap_followers(user),
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"attachment" => [
|
||||
object
|
||||
],
|
||||
"actor" => User.ap_id(user),
|
||||
"object" => %{
|
||||
"published" => date,
|
||||
|
|
@ -42,7 +59,10 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
|
|||
"is_post_verb" => true,
|
||||
"created_at" => date,
|
||||
"in_reply_to_status_id" => 213123,
|
||||
"statusnet_conversation_id" => 4711
|
||||
"statusnet_conversation_id" => 4711,
|
||||
"attachments" => [
|
||||
ObjectRepresenter.to_map(object)
|
||||
]
|
||||
}
|
||||
|
||||
assert ActivityRepresenter.to_map(activity, %{user: user, for: follower}) == expected_status
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ObjectReprenterTest do
|
|||
"mediaType" => "sometype",
|
||||
"href" => "someurl"
|
||||
}
|
||||
]
|
||||
],
|
||||
"uuid" => 6
|
||||
}
|
||||
}
|
||||
|
||||
expected_object = %{
|
||||
id: 5,
|
||||
id: 6,
|
||||
url: "someurl",
|
||||
mimetype: "sometype",
|
||||
oembed: false
|
||||
|
|
|
|||
|
|
@ -2,13 +2,28 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
use Pleroma.DataCase
|
||||
alias Pleroma.Builders.{UserBuilder, ActivityBuilder}
|
||||
alias Pleroma.Web.TwitterAPI.TwitterAPI
|
||||
alias Pleroma.{Activity, User}
|
||||
alias Pleroma.{Activity, User, Object, Repo}
|
||||
alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
|
||||
|
||||
test "create a status" do
|
||||
user = UserBuilder.build
|
||||
object_data = %{
|
||||
"type" => "Image",
|
||||
"url" => [
|
||||
%{
|
||||
"type" => "Link",
|
||||
"mediaType" => "image/jpg",
|
||||
"href" => "http://example.org/image.jpg"
|
||||
}
|
||||
],
|
||||
"uuid" => 1
|
||||
}
|
||||
|
||||
object = Repo.insert!(%Object{data: object_data})
|
||||
|
||||
input = %{
|
||||
"status" => "Hello again."
|
||||
"status" => "Hello again.",
|
||||
"media_ids" => [object.id]
|
||||
}
|
||||
|
||||
{ :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input)
|
||||
|
|
@ -24,6 +39,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
assert is_binary(get_in(activity.data, ["object", "context"]))
|
||||
assert get_in(activity.data, ["object", "statusnetConversationId"]) == activity.id
|
||||
assert get_in(activity.data, ["statusnetConversationId"]) == activity.id
|
||||
|
||||
assert is_list(activity.data["attachment"])
|
||||
end
|
||||
|
||||
test "create a status that is a reply" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue