aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-09-27 23:09:07 +0000
committerrinpatch <rinpatch@sdf.org>2019-09-27 23:09:07 +0000
commita0f42ecbca7d1aabc0fb699084865231e32ec6d9 (patch)
tree6f5dda6e1fe52b5de220a438ac2d69c9f4cae053
parent705ea1b975779180c15d7b32d22f7fb9a11b2ed9 (diff)
parent374f83d29b5793d75a3a6be7c18cf52cfed42b64 (diff)
downloadpleroma-a0f42ecbca7d1aabc0fb699084865231e32ec6d9.tar.gz
Merge branch 'fix/empty-attachment-statuses' into 'develop'
Fix not being able to post empty statuses with attachments See merge request pleroma/pleroma!1734
-rw-r--r--lib/pleroma/web/common_api/activity_draft.ex2
-rw-r--r--test/web/mastodon_api/controllers/status_controller_test.exs22
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/pleroma/web/common_api/activity_draft.ex b/lib/pleroma/web/common_api/activity_draft.ex
index aa7c8c381..f7da81b34 100644
--- a/lib/pleroma/web/common_api/activity_draft.ex
+++ b/lib/pleroma/web/common_api/activity_draft.ex
@@ -40,11 +40,11 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
|> put_params(params)
|> status()
|> summary()
+ |> with_valid(&attachments/1)
|> full_payload()
|> expires_at()
|> poll()
|> with_valid(&in_reply_to/1)
- |> with_valid(&attachments/1)
|> with_valid(&in_reply_to_conversation/1)
|> with_valid(&visibility/1)
|> content()
diff --git a/test/web/mastodon_api/controllers/status_controller_test.exs b/test/web/mastodon_api/controllers/status_controller_test.exs
index cbd4bafe8..c0121ac63 100644
--- a/test/web/mastodon_api/controllers/status_controller_test.exs
+++ b/test/web/mastodon_api/controllers/status_controller_test.exs
@@ -99,6 +99,28 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
NaiveDateTime.to_iso8601(expiration.scheduled_at)
end
+ test "posting an empty status with an attachment", %{conn: conn} do
+ user = insert(:user)
+
+ file = %Plug.Upload{
+ content_type: "image/jpg",
+ path: Path.absname("test/fixtures/image.jpg"),
+ filename: "an_image.jpg"
+ }
+
+ {:ok, upload} = ActivityPub.upload(file, actor: user.ap_id)
+
+ conn =
+ conn
+ |> assign(:user, user)
+ |> post("/api/v1/statuses", %{
+ "media_ids" => [to_string(upload.id)],
+ "status" => ""
+ })
+
+ assert json_response(conn, 200)
+ end
+
test "replying to a status", %{conn: conn} do
user = insert(:user)
{:ok, replied_to} = CommonAPI.post(user, %{"status" => "cofe"})