1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.CommonAPITest do
9 alias Pleroma.Conversation.Participation
12 alias Pleroma.Web.ActivityPub.ActivityPub
13 alias Pleroma.Web.ActivityPub.Transmogrifier
14 alias Pleroma.Web.ActivityPub.Visibility
15 alias Pleroma.Web.AdminAPI.AccountView
16 alias Pleroma.Web.CommonAPI
18 import Pleroma.Factory
21 require Pleroma.Constants
23 setup do: clear_config([:instance, :safe_dm_mentions])
24 setup do: clear_config([:instance, :limit])
25 setup do: clear_config([:instance, :max_pinned_statuses])
27 describe "posting chat messages" do
28 setup do: clear_config([:instance, :chat_limit])
30 test "it posts a chat message" do
31 author = insert(:user)
32 recipient = insert(:user)
35 CommonAPI.post_chat_message(
38 "a test message <script>alert('uuu')</script> :firefox:"
41 assert activity.data["type"] == "Create"
43 object = Object.normalize(activity)
45 assert object.data["type"] == "ChatMessage"
46 assert object.data["to"] == [recipient.ap_id]
48 assert object.data["content"] ==
49 "a test message <script>alert('uuu')</script> :firefox:"
51 assert object.data["emoji"] == %{
52 "firefox" => "http://localhost:4001/emoji/Firefox.gif"
55 assert Chat.get(author.id, recipient.ap_id)
56 assert Chat.get(recipient.id, author.ap_id)
58 assert :ok == Pleroma.Web.Federator.perform(:publish, activity)
61 test "it reject messages over the local limit" do
62 Pleroma.Config.put([:instance, :chat_limit], 2)
64 author = insert(:user)
65 recipient = insert(:user)
68 CommonAPI.post_chat_message(
74 assert message == :content_too_long
78 describe "deletion" do
79 test "it works with pruned objects" do
82 {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
84 Object.normalize(post, false)
87 with_mock Pleroma.Web.Federator,
88 publish: fn _ -> nil end do
89 assert {:ok, delete} = CommonAPI.delete(post.id, user)
91 assert called(Pleroma.Web.Federator.publish(delete))
94 refute Activity.get_by_id(post.id)
97 test "it allows users to delete their posts" do
100 {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
102 with_mock Pleroma.Web.Federator,
103 publish: fn _ -> nil end do
104 assert {:ok, delete} = CommonAPI.delete(post.id, user)
106 assert called(Pleroma.Web.Federator.publish(delete))
109 refute Activity.get_by_id(post.id)
112 test "it does not allow a user to delete their posts" do
114 other_user = insert(:user)
116 {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
118 assert {:error, "Could not delete"} = CommonAPI.delete(post.id, other_user)
119 assert Activity.get_by_id(post.id)
122 test "it allows moderators to delete other user's posts" do
124 moderator = insert(:user, is_moderator: true)
126 {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
128 assert {:ok, delete} = CommonAPI.delete(post.id, moderator)
131 refute Activity.get_by_id(post.id)
134 test "it allows admins to delete other user's posts" do
136 moderator = insert(:user, is_admin: true)
138 {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
140 assert {:ok, delete} = CommonAPI.delete(post.id, moderator)
143 refute Activity.get_by_id(post.id)
146 test "superusers deleting non-local posts won't federate the delete" do
147 # This is the user of the ingested activity
151 ap_id: "http://mastodon.example.org/users/admin",
152 last_refreshed_at: NaiveDateTime.utc_now()
155 moderator = insert(:user, is_admin: true)
158 File.read!("test/fixtures/mastodon-post-activity.json")
161 {:ok, post} = Transmogrifier.handle_incoming(data)
163 with_mock Pleroma.Web.Federator,
164 publish: fn _ -> nil end do
165 assert {:ok, delete} = CommonAPI.delete(post.id, moderator)
167 refute called(Pleroma.Web.Federator.publish(:_))
170 refute Activity.get_by_id(post.id)
174 test "favoriting race condition" do
176 users_serial = insert_list(10, :user)
177 users = insert_list(10, :user)
179 {:ok, activity} = CommonAPI.post(user, %{status: "."})
182 |> Enum.map(fn user ->
183 CommonAPI.favorite(user, activity.id)
186 object = Object.get_by_ap_id(activity.data["object"])
187 assert object.data["like_count"] == 10
190 |> Enum.map(fn user ->
192 CommonAPI.favorite(user, activity.id)
195 |> Enum.map(&Task.await/1)
197 object = Object.get_by_ap_id(activity.data["object"])
198 assert object.data["like_count"] == 20
201 test "repeating race condition" do
203 users_serial = insert_list(10, :user)
204 users = insert_list(10, :user)
206 {:ok, activity} = CommonAPI.post(user, %{status: "."})
209 |> Enum.map(fn user ->
210 CommonAPI.repeat(activity.id, user)
213 object = Object.get_by_ap_id(activity.data["object"])
214 assert object.data["announcement_count"] == 10
217 |> Enum.map(fn user ->
219 CommonAPI.repeat(activity.id, user)
222 |> Enum.map(&Task.await/1)
224 object = Object.get_by_ap_id(activity.data["object"])
225 assert object.data["announcement_count"] == 20
228 test "when replying to a conversation / participation, it will set the correct context id even if no explicit reply_to is given" do
230 {:ok, activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
232 [participation] = Participation.for_user(user)
235 CommonAPI.post(user, %{status: ".", in_reply_to_conversation_id: participation.id})
237 assert Visibility.is_direct?(convo_reply)
239 assert activity.data["context"] == convo_reply.data["context"]
242 test "when replying to a conversation / participation, it only mentions the recipients explicitly declared in the participation" do
244 jafnhar = insert(:user)
245 tridi = insert(:user)
248 CommonAPI.post(har, %{
249 status: "@#{jafnhar.nickname} hey",
253 assert har.ap_id in activity.recipients
254 assert jafnhar.ap_id in activity.recipients
256 [participation] = Participation.for_user(har)
259 CommonAPI.post(har, %{
260 status: "I don't really like @#{tridi.nickname}",
261 visibility: "direct",
262 in_reply_to_status_id: activity.id,
263 in_reply_to_conversation_id: participation.id
266 assert har.ap_id in activity.recipients
267 assert jafnhar.ap_id in activity.recipients
268 refute tridi.ap_id in activity.recipients
271 test "with the safe_dm_mention option set, it does not mention people beyond the initial tags" do
273 jafnhar = insert(:user)
274 tridi = insert(:user)
276 Pleroma.Config.put([:instance, :safe_dm_mentions], true)
279 CommonAPI.post(har, %{
280 status: "@#{jafnhar.nickname} hey, i never want to see @#{tridi.nickname} again",
284 refute tridi.ap_id in activity.recipients
285 assert jafnhar.ap_id in activity.recipients
288 test "it de-duplicates tags" do
290 {:ok, activity} = CommonAPI.post(user, %{status: "#2hu #2HU"})
292 object = Object.normalize(activity)
294 assert object.data["tag"] == ["2hu"]
297 test "it adds emoji in the object" do
299 {:ok, activity} = CommonAPI.post(user, %{status: ":firefox:"})
301 assert Object.normalize(activity).data["emoji"]["firefox"]
304 describe "posting" do
305 test "it supports explicit addressing" do
307 user_two = insert(:user)
308 user_three = insert(:user)
309 user_four = insert(:user)
312 CommonAPI.post(user, %{
314 "Hey, I think @#{user_three.nickname} is ugly. @#{user_four.nickname} is alright though.",
315 to: [user_two.nickname, user_four.nickname, "nonexistent"]
318 assert user.ap_id in activity.recipients
319 assert user_two.ap_id in activity.recipients
320 assert user_four.ap_id in activity.recipients
321 refute user_three.ap_id in activity.recipients
324 test "it filters out obviously bad tags when accepting a post as HTML" do
327 post = "<p><b>2hu</b></p><script>alert('xss')</script>"
330 CommonAPI.post(user, %{
332 content_type: "text/html"
335 object = Object.normalize(activity)
337 assert object.data["content"] == "<p><b>2hu</b></p>alert('xss')"
340 test "it filters out obviously bad tags when accepting a post as Markdown" do
343 post = "<p><b>2hu</b></p><script>alert('xss')</script>"
346 CommonAPI.post(user, %{
348 content_type: "text/markdown"
351 object = Object.normalize(activity)
353 assert object.data["content"] == "<p><b>2hu</b></p>alert('xss')"
356 test "it does not allow replies to direct messages that are not direct messages themselves" do
359 {:ok, activity} = CommonAPI.post(user, %{status: "suya..", visibility: "direct"})
362 CommonAPI.post(user, %{
364 visibility: "direct",
365 in_reply_to_status_id: activity.id
368 Enum.each(["public", "private", "unlisted"], fn visibility ->
369 assert {:error, "The message visibility must be direct"} =
370 CommonAPI.post(user, %{
372 visibility: visibility,
373 in_reply_to_status_id: activity.id
378 test "it allows to address a list" do
380 {:ok, list} = Pleroma.List.create("foo", user)
382 {:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
384 assert activity.data["bcc"] == [list.ap_id]
385 assert activity.recipients == [list.ap_id, user.ap_id]
386 assert activity.data["listMessage"] == list.ap_id
389 test "it returns error when status is empty and no attachments" do
392 assert {:error, "Cannot post an empty status without attachments"} =
393 CommonAPI.post(user, %{status: ""})
396 test "it validates character limits are correctly enforced" do
397 Pleroma.Config.put([:instance, :limit], 5)
401 assert {:error, "The status is over the character limit"} =
402 CommonAPI.post(user, %{status: "foobar"})
404 assert {:ok, activity} = CommonAPI.post(user, %{status: "12345"})
407 test "it can handle activities that expire" do
411 NaiveDateTime.utc_now()
412 |> NaiveDateTime.truncate(:second)
413 |> NaiveDateTime.add(1_000_000, :second)
415 assert {:ok, activity} = CommonAPI.post(user, %{status: "chai", expires_in: 1_000_000})
417 assert expiration = Pleroma.ActivityExpiration.get_by_activity_id(activity.id)
418 assert expiration.scheduled_at == expires_at
422 describe "reactions" do
423 test "reacting to a status with an emoji" do
425 other_user = insert(:user)
427 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
429 {:ok, reaction} = CommonAPI.react_with_emoji(activity.id, user, "👍")
431 assert reaction.data["actor"] == user.ap_id
432 assert reaction.data["content"] == "👍"
434 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
436 {:error, _} = CommonAPI.react_with_emoji(activity.id, user, ".")
439 test "unreacting to a status with an emoji" do
441 other_user = insert(:user)
443 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
444 {:ok, reaction} = CommonAPI.react_with_emoji(activity.id, user, "👍")
446 {:ok, unreaction} = CommonAPI.unreact_with_emoji(activity.id, user, "👍")
448 assert unreaction.data["type"] == "Undo"
449 assert unreaction.data["object"] == reaction.data["id"]
450 assert unreaction.local
453 test "repeating a status" do
455 other_user = insert(:user)
457 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
459 {:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, user)
462 test "can't repeat a repeat" do
464 other_user = insert(:user)
465 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
467 {:ok, %Activity{} = announce, _} = CommonAPI.repeat(activity.id, other_user)
469 refute match?({:ok, %Activity{}, _}, CommonAPI.repeat(announce.id, user))
472 test "repeating a status privately" do
474 other_user = insert(:user)
476 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
478 {:ok, %Activity{} = announce_activity, _} =
479 CommonAPI.repeat(activity.id, user, %{visibility: "private"})
481 assert Visibility.is_private?(announce_activity)
484 test "favoriting a status" do
486 other_user = insert(:user)
488 {:ok, post_activity} = CommonAPI.post(other_user, %{status: "cofe"})
490 {:ok, %Activity{data: data}} = CommonAPI.favorite(user, post_activity.id)
491 assert data["type"] == "Like"
492 assert data["actor"] == user.ap_id
493 assert data["object"] == post_activity.data["object"]
496 test "retweeting a status twice returns the status" do
498 other_user = insert(:user)
500 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
501 {:ok, %Activity{} = announce, object} = CommonAPI.repeat(activity.id, user)
502 {:ok, ^announce, ^object} = CommonAPI.repeat(activity.id, user)
505 test "favoriting a status twice returns ok, but without the like activity" do
507 other_user = insert(:user)
509 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
510 {:ok, %Activity{}} = CommonAPI.favorite(user, activity.id)
511 assert {:ok, :already_liked} = CommonAPI.favorite(user, activity.id)
515 describe "pinned statuses" do
517 Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
520 {:ok, activity} = CommonAPI.post(user, %{status: "HI!!!"})
522 [user: user, activity: activity]
525 test "pin status", %{user: user, activity: activity} do
526 assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
529 user = refresh_record(user)
531 assert %User{pinned_activities: [^id]} = user
534 test "pin poll", %{user: user} do
536 CommonAPI.post(user, %{
537 status: "How is fediverse today?",
538 poll: %{options: ["Absolutely outstanding", "Not good"], expires_in: 20}
541 assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
544 user = refresh_record(user)
546 assert %User{pinned_activities: [^id]} = user
549 test "unlisted statuses can be pinned", %{user: user} do
550 {:ok, activity} = CommonAPI.post(user, %{status: "HI!!!", visibility: "unlisted"})
551 assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
554 test "only self-authored can be pinned", %{activity: activity} do
557 assert {:error, "Could not pin"} = CommonAPI.pin(activity.id, user)
560 test "max pinned statuses", %{user: user, activity: activity_one} do
561 {:ok, activity_two} = CommonAPI.post(user, %{status: "HI!!!"})
563 assert {:ok, ^activity_one} = CommonAPI.pin(activity_one.id, user)
565 user = refresh_record(user)
567 assert {:error, "You have already pinned the maximum number of statuses"} =
568 CommonAPI.pin(activity_two.id, user)
571 test "unpin status", %{user: user, activity: activity} do
572 {:ok, activity} = CommonAPI.pin(activity.id, user)
574 user = refresh_record(user)
578 assert match?({:ok, %{id: ^id}}, CommonAPI.unpin(activity.id, user))
580 user = refresh_record(user)
582 assert %User{pinned_activities: []} = user
585 test "should unpin when deleting a status", %{user: user, activity: activity} do
586 {:ok, activity} = CommonAPI.pin(activity.id, user)
588 user = refresh_record(user)
590 assert {:ok, _} = CommonAPI.delete(activity.id, user)
592 user = refresh_record(user)
594 assert %User{pinned_activities: []} = user
598 describe "mute tests" do
602 activity = insert(:note_activity)
604 [user: user, activity: activity]
607 test "add mute", %{user: user, activity: activity} do
608 {:ok, _} = CommonAPI.add_mute(user, activity)
609 assert CommonAPI.thread_muted?(user, activity)
612 test "remove mute", %{user: user, activity: activity} do
613 CommonAPI.add_mute(user, activity)
614 {:ok, _} = CommonAPI.remove_mute(user, activity)
615 refute CommonAPI.thread_muted?(user, activity)
618 test "check that mutes can't be duplicate", %{user: user, activity: activity} do
619 CommonAPI.add_mute(user, activity)
620 {:error, _} = CommonAPI.add_mute(user, activity)
624 describe "reports" do
625 test "creates a report" do
626 reporter = insert(:user)
627 target_user = insert(:user)
629 {:ok, activity} = CommonAPI.post(target_user, %{status: "foobar"})
631 reporter_ap_id = reporter.ap_id
632 target_ap_id = target_user.ap_id
633 activity_ap_id = activity.data["id"]
637 account_id: target_user.id,
639 status_ids: [activity.id]
644 "id" => activity_ap_id,
645 "content" => "foobar",
646 "published" => activity.object.data["published"],
647 "actor" => AccountView.render("show.json", %{user: target_user})
650 assert {:ok, flag_activity} = CommonAPI.report(reporter, report_data)
653 actor: ^reporter_ap_id,
656 "content" => ^comment,
657 "object" => [^target_ap_id, ^note_obj],
663 test "updates report state" do
664 [reporter, target_user] = insert_pair(:user)
665 activity = insert(:note_activity, user: target_user)
667 {:ok, %Activity{id: report_id}} =
668 CommonAPI.report(reporter, %{
669 account_id: target_user.id,
670 comment: "I feel offended",
671 status_ids: [activity.id]
674 {:ok, report} = CommonAPI.update_report_state(report_id, "resolved")
676 assert report.data["state"] == "resolved"
678 [reported_user, activity_id] = report.data["object"]
680 assert reported_user == target_user.ap_id
681 assert activity_id == activity.data["id"]
684 test "does not update report state when state is unsupported" do
685 [reporter, target_user] = insert_pair(:user)
686 activity = insert(:note_activity, user: target_user)
688 {:ok, %Activity{id: report_id}} =
689 CommonAPI.report(reporter, %{
690 account_id: target_user.id,
691 comment: "I feel offended",
692 status_ids: [activity.id]
695 assert CommonAPI.update_report_state(report_id, "test") == {:error, "Unsupported state"}
698 test "updates state of multiple reports" do
699 [reporter, target_user] = insert_pair(:user)
700 activity = insert(:note_activity, user: target_user)
702 {:ok, %Activity{id: first_report_id}} =
703 CommonAPI.report(reporter, %{
704 account_id: target_user.id,
705 comment: "I feel offended",
706 status_ids: [activity.id]
709 {:ok, %Activity{id: second_report_id}} =
710 CommonAPI.report(reporter, %{
711 account_id: target_user.id,
712 comment: "I feel very offended!",
713 status_ids: [activity.id]
717 CommonAPI.update_report_state([first_report_id, second_report_id], "resolved")
719 first_report = Activity.get_by_id(first_report_id)
720 second_report = Activity.get_by_id(second_report_id)
722 assert report_ids -- [first_report_id, second_report_id] == []
723 assert first_report.data["state"] == "resolved"
724 assert second_report.data["state"] == "resolved"
728 describe "reblog muting" do
730 muter = insert(:user)
732 muted = insert(:user)
734 [muter: muter, muted: muted]
737 test "add a reblog mute", %{muter: muter, muted: muted} do
738 {:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted)
740 assert User.showing_reblogs?(muter, muted) == false
743 test "remove a reblog mute", %{muter: muter, muted: muted} do
744 {:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted)
745 {:ok, _reblog_mute} = CommonAPI.show_reblogs(muter, muted)
747 assert User.showing_reblogs?(muter, muted) == true
751 describe "unfollow/2" do
752 test "also unsubscribes a user" do
753 [follower, followed] = insert_pair(:user)
754 {:ok, follower, followed, _} = CommonAPI.follow(follower, followed)
755 {:ok, _subscription} = User.subscribe(follower, followed)
757 assert User.subscribed_to?(follower, followed)
759 {:ok, follower} = CommonAPI.unfollow(follower, followed)
761 refute User.subscribed_to?(follower, followed)
764 test "cancels a pending follow for a local user" do
765 follower = insert(:user)
766 followed = insert(:user, locked: true)
768 assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
769 CommonAPI.follow(follower, followed)
771 assert User.get_follow_state(follower, followed) == :follow_pending
772 assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
773 assert User.get_follow_state(follower, followed) == nil
775 assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
776 Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(follower, followed)
781 "object" => %{"type" => "Follow", "state" => "cancelled"}
783 } = Pleroma.Web.ActivityPub.Utils.fetch_latest_undo(follower)
786 test "cancels a pending follow for a remote user" do
787 follower = insert(:user)
788 followed = insert(:user, locked: true, local: false, ap_enabled: true)
790 assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
791 CommonAPI.follow(follower, followed)
793 assert User.get_follow_state(follower, followed) == :follow_pending
794 assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
795 assert User.get_follow_state(follower, followed) == nil
797 assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
798 Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(follower, followed)
803 "object" => %{"type" => "Follow", "state" => "cancelled"}
805 } = Pleroma.Web.ActivityPub.Utils.fetch_latest_undo(follower)
809 describe "accept_follow_request/2" do
810 test "after acceptance, it sets all existing pending follow request states to 'accept'" do
811 user = insert(:user, locked: true)
812 follower = insert(:user)
813 follower_two = insert(:user)
815 {:ok, follow_activity} = ActivityPub.follow(follower, user)
816 {:ok, follow_activity_two} = ActivityPub.follow(follower, user)
817 {:ok, follow_activity_three} = ActivityPub.follow(follower_two, user)
819 assert follow_activity.data["state"] == "pending"
820 assert follow_activity_two.data["state"] == "pending"
821 assert follow_activity_three.data["state"] == "pending"
823 {:ok, _follower} = CommonAPI.accept_follow_request(follower, user)
825 assert Repo.get(Activity, follow_activity.id).data["state"] == "accept"
826 assert Repo.get(Activity, follow_activity_two.id).data["state"] == "accept"
827 assert Repo.get(Activity, follow_activity_three.id).data["state"] == "pending"
830 test "after rejection, it sets all existing pending follow request states to 'reject'" do
831 user = insert(:user, locked: true)
832 follower = insert(:user)
833 follower_two = insert(:user)
835 {:ok, follow_activity} = ActivityPub.follow(follower, user)
836 {:ok, follow_activity_two} = ActivityPub.follow(follower, user)
837 {:ok, follow_activity_three} = ActivityPub.follow(follower_two, user)
839 assert follow_activity.data["state"] == "pending"
840 assert follow_activity_two.data["state"] == "pending"
841 assert follow_activity_three.data["state"] == "pending"
843 {:ok, _follower} = CommonAPI.reject_follow_request(follower, user)
845 assert Repo.get(Activity, follow_activity.id).data["state"] == "reject"
846 assert Repo.get(Activity, follow_activity_two.id).data["state"] == "reject"
847 assert Repo.get(Activity, follow_activity_three.id).data["state"] == "pending"
850 test "doesn't create a following relationship if the corresponding follow request doesn't exist" do
851 user = insert(:user, locked: true)
852 not_follower = insert(:user)
853 CommonAPI.accept_follow_request(not_follower, user)
855 assert Pleroma.FollowingRelationship.following?(not_follower, user) == false
860 test "does not allow to vote twice" do
862 other_user = insert(:user)
865 CommonAPI.post(user, %{
866 status: "Am I cute?",
867 poll: %{options: ["Yes", "No"], expires_in: 20}
870 object = Object.normalize(activity)
872 {:ok, _, object} = CommonAPI.vote(other_user, object, [0])
874 assert {:error, "Already voted"} == CommonAPI.vote(other_user, object, [1])
878 describe "listen/2" do
879 test "returns a valid activity" do
883 CommonAPI.listen(user, %{
884 "title" => "lain radio episode 1",
885 "album" => "lain radio",
890 object = Object.normalize(activity)
892 assert object.data["title"] == "lain radio episode 1"
894 assert Visibility.get_visibility(activity) == "public"
897 test "respects visibility=private" do
901 CommonAPI.listen(user, %{
902 "title" => "lain radio episode 1",
903 "album" => "lain radio",
906 "visibility" => "private"
909 object = Object.normalize(activity)
911 assert object.data["title"] == "lain radio episode 1"
913 assert Visibility.get_visibility(activity) == "private"