Merge branch 'develop' into global-status-expiration
[akkoma] / test / web / common_api / common_api_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.CommonAPITest do
6 use Pleroma.DataCase
7 alias Pleroma.Activity
8 alias Pleroma.Conversation.Participation
9 alias Pleroma.Object
10 alias Pleroma.User
11 alias Pleroma.Web.ActivityPub.ActivityPub
12 alias Pleroma.Web.ActivityPub.Visibility
13 alias Pleroma.Web.AdminAPI.AccountView
14 alias Pleroma.Web.CommonAPI
15
16 import Pleroma.Factory
17
18 require Pleroma.Constants
19
20 setup do: clear_config([:instance, :safe_dm_mentions])
21 setup do: clear_config([:instance, :limit])
22 setup do: clear_config([:instance, :max_pinned_statuses])
23
24 test "favoriting race condition" do
25 user = insert(:user)
26 users_serial = insert_list(10, :user)
27 users = insert_list(10, :user)
28
29 {:ok, activity} = CommonAPI.post(user, %{"status" => "."})
30
31 users_serial
32 |> Enum.map(fn user ->
33 CommonAPI.favorite(user, activity.id)
34 end)
35
36 object = Object.get_by_ap_id(activity.data["object"])
37 assert object.data["like_count"] == 10
38
39 users
40 |> Enum.map(fn user ->
41 Task.async(fn ->
42 CommonAPI.favorite(user, activity.id)
43 end)
44 end)
45 |> Enum.map(&Task.await/1)
46
47 object = Object.get_by_ap_id(activity.data["object"])
48 assert object.data["like_count"] == 20
49 end
50
51 test "when replying to a conversation / participation, it will set the correct context id even if no explicit reply_to is given" do
52 user = insert(:user)
53 {:ok, activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
54
55 [participation] = Participation.for_user(user)
56
57 {:ok, convo_reply} =
58 CommonAPI.post(user, %{"status" => ".", "in_reply_to_conversation_id" => participation.id})
59
60 assert Visibility.is_direct?(convo_reply)
61
62 assert activity.data["context"] == convo_reply.data["context"]
63 end
64
65 test "when replying to a conversation / participation, it only mentions the recipients explicitly declared in the participation" do
66 har = insert(:user)
67 jafnhar = insert(:user)
68 tridi = insert(:user)
69
70 {:ok, activity} =
71 CommonAPI.post(har, %{
72 "status" => "@#{jafnhar.nickname} hey",
73 "visibility" => "direct"
74 })
75
76 assert har.ap_id in activity.recipients
77 assert jafnhar.ap_id in activity.recipients
78
79 [participation] = Participation.for_user(har)
80
81 {:ok, activity} =
82 CommonAPI.post(har, %{
83 "status" => "I don't really like @#{tridi.nickname}",
84 "visibility" => "direct",
85 "in_reply_to_status_id" => activity.id,
86 "in_reply_to_conversation_id" => participation.id
87 })
88
89 assert har.ap_id in activity.recipients
90 assert jafnhar.ap_id in activity.recipients
91 refute tridi.ap_id in activity.recipients
92 end
93
94 test "with the safe_dm_mention option set, it does not mention people beyond the initial tags" do
95 har = insert(:user)
96 jafnhar = insert(:user)
97 tridi = insert(:user)
98
99 Pleroma.Config.put([:instance, :safe_dm_mentions], true)
100
101 {:ok, activity} =
102 CommonAPI.post(har, %{
103 "status" => "@#{jafnhar.nickname} hey, i never want to see @#{tridi.nickname} again",
104 "visibility" => "direct"
105 })
106
107 refute tridi.ap_id in activity.recipients
108 assert jafnhar.ap_id in activity.recipients
109 end
110
111 test "it de-duplicates tags" do
112 user = insert(:user)
113 {:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu #2HU"})
114
115 object = Object.normalize(activity)
116
117 assert object.data["tag"] == ["2hu"]
118 end
119
120 test "it adds emoji in the object" do
121 user = insert(:user)
122 {:ok, activity} = CommonAPI.post(user, %{"status" => ":firefox:"})
123
124 assert Object.normalize(activity).data["emoji"]["firefox"]
125 end
126
127 describe "posting" do
128 test "it supports explicit addressing" do
129 user = insert(:user)
130 user_two = insert(:user)
131 user_three = insert(:user)
132 user_four = insert(:user)
133
134 {:ok, activity} =
135 CommonAPI.post(user, %{
136 "status" =>
137 "Hey, I think @#{user_three.nickname} is ugly. @#{user_four.nickname} is alright though.",
138 "to" => [user_two.nickname, user_four.nickname, "nonexistent"]
139 })
140
141 assert user.ap_id in activity.recipients
142 assert user_two.ap_id in activity.recipients
143 assert user_four.ap_id in activity.recipients
144 refute user_three.ap_id in activity.recipients
145 end
146
147 test "it filters out obviously bad tags when accepting a post as HTML" do
148 user = insert(:user)
149
150 post = "<p><b>2hu</b></p><script>alert('xss')</script>"
151
152 {:ok, activity} =
153 CommonAPI.post(user, %{
154 "status" => post,
155 "content_type" => "text/html"
156 })
157
158 object = Object.normalize(activity)
159
160 assert object.data["content"] == "<p><b>2hu</b></p>alert(&#39;xss&#39;)"
161 end
162
163 test "it filters out obviously bad tags when accepting a post as Markdown" do
164 user = insert(:user)
165
166 post = "<p><b>2hu</b></p><script>alert('xss')</script>"
167
168 {:ok, activity} =
169 CommonAPI.post(user, %{
170 "status" => post,
171 "content_type" => "text/markdown"
172 })
173
174 object = Object.normalize(activity)
175
176 assert object.data["content"] == "<p><b>2hu</b></p>alert(&#39;xss&#39;)"
177 end
178
179 test "it does not allow replies to direct messages that are not direct messages themselves" do
180 user = insert(:user)
181
182 {:ok, activity} = CommonAPI.post(user, %{"status" => "suya..", "visibility" => "direct"})
183
184 assert {:ok, _} =
185 CommonAPI.post(user, %{
186 "status" => "suya..",
187 "visibility" => "direct",
188 "in_reply_to_status_id" => activity.id
189 })
190
191 Enum.each(["public", "private", "unlisted"], fn visibility ->
192 assert {:error, "The message visibility must be direct"} =
193 CommonAPI.post(user, %{
194 "status" => "suya..",
195 "visibility" => visibility,
196 "in_reply_to_status_id" => activity.id
197 })
198 end)
199 end
200
201 test "it allows to address a list" do
202 user = insert(:user)
203 {:ok, list} = Pleroma.List.create("foo", user)
204
205 {:ok, activity} =
206 CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
207
208 assert activity.data["bcc"] == [list.ap_id]
209 assert activity.recipients == [list.ap_id, user.ap_id]
210 assert activity.data["listMessage"] == list.ap_id
211 end
212
213 test "it returns error when status is empty and no attachments" do
214 user = insert(:user)
215
216 assert {:error, "Cannot post an empty status without attachments"} =
217 CommonAPI.post(user, %{"status" => ""})
218 end
219
220 test "it validates character limits are correctly enforced" do
221 Pleroma.Config.put([:instance, :limit], 5)
222
223 user = insert(:user)
224
225 assert {:error, "The status is over the character limit"} =
226 CommonAPI.post(user, %{"status" => "foobar"})
227
228 assert {:ok, activity} = CommonAPI.post(user, %{"status" => "12345"})
229 end
230
231 test "it can handle activities that expire" do
232 user = insert(:user)
233
234 expires_at =
235 NaiveDateTime.utc_now()
236 |> NaiveDateTime.truncate(:second)
237 |> NaiveDateTime.add(1_000_000, :second)
238
239 assert {:ok, activity} =
240 CommonAPI.post(user, %{"status" => "chai", "expires_in" => 1_000_000})
241
242 assert expiration = Pleroma.ActivityExpiration.get_by_activity_id(activity.id)
243 assert expiration.scheduled_at == expires_at
244 end
245 end
246
247 describe "reactions" do
248 test "reacting to a status with an emoji" do
249 user = insert(:user)
250 other_user = insert(:user)
251
252 {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
253
254 {:ok, reaction, _} = CommonAPI.react_with_emoji(activity.id, user, "👍")
255
256 assert reaction.data["actor"] == user.ap_id
257 assert reaction.data["content"] == "👍"
258
259 {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
260
261 {:error, _} = CommonAPI.react_with_emoji(activity.id, user, ".")
262 end
263
264 test "unreacting to a status with an emoji" do
265 user = insert(:user)
266 other_user = insert(:user)
267
268 {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
269 {:ok, reaction, _} = CommonAPI.react_with_emoji(activity.id, user, "👍")
270
271 {:ok, unreaction, _} = CommonAPI.unreact_with_emoji(activity.id, user, "👍")
272
273 assert unreaction.data["type"] == "Undo"
274 assert unreaction.data["object"] == reaction.data["id"]
275 end
276
277 test "repeating a status" do
278 user = insert(:user)
279 other_user = insert(:user)
280
281 {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
282
283 {:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, user)
284 end
285
286 test "can't repeat a repeat" do
287 user = insert(:user)
288 other_user = insert(:user)
289 {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
290
291 {:ok, %Activity{} = announce, _} = CommonAPI.repeat(activity.id, other_user)
292
293 refute match?({:ok, %Activity{}, _}, CommonAPI.repeat(announce.id, user))
294 end
295
296 test "repeating a status privately" do
297 user = insert(:user)
298 other_user = insert(:user)
299
300 {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
301
302 {:ok, %Activity{} = announce_activity, _} =
303 CommonAPI.repeat(activity.id, user, %{"visibility" => "private"})
304
305 assert Visibility.is_private?(announce_activity)
306 end
307
308 test "favoriting a status" do
309 user = insert(:user)
310 other_user = insert(:user)
311
312 {:ok, post_activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
313
314 {:ok, %Activity{data: data}} = CommonAPI.favorite(user, post_activity.id)
315 assert data["type"] == "Like"
316 assert data["actor"] == user.ap_id
317 assert data["object"] == post_activity.data["object"]
318 end
319
320 test "retweeting a status twice returns the status" do
321 user = insert(:user)
322 other_user = insert(:user)
323
324 {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
325 {:ok, %Activity{} = announce, object} = CommonAPI.repeat(activity.id, user)
326 {:ok, ^announce, ^object} = CommonAPI.repeat(activity.id, user)
327 end
328
329 test "favoriting a status twice returns ok, but without the like activity" do
330 user = insert(:user)
331 other_user = insert(:user)
332
333 {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
334 {:ok, %Activity{}} = CommonAPI.favorite(user, activity.id)
335 assert {:ok, :already_liked} = CommonAPI.favorite(user, activity.id)
336 end
337 end
338
339 describe "pinned statuses" do
340 setup do
341 Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
342
343 user = insert(:user)
344 {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
345
346 [user: user, activity: activity]
347 end
348
349 test "pin status", %{user: user, activity: activity} do
350 assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
351
352 id = activity.id
353 user = refresh_record(user)
354
355 assert %User{pinned_activities: [^id]} = user
356 end
357
358 test "pin poll", %{user: user} do
359 {:ok, activity} =
360 CommonAPI.post(user, %{
361 "status" => "How is fediverse today?",
362 "poll" => %{"options" => ["Absolutely outstanding", "Not good"], "expires_in" => 20}
363 })
364
365 assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
366
367 id = activity.id
368 user = refresh_record(user)
369
370 assert %User{pinned_activities: [^id]} = user
371 end
372
373 test "unlisted statuses can be pinned", %{user: user} do
374 {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!", "visibility" => "unlisted"})
375 assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
376 end
377
378 test "only self-authored can be pinned", %{activity: activity} do
379 user = insert(:user)
380
381 assert {:error, "Could not pin"} = CommonAPI.pin(activity.id, user)
382 end
383
384 test "max pinned statuses", %{user: user, activity: activity_one} do
385 {:ok, activity_two} = CommonAPI.post(user, %{"status" => "HI!!!"})
386
387 assert {:ok, ^activity_one} = CommonAPI.pin(activity_one.id, user)
388
389 user = refresh_record(user)
390
391 assert {:error, "You have already pinned the maximum number of statuses"} =
392 CommonAPI.pin(activity_two.id, user)
393 end
394
395 test "unpin status", %{user: user, activity: activity} do
396 {:ok, activity} = CommonAPI.pin(activity.id, user)
397
398 user = refresh_record(user)
399
400 id = activity.id
401
402 assert match?({:ok, %{id: ^id}}, CommonAPI.unpin(activity.id, user))
403
404 user = refresh_record(user)
405
406 assert %User{pinned_activities: []} = user
407 end
408
409 test "should unpin when deleting a status", %{user: user, activity: activity} do
410 {:ok, activity} = CommonAPI.pin(activity.id, user)
411
412 user = refresh_record(user)
413
414 assert {:ok, _} = CommonAPI.delete(activity.id, user)
415
416 user = refresh_record(user)
417
418 assert %User{pinned_activities: []} = user
419 end
420 end
421
422 describe "mute tests" do
423 setup do
424 user = insert(:user)
425
426 activity = insert(:note_activity)
427
428 [user: user, activity: activity]
429 end
430
431 test "add mute", %{user: user, activity: activity} do
432 {:ok, _} = CommonAPI.add_mute(user, activity)
433 assert CommonAPI.thread_muted?(user, activity)
434 end
435
436 test "remove mute", %{user: user, activity: activity} do
437 CommonAPI.add_mute(user, activity)
438 {:ok, _} = CommonAPI.remove_mute(user, activity)
439 refute CommonAPI.thread_muted?(user, activity)
440 end
441
442 test "check that mutes can't be duplicate", %{user: user, activity: activity} do
443 CommonAPI.add_mute(user, activity)
444 {:error, _} = CommonAPI.add_mute(user, activity)
445 end
446 end
447
448 describe "reports" do
449 test "creates a report" do
450 reporter = insert(:user)
451 target_user = insert(:user)
452
453 {:ok, activity} = CommonAPI.post(target_user, %{"status" => "foobar"})
454
455 reporter_ap_id = reporter.ap_id
456 target_ap_id = target_user.ap_id
457 activity_ap_id = activity.data["id"]
458 comment = "foobar"
459
460 report_data = %{
461 "account_id" => target_user.id,
462 "comment" => comment,
463 "status_ids" => [activity.id]
464 }
465
466 note_obj = %{
467 "type" => "Note",
468 "id" => activity_ap_id,
469 "content" => "foobar",
470 "published" => activity.object.data["published"],
471 "actor" => AccountView.render("show.json", %{user: target_user})
472 }
473
474 assert {:ok, flag_activity} = CommonAPI.report(reporter, report_data)
475
476 assert %Activity{
477 actor: ^reporter_ap_id,
478 data: %{
479 "type" => "Flag",
480 "content" => ^comment,
481 "object" => [^target_ap_id, ^note_obj],
482 "state" => "open"
483 }
484 } = flag_activity
485 end
486
487 test "updates report state" do
488 [reporter, target_user] = insert_pair(:user)
489 activity = insert(:note_activity, user: target_user)
490
491 {:ok, %Activity{id: report_id}} =
492 CommonAPI.report(reporter, %{
493 "account_id" => target_user.id,
494 "comment" => "I feel offended",
495 "status_ids" => [activity.id]
496 })
497
498 {:ok, report} = CommonAPI.update_report_state(report_id, "resolved")
499
500 assert report.data["state"] == "resolved"
501
502 [reported_user, activity_id] = report.data["object"]
503
504 assert reported_user == target_user.ap_id
505 assert activity_id == activity.data["id"]
506 end
507
508 test "does not update report state when state is unsupported" do
509 [reporter, target_user] = insert_pair(:user)
510 activity = insert(:note_activity, user: target_user)
511
512 {:ok, %Activity{id: report_id}} =
513 CommonAPI.report(reporter, %{
514 "account_id" => target_user.id,
515 "comment" => "I feel offended",
516 "status_ids" => [activity.id]
517 })
518
519 assert CommonAPI.update_report_state(report_id, "test") == {:error, "Unsupported state"}
520 end
521
522 test "updates state of multiple reports" do
523 [reporter, target_user] = insert_pair(:user)
524 activity = insert(:note_activity, user: target_user)
525
526 {:ok, %Activity{id: first_report_id}} =
527 CommonAPI.report(reporter, %{
528 "account_id" => target_user.id,
529 "comment" => "I feel offended",
530 "status_ids" => [activity.id]
531 })
532
533 {:ok, %Activity{id: second_report_id}} =
534 CommonAPI.report(reporter, %{
535 "account_id" => target_user.id,
536 "comment" => "I feel very offended!",
537 "status_ids" => [activity.id]
538 })
539
540 {:ok, report_ids} =
541 CommonAPI.update_report_state([first_report_id, second_report_id], "resolved")
542
543 first_report = Activity.get_by_id(first_report_id)
544 second_report = Activity.get_by_id(second_report_id)
545
546 assert report_ids -- [first_report_id, second_report_id] == []
547 assert first_report.data["state"] == "resolved"
548 assert second_report.data["state"] == "resolved"
549 end
550 end
551
552 describe "reblog muting" do
553 setup do
554 muter = insert(:user)
555
556 muted = insert(:user)
557
558 [muter: muter, muted: muted]
559 end
560
561 test "add a reblog mute", %{muter: muter, muted: muted} do
562 {:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted)
563
564 assert User.showing_reblogs?(muter, muted) == false
565 end
566
567 test "remove a reblog mute", %{muter: muter, muted: muted} do
568 {:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted)
569 {:ok, _reblog_mute} = CommonAPI.show_reblogs(muter, muted)
570
571 assert User.showing_reblogs?(muter, muted) == true
572 end
573 end
574
575 describe "unfollow/2" do
576 test "also unsubscribes a user" do
577 [follower, followed] = insert_pair(:user)
578 {:ok, follower, followed, _} = CommonAPI.follow(follower, followed)
579 {:ok, _subscription} = User.subscribe(follower, followed)
580
581 assert User.subscribed_to?(follower, followed)
582
583 {:ok, follower} = CommonAPI.unfollow(follower, followed)
584
585 refute User.subscribed_to?(follower, followed)
586 end
587
588 test "cancels a pending follow for a local user" do
589 follower = insert(:user)
590 followed = insert(:user, locked: true)
591
592 assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
593 CommonAPI.follow(follower, followed)
594
595 assert User.get_follow_state(follower, followed) == :follow_pending
596 assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
597 assert User.get_follow_state(follower, followed) == nil
598
599 assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
600 Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(follower, followed)
601
602 assert %{
603 data: %{
604 "type" => "Undo",
605 "object" => %{"type" => "Follow", "state" => "cancelled"}
606 }
607 } = Pleroma.Web.ActivityPub.Utils.fetch_latest_undo(follower)
608 end
609
610 test "cancels a pending follow for a remote user" do
611 follower = insert(:user)
612 followed = insert(:user, locked: true, local: false, ap_enabled: true)
613
614 assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
615 CommonAPI.follow(follower, followed)
616
617 assert User.get_follow_state(follower, followed) == :follow_pending
618 assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
619 assert User.get_follow_state(follower, followed) == nil
620
621 assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
622 Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(follower, followed)
623
624 assert %{
625 data: %{
626 "type" => "Undo",
627 "object" => %{"type" => "Follow", "state" => "cancelled"}
628 }
629 } = Pleroma.Web.ActivityPub.Utils.fetch_latest_undo(follower)
630 end
631 end
632
633 describe "accept_follow_request/2" do
634 test "after acceptance, it sets all existing pending follow request states to 'accept'" do
635 user = insert(:user, locked: true)
636 follower = insert(:user)
637 follower_two = insert(:user)
638
639 {:ok, follow_activity} = ActivityPub.follow(follower, user)
640 {:ok, follow_activity_two} = ActivityPub.follow(follower, user)
641 {:ok, follow_activity_three} = ActivityPub.follow(follower_two, user)
642
643 assert follow_activity.data["state"] == "pending"
644 assert follow_activity_two.data["state"] == "pending"
645 assert follow_activity_three.data["state"] == "pending"
646
647 {:ok, _follower} = CommonAPI.accept_follow_request(follower, user)
648
649 assert Repo.get(Activity, follow_activity.id).data["state"] == "accept"
650 assert Repo.get(Activity, follow_activity_two.id).data["state"] == "accept"
651 assert Repo.get(Activity, follow_activity_three.id).data["state"] == "pending"
652 end
653
654 test "after rejection, it sets all existing pending follow request states to 'reject'" do
655 user = insert(:user, locked: true)
656 follower = insert(:user)
657 follower_two = insert(:user)
658
659 {:ok, follow_activity} = ActivityPub.follow(follower, user)
660 {:ok, follow_activity_two} = ActivityPub.follow(follower, user)
661 {:ok, follow_activity_three} = ActivityPub.follow(follower_two, user)
662
663 assert follow_activity.data["state"] == "pending"
664 assert follow_activity_two.data["state"] == "pending"
665 assert follow_activity_three.data["state"] == "pending"
666
667 {:ok, _follower} = CommonAPI.reject_follow_request(follower, user)
668
669 assert Repo.get(Activity, follow_activity.id).data["state"] == "reject"
670 assert Repo.get(Activity, follow_activity_two.id).data["state"] == "reject"
671 assert Repo.get(Activity, follow_activity_three.id).data["state"] == "pending"
672 end
673 end
674
675 describe "vote/3" do
676 test "does not allow to vote twice" do
677 user = insert(:user)
678 other_user = insert(:user)
679
680 {:ok, activity} =
681 CommonAPI.post(user, %{
682 "status" => "Am I cute?",
683 "poll" => %{"options" => ["Yes", "No"], "expires_in" => 20}
684 })
685
686 object = Object.normalize(activity)
687
688 {:ok, _, object} = CommonAPI.vote(other_user, object, [0])
689
690 assert {:error, "Already voted"} == CommonAPI.vote(other_user, object, [1])
691 end
692 end
693
694 describe "listen/2" do
695 test "returns a valid activity" do
696 user = insert(:user)
697
698 {:ok, activity} =
699 CommonAPI.listen(user, %{
700 "title" => "lain radio episode 1",
701 "album" => "lain radio",
702 "artist" => "lain",
703 "length" => 180_000
704 })
705
706 object = Object.normalize(activity)
707
708 assert object.data["title"] == "lain radio episode 1"
709
710 assert Visibility.get_visibility(activity) == "public"
711 end
712
713 test "respects visibility=private" do
714 user = insert(:user)
715
716 {:ok, activity} =
717 CommonAPI.listen(user, %{
718 "title" => "lain radio episode 1",
719 "album" => "lain radio",
720 "artist" => "lain",
721 "length" => 180_000,
722 "visibility" => "private"
723 })
724
725 object = Object.normalize(activity)
726
727 assert object.data["title"] == "lain radio episode 1"
728
729 assert Visibility.get_visibility(activity) == "private"
730 end
731 end
732 end