end
def dm_timeline(%{assigns: %{user: user}} = conn, params) do
- query =
- ActivityPub.fetch_activities_query(
- [user.ap_id],
- Map.merge(params, %{"type" => "Create", visibility: "direct"})
- )
+ params =
+ params
+ |> Map.put("type", "Create")
+ |> Map.put("blocking_user", user)
+ |> Map.put("user", user)
+ |> Map.put(:visibility, "direct")
- activities = Repo.all(query)
+ activities =
+ ActivityPub.fetch_activities_query([user.ap_id], params)
+ |> Repo.all()
conn
|> add_link_headers(:dm_timeline, activities)
end
def dm_timeline(%{assigns: %{user: user}} = conn, params) do
- query =
- ActivityPub.fetch_activities_query(
- [user.ap_id],
- Map.merge(params, %{"type" => "Create", "user" => user, visibility: "direct"})
- )
+ params =
+ params
+ |> Map.put("type", "Create")
+ |> Map.put("blocking_user", user)
+ |> Map.put("user", user)
+ |> Map.put(:visibility, "direct")
- activities = Repo.all(query)
+ activities =
+ ActivityPub.fetch_activities_query([user.ap_id], params)
+ |> Repo.all()
conn
|> put_view(ActivityView)
assert status["url"] != direct.data["id"]
end
+ test "doesn't include DMs from blocked users", %{conn: conn} do
+ blocker = insert(:user)
+ blocked = insert(:user)
+ user = insert(:user)
+ {:ok, blocker} = User.block(blocker, blocked)
+
+ {:ok, _blocked_direct} =
+ CommonAPI.post(blocked, %{
+ "status" => "Hi @#{blocker.nickname}!",
+ "visibility" => "direct"
+ })
+
+ {:ok, direct} =
+ CommonAPI.post(user, %{
+ "status" => "Hi @#{blocker.nickname}!",
+ "visibility" => "direct"
+ })
+
+ res_conn =
+ conn
+ |> assign(:user, user)
+ |> get("api/v1/timelines/direct")
+
+ [status] = json_response(res_conn, 200)
+ assert status["id"] == direct.id
+ end
+
test "replying to a status", %{conn: conn} do
user = insert(:user)
assert status["id"] == direct_two.id
assert status_two["id"] == direct.id
end
+
+ test "doesn't include DMs from blocked users", %{conn: conn} do
+ blocker = insert(:user)
+ blocked = insert(:user)
+ user = insert(:user)
+ {:ok, blocker} = User.block(blocker, blocked)
+
+ {:ok, _blocked_direct} =
+ CommonAPI.post(blocked, %{
+ "status" => "Hi @#{blocker.nickname}!",
+ "visibility" => "direct"
+ })
+
+ {:ok, direct} =
+ CommonAPI.post(user, %{
+ "status" => "Hi @#{blocker.nickname}!",
+ "visibility" => "direct"
+ })
+
+ res_conn =
+ conn
+ |> assign(:user, blocker)
+ |> get("/api/statuses/dm_timeline.json")
+
+ [status] = json_response(res_conn, 200)
+ assert status["id"] == direct.id
+ end
end
describe "GET /statuses/mentions.json" do
|> assign(:user, user)
|> post("/api/pleroma/friendships/approve", %{"user_id" => other_user.id})
- user = Repo.get(User, user.id)
-
assert relationship = json_response(conn, 200)
assert other_user.id == relationship["id"]
assert relationship["follows_you"] == true
|> assign(:user, user)
|> post("/api/pleroma/friendships/deny", %{"user_id" => other_user.id})
- user = Repo.get(User, user.id)
-
assert relationship = json_response(conn, 200)
assert other_user.id == relationship["id"]
assert relationship["follows_you"] == false