Merge branch 'feature/unrepeats' into 'develop'
Add unrepeats Closes #69 See merge request pleroma/pleroma!113
This commit is contained in:
commit
aeff2d6474
14 changed files with 280 additions and 26 deletions
47
test/fixtures/mastodon-undo-announce.json
vendored
Normal file
47
test/fixtures/mastodon-undo-announce.json
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"type": "Undo",
|
||||
"signature": {
|
||||
"type": "RsaSignature2017",
|
||||
"signatureValue": "VU9AmHf3Pus9cWtMG/TOdxr+MRQfPHdTVKBBgFJBXhAlMhxEtcbxsu7zmqBgfIz6u0HpTCi5jRXEMftc228OJf/aBUkr4hyWADgcdmhPQgpibouDLgQf9BmnrPqb2rMbzZyt49GJkQZma8taLh077TTq6OKcnsAAJ1evEKOcRYS4OxBSwh4nI726bOXzZWoNzpTcrnm+llcUEN980sDSAS0uyZdb8AxZdfdG6DJQX4AkUD5qTpfqP/vC1ISirrNphvVhlxjUV9Amr4SYTsLx80vdZe5NjeL5Ir4jTIIQLedpxaDu1M9Q+Jpc0fYByQ2hOwUq8JxEmvHvarKjrq0Oww==",
|
||||
"creator": "http://mastodon.example.org/users/admin#main-key",
|
||||
"created": "2018-05-11T16:23:45Z"
|
||||
},
|
||||
"object": {
|
||||
"type": "Announce",
|
||||
"to": [
|
||||
"http://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"published": "2018-05-11T16:23:37Z",
|
||||
"object": "http://mastodon.example.org/@admin/99541947525187367",
|
||||
"id": "http://mastodon.example.org/users/admin/statuses/99542391527669785/activity",
|
||||
"cc": [
|
||||
"http://mastodon.example.org/users/admin",
|
||||
"http://mastodon.example.org/users/admin/followers"
|
||||
],
|
||||
"atomUri": "http://mastodon.example.org/users/admin/statuses/99542391527669785/activity",
|
||||
"actor": "http://mastodon.example.org/users/admin"
|
||||
},
|
||||
"id": "http://mastodon.example.org/users/admin#announces/100011594053806179/undo",
|
||||
"actor": "http://mastodon.example.org/users/admin",
|
||||
"@context": [
|
||||
"http://www.w3.org/ns/activitystreams",
|
||||
"http://w3id.org/security/v1",
|
||||
{
|
||||
"toot": "http://joinmastodon.org/ns#",
|
||||
"sensitive": "as:sensitive",
|
||||
"ostatus": "http://ostatus.org#",
|
||||
"movedTo": "as:movedTo",
|
||||
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
|
||||
"focalPoint": {
|
||||
"@id": "toot:focalPoint",
|
||||
"@container": "@list"
|
||||
},
|
||||
"featured": "toot:featured",
|
||||
"conversation": "ostatus:conversation",
|
||||
"atomUri": "ostatus:atomUri",
|
||||
"Hashtag": "as:Hashtag",
|
||||
"Emoji": "toot:Emoji"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -302,6 +302,38 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "unannouncing an object" do
|
||||
test "unannouncing a previously announced object" do
|
||||
note_activity = insert(:note_activity)
|
||||
object = Object.get_by_ap_id(note_activity.data["object"]["id"])
|
||||
user = insert(:user)
|
||||
|
||||
# Unannouncing an object that is not announced does nothing
|
||||
# {:ok, object} = ActivityPub.unannounce(user, object)
|
||||
# assert object.data["announcement_count"] == 0
|
||||
|
||||
{:ok, announce_activity, object} = ActivityPub.announce(user, object)
|
||||
assert object.data["announcement_count"] == 1
|
||||
|
||||
{:ok, unannounce_activity, activity, object} = ActivityPub.unannounce(user, object)
|
||||
assert object.data["announcement_count"] == 0
|
||||
|
||||
assert activity == announce_activity
|
||||
|
||||
assert unannounce_activity.data["to"] == [
|
||||
User.ap_followers(user),
|
||||
announce_activity.data["actor"]
|
||||
]
|
||||
|
||||
assert unannounce_activity.data["type"] == "Undo"
|
||||
assert unannounce_activity.data["object"] == announce_activity.data
|
||||
assert unannounce_activity.data["actor"] == user.ap_id
|
||||
assert unannounce_activity.data["context"] == announce_activity.data["context"]
|
||||
|
||||
assert Repo.get(Activity, announce_activity.id) == nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "uploading files" do
|
||||
test "copies the file to the configured folder" do
|
||||
file = %Plug.Upload{
|
||||
|
|
|
|||
|
|
@ -232,6 +232,34 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
refute Repo.get(Activity, activity.id)
|
||||
end
|
||||
|
||||
test "it works for incoming unannounces with an existing notice" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
|
||||
announce_data =
|
||||
File.read!("test/fixtures/mastodon-announce.json")
|
||||
|> Poison.decode!()
|
||||
|> Map.put("object", activity.data["object"]["id"])
|
||||
|
||||
{:ok, %Activity{data: announce_data, local: false}} =
|
||||
Transmogrifier.handle_incoming(announce_data)
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-undo-announce.json")
|
||||
|> Poison.decode!()
|
||||
|> Map.put("object", announce_data)
|
||||
|> Map.put("actor", announce_data["actor"])
|
||||
|
||||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert data["type"] == "Undo"
|
||||
assert data["object"]["type"] == "Announce"
|
||||
assert data["object"]["object"] == activity.data["object"]["id"]
|
||||
|
||||
assert data["object"]["id"] ==
|
||||
"http://mastodon.example.org/users/admin/statuses/99542391527669785/activity"
|
||||
end
|
||||
end
|
||||
|
||||
describe "prepare outgoing" do
|
||||
|
|
|
|||
|
|
@ -298,6 +298,24 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "unreblogging" do
|
||||
test "unreblogs and returns the unreblogged status", %{conn: conn} do
|
||||
activity = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, _, _} = CommonAPI.repeat(activity.id, user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/v1/statuses/#{activity.id}/unreblog")
|
||||
|
||||
assert %{"id" => id, "reblogged" => false, "reblogs_count" => 0} = json_response(conn, 200)
|
||||
|
||||
assert to_string(activity.id) == id
|
||||
end
|
||||
end
|
||||
|
||||
describe "favoriting" do
|
||||
test "favs a status and returns it", %{conn: conn} do
|
||||
activity = insert(:note_activity)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue