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
8 alias Pleroma.Conversation.Participation
11 alias Pleroma.Web.ActivityPub.ActivityPub
12 alias Pleroma.Web.ActivityPub.Transmogrifier
13 alias Pleroma.Web.ActivityPub.Visibility
14 alias Pleroma.Web.AdminAPI.AccountView
15 alias Pleroma.Web.CommonAPI
17 import Pleroma.Factory
20 require Pleroma.Constants
22 setup do: clear_config([:instance, :safe_dm_mentions])
23 setup do: clear_config([:instance, :limit])
24 setup do: clear_config([:instance, :max_pinned_statuses])
26 describe "unblocking" do
27 test "it works even without an existing block activity" do
28 blocked = insert(:user)
29 blocker = insert(:user)
30 User.block(blocker, blocked)
32 assert User.blocks?(blocker, blocked)
33 assert {:ok, :no_activity} == CommonAPI.unblock(blocker, blocked)
34 refute User.blocks?(blocker, blocked)
38 describe "deletion" do
39 test "it works with pruned objects" do
42 {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
44 clear_config([:instance, :federating], true)
46 Object.normalize(post, false)
49 with_mock Pleroma.Web.Federator,
50 publish: fn _ -> nil end do
51 assert {:ok, delete} = CommonAPI.delete(post.id, user)
53 assert called(Pleroma.Web.Federator.publish(delete))
56 refute Activity.get_by_id(post.id)
59 test "it allows users to delete their posts" do
62 {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
64 clear_config([:instance, :federating], true)
66 with_mock Pleroma.Web.Federator,
67 publish: fn _ -> nil end do
68 assert {:ok, delete} = CommonAPI.delete(post.id, user)
70 assert called(Pleroma.Web.Federator.publish(delete))
73 refute Activity.get_by_id(post.id)
76 test "it does not allow a user to delete their posts" do
78 other_user = insert(:user)
80 {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
82 assert {:error, "Could not delete"} = CommonAPI.delete(post.id, other_user)
83 assert Activity.get_by_id(post.id)
86 test "it allows moderators to delete other user's posts" do
88 moderator = insert(:user, is_moderator: true)
90 {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
92 assert {:ok, delete} = CommonAPI.delete(post.id, moderator)
95 refute Activity.get_by_id(post.id)
98 test "it allows admins to delete other user's posts" do
100 moderator = insert(:user, is_admin: true)
102 {:ok, post} = CommonAPI.post(user, %{status: "namu amida butsu"})
104 assert {:ok, delete} = CommonAPI.delete(post.id, moderator)
107 refute Activity.get_by_id(post.id)
110 test "superusers deleting non-local posts won't federate the delete" do
111 # This is the user of the ingested activity
115 ap_id: "http://mastodon.example.org/users/admin",
116 last_refreshed_at: NaiveDateTime.utc_now()
119 moderator = insert(:user, is_admin: true)
122 File.read!("test/fixtures/mastodon-post-activity.json")
125 {:ok, post} = Transmogrifier.handle_incoming(data)
127 with_mock Pleroma.Web.Federator,
128 publish: fn _ -> nil end do
129 assert {:ok, delete} = CommonAPI.delete(post.id, moderator)
131 refute called(Pleroma.Web.Federator.publish(:_))
134 refute Activity.get_by_id(post.id)
138 test "favoriting race condition" do
140 users_serial = insert_list(10, :user)
141 users = insert_list(10, :user)
143 {:ok, activity} = CommonAPI.post(user, %{status: "."})
146 |> Enum.map(fn user ->
147 CommonAPI.favorite(user, activity.id)
150 object = Object.get_by_ap_id(activity.data["object"])
151 assert object.data["like_count"] == 10
154 |> Enum.map(fn user ->
156 CommonAPI.favorite(user, activity.id)
159 |> Enum.map(&Task.await/1)
161 object = Object.get_by_ap_id(activity.data["object"])
162 assert object.data["like_count"] == 20
165 test "repeating race condition" do
167 users_serial = insert_list(10, :user)
168 users = insert_list(10, :user)
170 {:ok, activity} = CommonAPI.post(user, %{status: "."})
173 |> Enum.map(fn user ->
174 CommonAPI.repeat(activity.id, user)
177 object = Object.get_by_ap_id(activity.data["object"])
178 assert object.data["announcement_count"] == 10
181 |> Enum.map(fn user ->
183 CommonAPI.repeat(activity.id, user)
186 |> Enum.map(&Task.await/1)
188 object = Object.get_by_ap_id(activity.data["object"])
189 assert object.data["announcement_count"] == 20
192 test "when replying to a conversation / participation, it will set the correct context id even if no explicit reply_to is given" do
194 {:ok, activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
196 [participation] = Participation.for_user(user)
199 CommonAPI.post(user, %{status: ".", in_reply_to_conversation_id: participation.id})
201 assert Visibility.is_direct?(convo_reply)
203 assert activity.data["context"] == convo_reply.data["context"]
206 test "when replying to a conversation / participation, it only mentions the recipients explicitly declared in the participation" do
208 jafnhar = insert(:user)
209 tridi = insert(:user)
212 CommonAPI.post(har, %{
213 status: "@#{jafnhar.nickname} hey",
217 assert har.ap_id in activity.recipients
218 assert jafnhar.ap_id in activity.recipients
220 [participation] = Participation.for_user(har)
223 CommonAPI.post(har, %{
224 status: "I don't really like @#{tridi.nickname}",
225 visibility: "direct",
226 in_reply_to_status_id: activity.id,
227 in_reply_to_conversation_id: participation.id
230 assert har.ap_id in activity.recipients
231 assert jafnhar.ap_id in activity.recipients
232 refute tridi.ap_id in activity.recipients
235 test "with the safe_dm_mention option set, it does not mention people beyond the initial tags" do
237 jafnhar = insert(:user)
238 tridi = insert(:user)
240 Pleroma.Config.put([:instance, :safe_dm_mentions], true)
243 CommonAPI.post(har, %{
244 status: "@#{jafnhar.nickname} hey, i never want to see @#{tridi.nickname} again",
248 refute tridi.ap_id in activity.recipients
249 assert jafnhar.ap_id in activity.recipients
252 test "it de-duplicates tags" do
254 {:ok, activity} = CommonAPI.post(user, %{status: "#2hu #2HU"})
256 object = Object.normalize(activity)
258 assert object.data["tag"] == ["2hu"]
261 test "it adds emoji in the object" do
263 {:ok, activity} = CommonAPI.post(user, %{status: ":firefox:"})
265 assert Object.normalize(activity).data["emoji"]["firefox"]
268 describe "posting" do
269 test "it supports explicit addressing" do
271 user_two = insert(:user)
272 user_three = insert(:user)
273 user_four = insert(:user)
276 CommonAPI.post(user, %{
278 "Hey, I think @#{user_three.nickname} is ugly. @#{user_four.nickname} is alright though.",
279 to: [user_two.nickname, user_four.nickname, "nonexistent"]
282 assert user.ap_id in activity.recipients
283 assert user_two.ap_id in activity.recipients
284 assert user_four.ap_id in activity.recipients
285 refute user_three.ap_id in activity.recipients
288 test "it filters out obviously bad tags when accepting a post as HTML" do
291 post = "<p><b>2hu</b></p><script>alert('xss')</script>"
294 CommonAPI.post(user, %{
296 content_type: "text/html"
299 object = Object.normalize(activity)
301 assert object.data["content"] == "<p><b>2hu</b></p>alert('xss')"
304 test "it filters out obviously bad tags when accepting a post as Markdown" do
307 post = "<p><b>2hu</b></p><script>alert('xss')</script>"
310 CommonAPI.post(user, %{
312 content_type: "text/markdown"
315 object = Object.normalize(activity)
317 assert object.data["content"] == "<p><b>2hu</b></p>alert('xss')"
320 test "it does not allow replies to direct messages that are not direct messages themselves" do
323 {:ok, activity} = CommonAPI.post(user, %{status: "suya..", visibility: "direct"})
326 CommonAPI.post(user, %{
328 visibility: "direct",
329 in_reply_to_status_id: activity.id
332 Enum.each(["public", "private", "unlisted"], fn visibility ->
333 assert {:error, "The message visibility must be direct"} =
334 CommonAPI.post(user, %{
336 visibility: visibility,
337 in_reply_to_status_id: activity.id
342 test "replying with a direct message will NOT auto-add the author of the reply to the recipient list" do
344 other_user = insert(:user)
345 third_user = insert(:user)
347 {:ok, post} = CommonAPI.post(user, %{status: "I'm stupid"})
350 CommonAPI.post(other_user, %{status: "No ur smart", in_reply_to_status_id: post.id})
352 # The OP is implicitly added
353 assert user.ap_id in open_answer.recipients
355 {:ok, secret_answer} =
356 CommonAPI.post(other_user, %{
357 status: "lol, that guy really is stupid, right, @#{third_user.nickname}?",
358 in_reply_to_status_id: post.id,
362 assert third_user.ap_id in secret_answer.recipients
364 # The OP is not added
365 refute user.ap_id in secret_answer.recipients
368 test "it allows to address a list" do
370 {:ok, list} = Pleroma.List.create("foo", user)
372 {:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
374 assert activity.data["bcc"] == [list.ap_id]
375 assert activity.recipients == [list.ap_id, user.ap_id]
376 assert activity.data["listMessage"] == list.ap_id
379 test "it returns error when status is empty and no attachments" do
382 assert {:error, "Cannot post an empty status without attachments"} =
383 CommonAPI.post(user, %{status: ""})
386 test "it validates character limits are correctly enforced" do
387 Pleroma.Config.put([:instance, :limit], 5)
391 assert {:error, "The status is over the character limit"} =
392 CommonAPI.post(user, %{status: "foobar"})
394 assert {:ok, activity} = CommonAPI.post(user, %{status: "12345"})
397 test "it can handle activities that expire" do
401 NaiveDateTime.utc_now()
402 |> NaiveDateTime.truncate(:second)
403 |> NaiveDateTime.add(1_000_000, :second)
405 assert {:ok, activity} = CommonAPI.post(user, %{status: "chai", expires_in: 1_000_000})
407 assert expiration = Pleroma.ActivityExpiration.get_by_activity_id(activity.id)
408 assert expiration.scheduled_at == expires_at
412 describe "reactions" do
413 test "reacting to a status with an emoji" do
415 other_user = insert(:user)
417 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
419 {:ok, reaction} = CommonAPI.react_with_emoji(activity.id, user, "👍")
421 assert reaction.data["actor"] == user.ap_id
422 assert reaction.data["content"] == "👍"
424 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
426 {:error, _} = CommonAPI.react_with_emoji(activity.id, user, ".")
429 test "unreacting to a status with an emoji" do
431 other_user = insert(:user)
433 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
434 {:ok, reaction} = CommonAPI.react_with_emoji(activity.id, user, "👍")
436 {:ok, unreaction} = CommonAPI.unreact_with_emoji(activity.id, user, "👍")
438 assert unreaction.data["type"] == "Undo"
439 assert unreaction.data["object"] == reaction.data["id"]
440 assert unreaction.local
443 test "repeating a status" do
445 other_user = insert(:user)
447 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
449 {:ok, %Activity{} = announce_activity} = CommonAPI.repeat(activity.id, user)
450 assert Visibility.is_public?(announce_activity)
453 test "can't repeat a repeat" do
455 other_user = insert(:user)
456 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
458 {:ok, %Activity{} = announce} = CommonAPI.repeat(activity.id, other_user)
460 refute match?({:ok, %Activity{}}, CommonAPI.repeat(announce.id, user))
463 test "repeating a status privately" do
465 other_user = insert(:user)
467 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
469 {:ok, %Activity{} = announce_activity} =
470 CommonAPI.repeat(activity.id, user, %{visibility: "private"})
472 assert Visibility.is_private?(announce_activity)
473 refute Visibility.visible_for_user?(announce_activity, nil)
476 test "favoriting a status" do
478 other_user = insert(:user)
480 {:ok, post_activity} = CommonAPI.post(other_user, %{status: "cofe"})
482 {:ok, %Activity{data: data}} = CommonAPI.favorite(user, post_activity.id)
483 assert data["type"] == "Like"
484 assert data["actor"] == user.ap_id
485 assert data["object"] == post_activity.data["object"]
488 test "retweeting a status twice returns the status" do
490 other_user = insert(:user)
492 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
493 {:ok, %Activity{} = announce} = CommonAPI.repeat(activity.id, user)
494 {:ok, ^announce} = CommonAPI.repeat(activity.id, user)
497 test "favoriting a status twice returns ok, but without the like activity" do
499 other_user = insert(:user)
501 {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"})
502 {:ok, %Activity{}} = CommonAPI.favorite(user, activity.id)
503 assert {:ok, :already_liked} = CommonAPI.favorite(user, activity.id)
507 describe "pinned statuses" do
509 Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
512 {:ok, activity} = CommonAPI.post(user, %{status: "HI!!!"})
514 [user: user, activity: activity]
517 test "pin status", %{user: user, activity: activity} do
518 assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
521 user = refresh_record(user)
523 assert %User{pinned_activities: [^id]} = user
526 test "pin poll", %{user: user} do
528 CommonAPI.post(user, %{
529 status: "How is fediverse today?",
530 poll: %{options: ["Absolutely outstanding", "Not good"], expires_in: 20}
533 assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
536 user = refresh_record(user)
538 assert %User{pinned_activities: [^id]} = user
541 test "unlisted statuses can be pinned", %{user: user} do
542 {:ok, activity} = CommonAPI.post(user, %{status: "HI!!!", visibility: "unlisted"})
543 assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
546 test "only self-authored can be pinned", %{activity: activity} do
549 assert {:error, "Could not pin"} = CommonAPI.pin(activity.id, user)
552 test "max pinned statuses", %{user: user, activity: activity_one} do
553 {:ok, activity_two} = CommonAPI.post(user, %{status: "HI!!!"})
555 assert {:ok, ^activity_one} = CommonAPI.pin(activity_one.id, user)
557 user = refresh_record(user)
559 assert {:error, "You have already pinned the maximum number of statuses"} =
560 CommonAPI.pin(activity_two.id, user)
563 test "unpin status", %{user: user, activity: activity} do
564 {:ok, activity} = CommonAPI.pin(activity.id, user)
566 user = refresh_record(user)
570 assert match?({:ok, %{id: ^id}}, CommonAPI.unpin(activity.id, user))
572 user = refresh_record(user)
574 assert %User{pinned_activities: []} = user
577 test "should unpin when deleting a status", %{user: user, activity: activity} do
578 {:ok, activity} = CommonAPI.pin(activity.id, user)
580 user = refresh_record(user)
582 assert {:ok, _} = CommonAPI.delete(activity.id, user)
584 user = refresh_record(user)
586 assert %User{pinned_activities: []} = user
590 describe "mute tests" do
594 activity = insert(:note_activity)
596 [user: user, activity: activity]
599 test "add mute", %{user: user, activity: activity} do
600 {:ok, _} = CommonAPI.add_mute(user, activity)
601 assert CommonAPI.thread_muted?(user, activity)
604 test "remove mute", %{user: user, activity: activity} do
605 CommonAPI.add_mute(user, activity)
606 {:ok, _} = CommonAPI.remove_mute(user, activity)
607 refute CommonAPI.thread_muted?(user, activity)
610 test "check that mutes can't be duplicate", %{user: user, activity: activity} do
611 CommonAPI.add_mute(user, activity)
612 {:error, _} = CommonAPI.add_mute(user, activity)
616 describe "reports" do
617 test "creates a report" do
618 reporter = insert(:user)
619 target_user = insert(:user)
621 {:ok, activity} = CommonAPI.post(target_user, %{status: "foobar"})
623 reporter_ap_id = reporter.ap_id
624 target_ap_id = target_user.ap_id
625 activity_ap_id = activity.data["id"]
629 account_id: target_user.id,
631 status_ids: [activity.id]
636 "id" => activity_ap_id,
637 "content" => "foobar",
638 "published" => activity.object.data["published"],
639 "actor" => AccountView.render("show.json", %{user: target_user})
642 assert {:ok, flag_activity} = CommonAPI.report(reporter, report_data)
645 actor: ^reporter_ap_id,
648 "content" => ^comment,
649 "object" => [^target_ap_id, ^note_obj],
655 test "updates report state" do
656 [reporter, target_user] = insert_pair(:user)
657 activity = insert(:note_activity, user: target_user)
659 {:ok, %Activity{id: report_id}} =
660 CommonAPI.report(reporter, %{
661 account_id: target_user.id,
662 comment: "I feel offended",
663 status_ids: [activity.id]
666 {:ok, report} = CommonAPI.update_report_state(report_id, "resolved")
668 assert report.data["state"] == "resolved"
670 [reported_user, activity_id] = report.data["object"]
672 assert reported_user == target_user.ap_id
673 assert activity_id == activity.data["id"]
676 test "does not update report state when state is unsupported" do
677 [reporter, target_user] = insert_pair(:user)
678 activity = insert(:note_activity, user: target_user)
680 {:ok, %Activity{id: report_id}} =
681 CommonAPI.report(reporter, %{
682 account_id: target_user.id,
683 comment: "I feel offended",
684 status_ids: [activity.id]
687 assert CommonAPI.update_report_state(report_id, "test") == {:error, "Unsupported state"}
690 test "updates state of multiple reports" do
691 [reporter, target_user] = insert_pair(:user)
692 activity = insert(:note_activity, user: target_user)
694 {:ok, %Activity{id: first_report_id}} =
695 CommonAPI.report(reporter, %{
696 account_id: target_user.id,
697 comment: "I feel offended",
698 status_ids: [activity.id]
701 {:ok, %Activity{id: second_report_id}} =
702 CommonAPI.report(reporter, %{
703 account_id: target_user.id,
704 comment: "I feel very offended!",
705 status_ids: [activity.id]
709 CommonAPI.update_report_state([first_report_id, second_report_id], "resolved")
711 first_report = Activity.get_by_id(first_report_id)
712 second_report = Activity.get_by_id(second_report_id)
714 assert report_ids -- [first_report_id, second_report_id] == []
715 assert first_report.data["state"] == "resolved"
716 assert second_report.data["state"] == "resolved"
720 describe "reblog muting" do
722 muter = insert(:user)
724 muted = insert(:user)
726 [muter: muter, muted: muted]
729 test "add a reblog mute", %{muter: muter, muted: muted} do
730 {:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted)
732 assert User.showing_reblogs?(muter, muted) == false
735 test "remove a reblog mute", %{muter: muter, muted: muted} do
736 {:ok, _reblog_mute} = CommonAPI.hide_reblogs(muter, muted)
737 {:ok, _reblog_mute} = CommonAPI.show_reblogs(muter, muted)
739 assert User.showing_reblogs?(muter, muted) == true
743 describe "unfollow/2" do
744 test "also unsubscribes a user" do
745 [follower, followed] = insert_pair(:user)
746 {:ok, follower, followed, _} = CommonAPI.follow(follower, followed)
747 {:ok, _subscription} = User.subscribe(follower, followed)
749 assert User.subscribed_to?(follower, followed)
751 {:ok, follower} = CommonAPI.unfollow(follower, followed)
753 refute User.subscribed_to?(follower, followed)
756 test "cancels a pending follow for a local user" do
757 follower = insert(:user)
758 followed = insert(:user, locked: true)
760 assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
761 CommonAPI.follow(follower, followed)
763 assert User.get_follow_state(follower, followed) == :follow_pending
764 assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
765 assert User.get_follow_state(follower, followed) == nil
767 assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
768 Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(follower, followed)
773 "object" => %{"type" => "Follow", "state" => "cancelled"}
775 } = Pleroma.Web.ActivityPub.Utils.fetch_latest_undo(follower)
778 test "cancels a pending follow for a remote user" do
779 follower = insert(:user)
780 followed = insert(:user, locked: true, local: false, ap_enabled: true)
782 assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
783 CommonAPI.follow(follower, followed)
785 assert User.get_follow_state(follower, followed) == :follow_pending
786 assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
787 assert User.get_follow_state(follower, followed) == nil
789 assert %{id: ^activity_id, data: %{"state" => "cancelled"}} =
790 Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(follower, followed)
795 "object" => %{"type" => "Follow", "state" => "cancelled"}
797 } = Pleroma.Web.ActivityPub.Utils.fetch_latest_undo(follower)
801 describe "accept_follow_request/2" do
802 test "after acceptance, it sets all existing pending follow request states to 'accept'" do
803 user = insert(:user, locked: true)
804 follower = insert(:user)
805 follower_two = insert(:user)
807 {:ok, follow_activity} = ActivityPub.follow(follower, user)
808 {:ok, follow_activity_two} = ActivityPub.follow(follower, user)
809 {:ok, follow_activity_three} = ActivityPub.follow(follower_two, user)
811 assert follow_activity.data["state"] == "pending"
812 assert follow_activity_two.data["state"] == "pending"
813 assert follow_activity_three.data["state"] == "pending"
815 {:ok, _follower} = CommonAPI.accept_follow_request(follower, user)
817 assert Repo.get(Activity, follow_activity.id).data["state"] == "accept"
818 assert Repo.get(Activity, follow_activity_two.id).data["state"] == "accept"
819 assert Repo.get(Activity, follow_activity_three.id).data["state"] == "pending"
822 test "after rejection, it sets all existing pending follow request states to 'reject'" do
823 user = insert(:user, locked: true)
824 follower = insert(:user)
825 follower_two = insert(:user)
827 {:ok, follow_activity} = ActivityPub.follow(follower, user)
828 {:ok, follow_activity_two} = ActivityPub.follow(follower, user)
829 {:ok, follow_activity_three} = ActivityPub.follow(follower_two, user)
831 assert follow_activity.data["state"] == "pending"
832 assert follow_activity_two.data["state"] == "pending"
833 assert follow_activity_three.data["state"] == "pending"
835 {:ok, _follower} = CommonAPI.reject_follow_request(follower, user)
837 assert Repo.get(Activity, follow_activity.id).data["state"] == "reject"
838 assert Repo.get(Activity, follow_activity_two.id).data["state"] == "reject"
839 assert Repo.get(Activity, follow_activity_three.id).data["state"] == "pending"
842 test "doesn't create a following relationship if the corresponding follow request doesn't exist" do
843 user = insert(:user, locked: true)
844 not_follower = insert(:user)
845 CommonAPI.accept_follow_request(not_follower, user)
847 assert Pleroma.FollowingRelationship.following?(not_follower, user) == false
852 test "does not allow to vote twice" do
854 other_user = insert(:user)
857 CommonAPI.post(user, %{
858 status: "Am I cute?",
859 poll: %{options: ["Yes", "No"], expires_in: 20}
862 object = Object.normalize(activity)
864 {:ok, _, object} = CommonAPI.vote(other_user, object, [0])
866 assert {:error, "Already voted"} == CommonAPI.vote(other_user, object, [1])
870 describe "listen/2" do
871 test "returns a valid activity" do
875 CommonAPI.listen(user, %{
876 title: "lain radio episode 1",
882 object = Object.normalize(activity)
884 assert object.data["title"] == "lain radio episode 1"
886 assert Visibility.get_visibility(activity) == "public"
889 test "respects visibility=private" do
893 CommonAPI.listen(user, %{
894 title: "lain radio episode 1",
898 visibility: "private"
901 object = Object.normalize(activity)
903 assert object.data["title"] == "lain radio episode 1"
905 assert Visibility.get_visibility(activity) == "private"