describe "/inbox" do
test "it inserts an incoming activity into the database", %{conn: conn} do
- data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
+ data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
conn =
conn
data =
File.read!("test/fixtures/mastodon-post-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", user.ap_id)
|> put_in(["object", "attridbutedTo"], user.ap_id)
end
test "it clears `unreachable` federation status of the sender", %{conn: conn} do
- data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
+ data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
sender_url = data["actor"]
Instances.set_consistently_unreachable(sender_url)
test "without valid signature, " <>
"it only accepts Create activities and requires enabled federation",
%{conn: conn} do
- data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
- non_create_data = File.read!("test/fixtures/mastodon-announce.json") |> Poison.decode!()
+ data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
+ non_create_data = File.read!("test/fixtures/mastodon-announce.json") |> Jason.decode!()
conn = put_req_header(conn, "content-type", "application/activity+json")
setup do
data =
File.read!("test/fixtures/mastodon-post-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
[data: data]
end
data =
File.read!("test/fixtures/activitypub-client-post-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
object = Map.put(data["object"], "attributedTo", actor.ap_id)
defp get_old_message do
File.read!("test/fixtures/mastodon-post-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
end
defp get_new_message do
accept_data =
File.read!("test/fixtures/mastodon-accept-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", followed.ap_id)
object =
accept_data =
File.read!("test/fixtures/mastodon-accept-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", followed.ap_id)
|> Map.put("object", follow_activity.data["id"])
accept_data =
File.read!("test/fixtures/mastodon-accept-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", followed.ap_id)
accept_data =
end
test "it works for incoming announces with actor being inlined (kroeg)" do
- data = File.read!("test/fixtures/kroeg-announce-with-inline-actor.json") |> Poison.decode!()
+ data = File.read!("test/fixtures/kroeg-announce-with-inline-actor.json") |> Jason.decode!()
_user = insert(:user, local: false, ap_id: data["actor"]["id"])
other_user = insert(:user)
test "it works for incoming announces, fetching the announced object" do
data =
File.read!("test/fixtures/mastodon-announce.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", "http://mastodon.example.org/users/admin/statuses/99541947525187367")
Tesla.Mock.mock(fn
data =
File.read!("test/fixtures/mastodon-announce.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
_user = insert(:user, local: false, ap_id: data["actor"])
test "it works for incoming announces with an inlined activity" do
data =
File.read!("test/fixtures/mastodon-announce-private.json")
- |> Poison.decode!()
+ |> Jason.decode!()
_user =
insert(:user,
data =
File.read!("test/fixtures/bogus-mastodon-announce.json")
- |> Poison.decode!()
+ |> Jason.decode!()
_user = insert(:user, local: false, ap_id: data["actor"])
data =
File.read!("test/fixtures/mastodon-announce.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", Object.normalize(activity).data["id"])
|> Map.put("to", ["http://mastodon.example.org/users/admin/followers"])
|> Map.put("cc", [])
data =
File.read!("test/fixtures/mastodon-vote.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Kernel.put_in(["to"], user.ap_id)
|> Kernel.put_in(["object", "inReplyTo"], object.data["id"])
|> Kernel.put_in(["object", "to"], user.ap_id)
# TODO: Replace with CommonAPI vote creation when implemented
data =
File.read!("test/fixtures/mastodon-vote.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Kernel.put_in(["to"], user.ap_id)
|> Kernel.put_in(["object", "inReplyTo"], poll_object.data["id"])
|> Kernel.put_in(["object", "to"], user.ap_id)
}
end)
- data = File.read!("test/fixtures/tesla_mock/funkwhale_create_audio.json") |> Poison.decode!()
+ data = File.read!("test/fixtures/tesla_mock/funkwhale_create_audio.json") |> Jason.decode!()
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
data =
File.read!("test/fixtures/mastodon-block-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
blocker = insert(:user, ap_id: data["actor"])
data =
File.read!("test/fixtures/mastodon-block-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", blocked.ap_id)
|> Map.put("actor", blocker.ap_id)
test "it rejects messages that don't contain content" do
data =
File.read!("test/fixtures/create-chat-message.json")
- |> Poison.decode!()
+ |> Jason.decode!()
object =
data["object"]
test "it rejects messages that don't concern local users" do
data =
File.read!("test/fixtures/create-chat-message.json")
- |> Poison.decode!()
+ |> Jason.decode!()
_author =
insert(:user, ap_id: data["actor"], local: false, last_refreshed_at: DateTime.utc_now())
test "it rejects messages where the `to` field of activity and object don't match" do
data =
File.read!("test/fixtures/create-chat-message.json")
- |> Poison.decode!()
+ |> Jason.decode!()
author = insert(:user, ap_id: data["actor"])
_recipient = insert(:user, ap_id: List.first(data["to"]))
data =
File.read!("test/fixtures/create-chat-message.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", "http://mastodon.example.org/users/admin")
|> put_in(["object", "actor"], "http://mastodon.example.org/users/admin")
test "it doesn't work for deactivated users" do
data =
File.read!("test/fixtures/create-chat-message.json")
- |> Poison.decode!()
+ |> Jason.decode!()
_author =
insert(:user,
test "it inserts it and creates a chat" do
data =
File.read!("test/fixtures/create-chat-message.json")
- |> Poison.decode!()
+ |> Jason.decode!()
author =
insert(:user, ap_id: data["actor"], local: false, last_refreshed_at: DateTime.utc_now())
data =
File.read!("test/fixtures/mastodon-delete.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", deleting_user.ap_id)
|> put_in(["object", "id"], activity.data["object"])
data =
File.read!("test/fixtures/mastodon-delete.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", deleting_user.ap_id)
|> put_in(["object", "id"], activity.data["object"])
data =
File.read!("test/fixtures/mastodon-delete.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", ap_id)
|> put_in(["object", "id"], activity.data["object"])
data =
File.read!("test/fixtures/mastodon-delete-user.json")
- |> Poison.decode!()
+ |> Jason.decode!()
{:ok, _} = Transmogrifier.handle_incoming(data)
ObanHelpers.perform_all()
data =
File.read!("test/fixtures/mastodon-delete-user.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", ap_id)
assert match?({:error, _}, Transmogrifier.handle_incoming(data))
data =
File.read!("test/fixtures/emoji-reaction.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
|> Map.put("actor", other_user.ap_id)
data =
File.read!("test/fixtures/emoji-reaction-too-long.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
|> Map.put("actor", other_user.ap_id)
data =
File.read!("test/fixtures/emoji-reaction-no-emoji.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
|> Map.put("actor", other_user.ap_id)
data =
File.read!("test/fixtures/osada-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
{:ok, %Activity{data: data, local: false} = activity} = Transmogrifier.handle_incoming(data)
data =
File.read!("test/fixtures/mastodon-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
{:ok, %Activity{data: data, local: false} = activity} = Transmogrifier.handle_incoming(data)
data =
File.read!("test/fixtures/mastodon-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
data =
File.read!("test/fixtures/mastodon-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
{:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data)
data =
File.read!("test/fixtures/mastodon-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("id", String.replace(data["id"], "2", "3"))
|> Map.put("object", user.ap_id)
data =
File.read!("test/fixtures/mastodon-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
{:ok, %Activity{data: %{"id" => id}}} = Transmogrifier.handle_incoming(data)
data =
File.read!("test/fixtures/mastodon-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
with_mock Pleroma.User, [:passthrough], follow: fn _, _, _ -> {:error, :testing} end do
data =
File.read!("test/fixtures/hubzilla-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
|> Utils.normalize_params()
data =
File.read!("test/fixtures/mastodon-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
data =
File.read!("test/fixtures/mastodon-like.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
_actor = insert(:user, ap_id: data["actor"], local: false)
data =
File.read!("test/fixtures/misskey-like.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
_actor = insert(:user, ap_id: data["actor"], local: false)
data =
File.read!("test/fixtures/misskey-like.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
|> Map.put("_misskey_reaction", "⭐")
end
test "Mastodon Question activity" do
- data = File.read!("test/fixtures/mastodon-question-activity.json") |> Poison.decode!()
+ data = File.read!("test/fixtures/mastodon-question-activity.json") |> Jason.decode!()
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
data =
File.read!("test/fixtures/mastodon-question-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Kernel.put_in(["object", "oneOf"], options)
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
data =
File.read!("test/fixtures/mastodon-question-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Kernel.put_in(["object", "oneOf"], options)
|> Kernel.put_in(["object", "tag"], tag)
end
test "returns same activity if received a second time" do
- data = File.read!("test/fixtures/mastodon-question-activity.json") |> Poison.decode!()
+ data = File.read!("test/fixtures/mastodon-question-activity.json") |> Jason.decode!()
assert {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
test "accepts a Question with no content" do
data =
File.read!("test/fixtures/mastodon-question-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Kernel.put_in(["object", "content"], "")
assert {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data)
accept_data =
File.read!("test/fixtures/mastodon-reject-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", followed.ap_id)
accept_data =
reject_data =
File.read!("test/fixtures/mastodon-reject-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", followed.ap_id)
|> Map.put("object", follow_activity.data["id"])
data =
File.read!("test/fixtures/mastodon-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
|> Map.put("id", "")
data =
File.read!("test/fixtures/mastodon-undo-like.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", reaction_activity.data["id"])
|> Map.put("actor", user.ap_id)
data =
File.read!("test/fixtures/mastodon-undo-like.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
assert Transmogrifier.handle_incoming(data) == :error
like_data =
File.read!("test/fixtures/mastodon-like.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
_liker = insert(:user, ap_id: like_data["actor"], local: false)
data =
File.read!("test/fixtures/mastodon-undo-like.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", like_data)
|> Map.put("actor", like_data["actor"])
like_data =
File.read!("test/fixtures/mastodon-like.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
_liker = insert(:user, ap_id: like_data["actor"], local: false)
data =
File.read!("test/fixtures/mastodon-undo-like.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", like_data["id"])
|> Map.put("actor", like_data["actor"])
announce_data =
File.read!("test/fixtures/mastodon-announce.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
_announcer = insert(:user, ap_id: announce_data["actor"], local: false)
data =
File.read!("test/fixtures/mastodon-undo-announce.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", announce_data)
|> Map.put("actor", announce_data["actor"])
follow_data =
File.read!("test/fixtures/mastodon-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
_follower = insert(:user, ap_id: follow_data["actor"], local: false)
data =
File.read!("test/fixtures/mastodon-unfollow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", follow_data)
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
block_data =
File.read!("test/fixtures/mastodon-block-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
_blocker = insert(:user, ap_id: block_data["actor"], local: false)
data =
File.read!("test/fixtures/mastodon-unblock-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", block_data)
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
test "it works for incoming update activities" do
user = insert(:user, local: false)
- update_data = File.read!("test/fixtures/mastodon-update.json") |> Poison.decode!()
+ update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
object =
update_data["object"]
{:ok, _activity} =
"test/fixtures/mastodon-update.json"
|> File.read!()
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("actor", actor)
|> Map.update!("object", fn object ->
object
assert user.fields == []
- update_data = File.read!("test/fixtures/mastodon-update.json") |> Poison.decode!()
+ update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
object =
update_data["object"]
test "it works for incoming update activities which lock the account" do
user = insert(:user, local: false)
- update_data = File.read!("test/fixtures/mastodon-update.json") |> Poison.decode!()
+ update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
object =
update_data["object"]
follow_data =
File.read!("test/fixtures/mastodon-follow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", user.ap_id)
{:ok, %Activity{data: _, local: false}} = Transmogrifier.handle_incoming(follow_data)
data =
File.read!("test/fixtures/mastodon-unfollow-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", follow_data)
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
params =
File.read!("test/fixtures/mastodon-post-activity.json")
- |> Poison.decode!()
+ |> Jason.decode!()
assert {:ok, job} = Federator.incoming_ap_doc(params)
assert {:error, _} = ObanHelpers.perform(job)
redirect_query = URI.parse(redirected_to(conn)).query
assert %{"state" => state_param} = URI.decode_query(redirect_query)
- assert {:ok, state_components} = Poison.decode(state_param)
+ assert {:ok, state_components} = Jason.decode(state_param)
expected_client_id = app.client_id
expected_redirect_uri = app.redirect_uris
"oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
"oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
"provider" => "twitter",
- "state" => Poison.encode!(state_params)
+ "state" => Jason.encode!(state_params)
}
)
"oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
"oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
"provider" => "twitter",
- "state" => Poison.encode!(state_params)
+ "state" => Jason.encode!(state_params)
}
)
"oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
"oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
"provider" => "twitter",
- "state" => Poison.encode!(state_params)
+ "state" => Jason.encode!(state_params)
}
)
data =
File.read!("test/fixtures/mastodon-announce.json")
- |> Poison.decode!()
+ |> Jason.decode!()
|> Map.put("object", activity.data["object"])
|> Map.put("actor", user.ap_id)
assigns = Map.new(assigns)
view.render(template, assigns)
- |> Poison.encode!()
- |> Poison.decode!()
+ |> Jason.encode!()
+ |> Jason.decode!()
end
def stringify_keys(nil), do: nil