caf2594c0330c6052d94ccc4eb9ddd6aa9206479
[akkoma] / test / pleroma / web / mastodon_api / views / status_view_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
6 use Pleroma.DataCase
7
8 alias Pleroma.Activity
9 alias Pleroma.Bookmark
10 alias Pleroma.Conversation.Participation
11 alias Pleroma.HTML
12 alias Pleroma.Object
13 alias Pleroma.Repo
14 alias Pleroma.User
15 alias Pleroma.UserRelationship
16 alias Pleroma.Web.CommonAPI
17 alias Pleroma.Web.CommonAPI.Utils
18 alias Pleroma.Web.MastodonAPI.AccountView
19 alias Pleroma.Web.MastodonAPI.StatusView
20
21 import Pleroma.Factory
22 import Tesla.Mock
23 import OpenApiSpex.TestAssertions
24
25 setup do
26 mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
27 :ok
28 end
29
30 test "has an emoji reaction list" do
31 user = insert(:user)
32 other_user = insert(:user)
33 third_user = insert(:user)
34 {:ok, activity} = CommonAPI.post(user, %{status: "dae cofe??"})
35
36 {:ok, _} = CommonAPI.react_with_emoji(activity.id, user, "☕")
37 {:ok, _} = CommonAPI.react_with_emoji(activity.id, user, ":dinosaur:")
38 {:ok, _} = CommonAPI.react_with_emoji(activity.id, third_user, "🍵")
39 {:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
40 {:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, ":dinosaur:")
41
42 activity = Repo.get(Activity, activity.id)
43 status = StatusView.render("show.json", activity: activity)
44
45 assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
46
47 assert status[:pleroma][:emoji_reactions] == [
48 %{name: "☕", count: 2, me: false, url: nil},
49 %{
50 count: 2,
51 me: false,
52 name: "dinosaur",
53 url: "http://localhost:4001/emoji/dino walking.gif"
54 },
55 %{name: "🍵", count: 1, me: false, url: nil}
56 ]
57
58 status = StatusView.render("show.json", activity: activity, for: user)
59
60 assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
61
62 assert status[:pleroma][:emoji_reactions] == [
63 %{name: "☕", count: 2, me: true, url: nil},
64 %{
65 count: 2,
66 me: true,
67 name: "dinosaur",
68 url: "http://localhost:4001/emoji/dino walking.gif"
69 },
70 %{name: "🍵", count: 1, me: false, url: nil}
71 ]
72 end
73
74 test "works correctly with badly formatted emojis" do
75 user = insert(:user)
76 {:ok, activity} = CommonAPI.post(user, %{status: "yo"})
77
78 activity
79 |> Object.normalize(fetch: false)
80 |> Object.update_data(%{"reactions" => %{"☕" => [user.ap_id], "x" => 1}})
81
82 activity = Activity.get_by_id(activity.id)
83 status = StatusView.render("show.json", activity: activity, for: user)
84
85 assert status[:pleroma][:emoji_reactions] == [
86 %{name: "☕", count: 1, me: true, url: nil}
87 ]
88 end
89
90 test "doesn't show reactions from muted and blocked users" do
91 user = insert(:user)
92 other_user = insert(:user)
93 third_user = insert(:user)
94
95 {:ok, activity} = CommonAPI.post(user, %{status: "dae cofe??"})
96
97 {:ok, _} = User.mute(user, other_user)
98 {:ok, _} = User.block(other_user, third_user)
99
100 {:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
101
102 activity = Repo.get(Activity, activity.id)
103 status = StatusView.render("show.json", activity: activity)
104
105 assert status[:pleroma][:emoji_reactions] == [
106 %{name: "☕", count: 1, me: false, url: nil}
107 ]
108
109 status = StatusView.render("show.json", activity: activity, for: user)
110
111 assert status[:pleroma][:emoji_reactions] == []
112
113 {:ok, _} = CommonAPI.react_with_emoji(activity.id, third_user, "☕")
114
115 status = StatusView.render("show.json", activity: activity)
116
117 assert status[:pleroma][:emoji_reactions] == [
118 %{name: "☕", count: 2, me: false, url: nil}
119 ]
120
121 status = StatusView.render("show.json", activity: activity, for: user)
122
123 assert status[:pleroma][:emoji_reactions] == [
124 %{name: "☕", count: 1, me: false, url: nil}
125 ]
126
127 status = StatusView.render("show.json", activity: activity, for: other_user)
128
129 assert status[:pleroma][:emoji_reactions] == [
130 %{name: "☕", count: 1, me: true, url: nil}
131 ]
132 end
133
134 test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do
135 user = insert(:user)
136
137 {:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
138 [participation] = Participation.for_user(user)
139
140 status =
141 StatusView.render("show.json",
142 activity: activity,
143 with_direct_conversation_id: true,
144 for: user
145 )
146
147 assert status[:pleroma][:direct_conversation_id] == participation.id
148
149 status = StatusView.render("show.json", activity: activity, for: user)
150 assert status[:pleroma][:direct_conversation_id] == nil
151 assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
152 end
153
154 test "returns the direct conversation id when given the `direct_conversation_id` option" do
155 user = insert(:user)
156
157 {:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
158 [participation] = Participation.for_user(user)
159
160 status =
161 StatusView.render("show.json",
162 activity: activity,
163 direct_conversation_id: participation.id,
164 for: user
165 )
166
167 assert status[:pleroma][:direct_conversation_id] == participation.id
168 assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
169 end
170
171 test "returns a temporary ap_id based user for activities missing db users" do
172 user = insert(:user)
173
174 {:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
175
176 Repo.delete(user)
177 User.invalidate_cache(user)
178
179 finger_url =
180 "https://localhost/.well-known/webfinger?resource=acct:#{user.nickname}@localhost"
181
182 Tesla.Mock.mock_global(fn
183 %{method: :get, url: "http://localhost/.well-known/host-meta"} ->
184 %Tesla.Env{status: 404, body: ""}
185
186 %{method: :get, url: "https://localhost/.well-known/host-meta"} ->
187 %Tesla.Env{status: 404, body: ""}
188
189 %{
190 method: :get,
191 url: ^finger_url
192 } ->
193 %Tesla.Env{status: 404, body: ""}
194 end)
195
196 %{account: ms_user} = StatusView.render("show.json", activity: activity)
197
198 assert ms_user.acct == "erroruser@example.com"
199 end
200
201 test "tries to get a user by nickname if fetching by ap_id doesn't work" do
202 user = insert(:user)
203
204 {:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
205
206 {:ok, user} =
207 user
208 |> Ecto.Changeset.change(%{ap_id: "#{user.ap_id}/extension/#{user.nickname}"})
209 |> Repo.update()
210
211 User.invalidate_cache(user)
212
213 result = StatusView.render("show.json", activity: activity)
214
215 assert result[:account][:id] == to_string(user.id)
216 assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
217 end
218
219 test "a note with null content" do
220 note = insert(:note_activity)
221 note_object = Object.normalize(note, fetch: false)
222
223 data =
224 note_object.data
225 |> Map.put("content", nil)
226
227 Object.change(note_object, %{data: data})
228 |> Object.update_and_set_cache()
229
230 User.get_cached_by_ap_id(note.data["actor"])
231
232 status = StatusView.render("show.json", %{activity: note})
233
234 assert status.content == ""
235 assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
236 end
237
238 test "a note activity" do
239 note = insert(:note_activity)
240 object_data = Object.normalize(note, fetch: false).data
241 user = User.get_cached_by_ap_id(note.data["actor"])
242
243 convo_id = Utils.context_to_conversation_id(object_data["context"])
244
245 status = StatusView.render("show.json", %{activity: note})
246
247 created_at =
248 (object_data["published"] || "")
249 |> String.replace(~r/\.\d+Z/, ".000Z")
250
251 expected = %{
252 id: to_string(note.id),
253 uri: object_data["id"],
254 url: Pleroma.Web.Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, note),
255 account: AccountView.render("show.json", %{user: user, skip_visibility_check: true}),
256 in_reply_to_id: nil,
257 in_reply_to_account_id: nil,
258 card: nil,
259 reblog: nil,
260 content: HTML.filter_tags(object_data["content"]),
261 text: nil,
262 created_at: created_at,
263 reblogs_count: 0,
264 replies_count: 0,
265 favourites_count: 0,
266 reblogged: false,
267 bookmarked: false,
268 favourited: false,
269 muted: false,
270 pinned: false,
271 sensitive: false,
272 poll: nil,
273 spoiler_text: HTML.filter_tags(object_data["summary"]),
274 visibility: "public",
275 media_attachments: [],
276 mentions: [],
277 tags: [
278 %{
279 name: "#{hd(object_data["tag"])}",
280 url: "http://localhost:4001/tag/#{hd(object_data["tag"])}"
281 }
282 ],
283 application: nil,
284 language: nil,
285 emojis: [
286 %{
287 shortcode: "2hu",
288 url: "corndog.png",
289 static_url: "corndog.png",
290 visible_in_picker: false
291 }
292 ],
293 pleroma: %{
294 local: true,
295 conversation_id: convo_id,
296 in_reply_to_account_acct: nil,
297 content: %{"text/plain" => HTML.strip_tags(object_data["content"])},
298 spoiler_text: %{"text/plain" => HTML.strip_tags(object_data["summary"])},
299 expires_at: nil,
300 direct_conversation_id: nil,
301 thread_muted: false,
302 emoji_reactions: [],
303 parent_visible: false,
304 pinned_at: nil
305 },
306 akkoma: %{
307 source: HTML.filter_tags(object_data["content"])
308 }
309 }
310
311 assert status == expected
312 assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
313 end
314
315 test "tells if the message is muted for some reason" do
316 user = insert(:user)
317 other_user = insert(:user)
318
319 {:ok, _user_relationships} = User.mute(user, other_user)
320
321 {:ok, activity} = CommonAPI.post(other_user, %{status: "test"})
322
323 relationships_opt = UserRelationship.view_relationships_option(user, [other_user])
324
325 opts = %{activity: activity}
326 status = StatusView.render("show.json", opts)
327 assert status.muted == false
328 assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
329
330 status = StatusView.render("show.json", Map.put(opts, :relationships, relationships_opt))
331 assert status.muted == false
332
333 for_opts = %{activity: activity, for: user}
334 status = StatusView.render("show.json", for_opts)
335 assert status.muted == true
336
337 status = StatusView.render("show.json", Map.put(for_opts, :relationships, relationships_opt))
338 assert status.muted == true
339 assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
340 end
341
342 test "tells if the message is thread muted" do
343 user = insert(:user)
344 other_user = insert(:user)
345
346 {:ok, _user_relationships} = User.mute(user, other_user)
347
348 {:ok, activity} = CommonAPI.post(other_user, %{status: "test"})
349 status = StatusView.render("show.json", %{activity: activity, for: user})
350
351 assert status.pleroma.thread_muted == false
352
353 {:ok, activity} = CommonAPI.add_mute(user, activity)
354
355 status = StatusView.render("show.json", %{activity: activity, for: user})
356
357 assert status.pleroma.thread_muted == true
358 end
359
360 test "tells if the status is bookmarked" do
361 user = insert(:user)
362
363 {:ok, activity} = CommonAPI.post(user, %{status: "Cute girls doing cute things"})
364 status = StatusView.render("show.json", %{activity: activity})
365
366 assert status.bookmarked == false
367
368 status = StatusView.render("show.json", %{activity: activity, for: user})
369
370 assert status.bookmarked == false
371
372 {:ok, _bookmark} = Bookmark.create(user.id, activity.id)
373
374 activity = Activity.get_by_id_with_object(activity.id)
375
376 status = StatusView.render("show.json", %{activity: activity, for: user})
377
378 assert status.bookmarked == true
379 end
380
381 test "a reply" do
382 note = insert(:note_activity)
383 user = insert(:user)
384
385 {:ok, activity} = CommonAPI.post(user, %{status: "he", in_reply_to_status_id: note.id})
386
387 status = StatusView.render("show.json", %{activity: activity})
388
389 assert status.in_reply_to_id == to_string(note.id)
390
391 [status] = StatusView.render("index.json", %{activities: [activity], as: :activity})
392
393 assert status.in_reply_to_id == to_string(note.id)
394 end
395
396 test "contains mentions" do
397 user = insert(:user)
398 mentioned = insert(:user)
399
400 {:ok, activity} = CommonAPI.post(user, %{status: "hi @#{mentioned.nickname}"})
401
402 status = StatusView.render("show.json", %{activity: activity})
403
404 assert status.mentions ==
405 Enum.map([mentioned], fn u -> AccountView.render("mention.json", %{user: u}) end)
406
407 assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
408 end
409
410 test "create mentions from the 'to' field" do
411 %User{ap_id: recipient_ap_id} = insert(:user)
412 cc = insert_pair(:user) |> Enum.map(& &1.ap_id)
413
414 object =
415 insert(:note, %{
416 data: %{
417 "to" => [recipient_ap_id],
418 "cc" => cc
419 }
420 })
421
422 activity =
423 insert(:note_activity, %{
424 note: object,
425 recipients: [recipient_ap_id | cc]
426 })
427
428 assert length(activity.recipients) == 3
429
430 %{mentions: [mention] = mentions} = StatusView.render("show.json", %{activity: activity})
431
432 assert length(mentions) == 1
433 assert mention.url == recipient_ap_id
434 end
435
436 test "create mentions from the 'tag' field" do
437 recipient = insert(:user)
438 cc = insert_pair(:user) |> Enum.map(& &1.ap_id)
439
440 object =
441 insert(:note, %{
442 data: %{
443 "cc" => cc,
444 "tag" => [
445 %{
446 "href" => recipient.ap_id,
447 "name" => recipient.nickname,
448 "type" => "Mention"
449 },
450 %{
451 "href" => "https://example.com/search?tag=test",
452 "name" => "#test",
453 "type" => "Hashtag"
454 }
455 ]
456 }
457 })
458
459 activity =
460 insert(:note_activity, %{
461 note: object,
462 recipients: [recipient.ap_id | cc]
463 })
464
465 assert length(activity.recipients) == 3
466
467 %{mentions: [mention] = mentions} = StatusView.render("show.json", %{activity: activity})
468
469 assert length(mentions) == 1
470 assert mention.url == recipient.ap_id
471 end
472
473 test "attachments" do
474 object = %{
475 "type" => "Image",
476 "url" => [
477 %{
478 "mediaType" => "image/png",
479 "href" => "someurl",
480 "width" => 200,
481 "height" => 100
482 }
483 ],
484 "blurhash" => "UJJ8X[xYW,%Jtq%NNFbXB5j]IVM|9GV=WHRn",
485 "uuid" => 6
486 }
487
488 expected = %{
489 id: "1638338801",
490 type: "image",
491 url: "someurl",
492 remote_url: "someurl",
493 preview_url: "someurl",
494 text_url: "someurl",
495 description: nil,
496 pleroma: %{mime_type: "image/png"},
497 meta: %{original: %{width: 200, height: 100, aspect: 2}},
498 blurhash: "UJJ8X[xYW,%Jtq%NNFbXB5j]IVM|9GV=WHRn"
499 }
500
501 api_spec = Pleroma.Web.ApiSpec.spec()
502
503 assert expected == StatusView.render("attachment.json", %{attachment: object})
504 assert_schema(expected, "Attachment", api_spec)
505
506 # If theres a "id", use that instead of the generated one
507 object = Map.put(object, "id", 2)
508 result = StatusView.render("attachment.json", %{attachment: object})
509
510 assert %{id: "2"} = result
511 assert_schema(result, "Attachment", api_spec)
512 end
513
514 test "put the url advertised in the Activity in to the url attribute" do
515 id = "https://wedistribute.org/wp-json/pterotype/v1/object/85810"
516 [activity] = Activity.search(nil, id)
517
518 status = StatusView.render("show.json", %{activity: activity})
519
520 assert status.uri == id
521 assert status.url == "https://wedistribute.org/2019/07/mastodon-drops-ostatus/"
522 end
523
524 test "a reblog" do
525 user = insert(:user)
526 activity = insert(:note_activity)
527
528 {:ok, reblog} = CommonAPI.repeat(activity.id, user)
529
530 represented = StatusView.render("show.json", %{for: user, activity: reblog})
531
532 assert represented[:id] == to_string(reblog.id)
533 assert represented[:reblog][:id] == to_string(activity.id)
534 assert represented[:emojis] == []
535 assert_schema(represented, "Status", Pleroma.Web.ApiSpec.spec())
536 end
537
538 test "a peertube video" do
539 user = insert(:user)
540
541 {:ok, object} =
542 Pleroma.Object.Fetcher.fetch_object_from_id(
543 "https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3"
544 )
545
546 %Activity{} = activity = Activity.get_create_by_object_ap_id(object.data["id"])
547
548 represented = StatusView.render("show.json", %{for: user, activity: activity})
549
550 assert represented[:id] == to_string(activity.id)
551 assert length(represented[:media_attachments]) == 1
552 assert_schema(represented, "Status", Pleroma.Web.ApiSpec.spec())
553 end
554
555 test "funkwhale audio" do
556 user = insert(:user)
557
558 {:ok, object} =
559 Pleroma.Object.Fetcher.fetch_object_from_id(
560 "https://channels.tests.funkwhale.audio/federation/music/uploads/42342395-0208-4fee-a38d-259a6dae0871"
561 )
562
563 %Activity{} = activity = Activity.get_create_by_object_ap_id(object.data["id"])
564
565 represented = StatusView.render("show.json", %{for: user, activity: activity})
566
567 assert represented[:id] == to_string(activity.id)
568 assert length(represented[:media_attachments]) == 1
569 end
570
571 test "a Mobilizon event" do
572 user = insert(:user)
573
574 {:ok, object} =
575 Pleroma.Object.Fetcher.fetch_object_from_id(
576 "https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39"
577 )
578
579 %Activity{} = activity = Activity.get_create_by_object_ap_id(object.data["id"])
580
581 represented = StatusView.render("show.json", %{for: user, activity: activity})
582
583 assert represented[:id] == to_string(activity.id)
584
585 assert represented[:url] ==
586 "https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39"
587
588 assert represented[:content] ==
589 "<p><a href=\"https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39\">Mobilizon Launching Party</a></p><p>Mobilizon is now federated! 🎉</p><p></p><p>You can view this event from other instances if they are subscribed to mobilizon.org, and soon directly from Mastodon and Pleroma. It is possible that you may see some comments from other instances, including Mastodon ones, just below.</p><p></p><p>With a Mobilizon account on an instance, you may <strong>participate</strong> at events from other instances and <strong>add comments</strong> on events.</p><p></p><p>Of course, it&#39;s still <u>a work in progress</u>: if reports made from an instance on events and comments can be federated, you can&#39;t block people right now, and moderators actions are rather limited, but this <strong>will definitely get fixed over time</strong> until first stable version next year.</p><p></p><p>Anyway, if you want to come up with some feedback, head over to our forum or - if you feel you have technical skills and are familiar with it - on our Gitlab repository.</p><p></p><p>Also, to people that want to set Mobilizon themselves even though we really don&#39;t advise to do that for now, we have a little documentation but it&#39;s quite the early days and you&#39;ll probably need some help. No worries, you can chat with us on our Forum or though our Matrix channel.</p><p></p><p>Check our website for more informations and follow us on Twitter or Mastodon.</p>"
590 end
591
592 describe "build_tags/1" do
593 test "it returns a a dictionary tags" do
594 object_tags = [
595 "fediverse",
596 "mastodon",
597 "nextcloud",
598 %{
599 "href" => "https://kawen.space/users/lain",
600 "name" => "@lain@kawen.space",
601 "type" => "Mention"
602 }
603 ]
604
605 assert StatusView.build_tags(object_tags) == [
606 %{name: "fediverse", url: "http://localhost:4001/tag/fediverse"},
607 %{name: "mastodon", url: "http://localhost:4001/tag/mastodon"},
608 %{name: "nextcloud", url: "http://localhost:4001/tag/nextcloud"}
609 ]
610 end
611 end
612
613 describe "rich media cards" do
614 test "a rich media card without a site name renders correctly" do
615 page_url = "http://example.com"
616
617 card = %{
618 url: page_url,
619 image: page_url <> "/example.jpg",
620 title: "Example website"
621 }
622
623 %{provider_name: "example.com"} =
624 StatusView.render("card.json", %{page_url: page_url, rich_media: card})
625 end
626
627 test "a rich media card without a site name or image renders correctly" do
628 page_url = "http://example.com"
629
630 card = %{
631 url: page_url,
632 title: "Example website"
633 }
634
635 %{provider_name: "example.com"} =
636 StatusView.render("card.json", %{page_url: page_url, rich_media: card})
637 end
638
639 test "a rich media card without an image renders correctly" do
640 page_url = "http://example.com"
641
642 card = %{
643 url: page_url,
644 site_name: "Example site name",
645 title: "Example website"
646 }
647
648 %{provider_name: "example.com"} =
649 StatusView.render("card.json", %{page_url: page_url, rich_media: card})
650 end
651
652 test "a rich media card with all relevant data renders correctly" do
653 page_url = "http://example.com"
654
655 card = %{
656 url: page_url,
657 site_name: "Example site name",
658 title: "Example website",
659 image: page_url <> "/example.jpg",
660 description: "Example description"
661 }
662
663 %{provider_name: "example.com"} =
664 StatusView.render("card.json", %{page_url: page_url, rich_media: card})
665 end
666 end
667
668 test "does not embed a relationship in the account" do
669 user = insert(:user)
670 other_user = insert(:user)
671
672 {:ok, activity} =
673 CommonAPI.post(user, %{
674 status: "drink more water"
675 })
676
677 result = StatusView.render("show.json", %{activity: activity, for: other_user})
678
679 assert result[:account][:pleroma][:relationship] == %{}
680 assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
681 end
682
683 test "does not embed a relationship in the account in reposts" do
684 user = insert(:user)
685 other_user = insert(:user)
686
687 {:ok, activity} =
688 CommonAPI.post(user, %{
689 status: "˙˙ɐʎns"
690 })
691
692 {:ok, activity} = CommonAPI.repeat(activity.id, other_user)
693
694 result = StatusView.render("show.json", %{activity: activity, for: user})
695
696 assert result[:account][:pleroma][:relationship] == %{}
697 assert result[:reblog][:account][:pleroma][:relationship] == %{}
698 assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
699 end
700
701 test "visibility/list" do
702 user = insert(:user)
703
704 {:ok, list} = Pleroma.List.create("foo", user)
705
706 {:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
707
708 status = StatusView.render("show.json", activity: activity)
709
710 assert status.visibility == "list"
711 end
712
713 test "has a field for parent visibility" do
714 user = insert(:user)
715 poster = insert(:user)
716
717 {:ok, invisible} = CommonAPI.post(poster, %{status: "hey", visibility: "private"})
718
719 {:ok, visible} =
720 CommonAPI.post(poster, %{status: "hey", visibility: "private", in_reply_to_id: invisible.id})
721
722 status = StatusView.render("show.json", activity: visible, for: user)
723 refute status.pleroma.parent_visible
724
725 status = StatusView.render("show.json", activity: visible, for: poster)
726 assert status.pleroma.parent_visible
727 end
728 end