reblogged: false,
favourited: false,
muted: false,
+ pinned: pinned?(activity, user),
sensitive: false,
spoiler_text: "",
visibility: "public",
reblogged: present?(repeated),
favourited: present?(favorited),
muted: false,
+ pinned: pinned?(activity, user),
sensitive: sensitive,
spoiler_text: object["summary"] || "",
visibility: get_visibility(object),
defp present?(nil), do: false
defp present?(false), do: false
defp present?(_), do: true
+
+ defp pinned?(%Activity{id: id}, %User{info: %{pinned_activities: pinned_activities}}),
+ do: id in pinned_activities
end
id_str = Integer.to_string(activity.id)
- assert [%{"id" => ^id_str}] = result
+ assert [%{"id" => ^id_str, "pinned" => true}] = result
end
test "pin status", %{conn: conn} do
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
id_str = Integer.to_string(activity.id)
- assert %{"id" => ^id_str} =
+ assert %{"id" => ^id_str, "pinned" => true} =
conn
|> assign(:user, user)
|> post("/api/v1/statuses/#{activity.id}/pin")
|> Map.get(:resp_body)
|> Jason.decode!()
- assert [%{"id" => ^id_str}] =
+ assert [%{"id" => ^id_str, "pinned" => true}] =
conn
|> assign(:user, user)
|> get("/api/v1/accounts/#{user.id}/statuses?pinned=true")
id_str = Integer.to_string(activity.id)
user = User.get_by_ap_id(user.ap_id)
- assert %{"id" => ^id_str} =
+ assert %{"id" => ^id_str, "pinned" => false} =
conn
|> assign(:user, user)
|> post("/api/v1/statuses/#{activity.id}/unpin")
id_str_one = Integer.to_string(activity_one.id)
- assert %{"id" => ^id_str_one} =
+ assert %{"id" => ^id_str_one, "pinned" => true} =
conn
|> assign(:user, user)
|> post("/api/v1/statuses/#{id_str_one}/pin")