Show only visible announcements in MastodonAPI
This commit is contained in:
parent
cf8334dbc1
commit
d569694ae9
2 changed files with 25 additions and 1 deletions
|
@ -46,7 +46,7 @@ defmodule Pleroma.Web.MastodonAPI.AnnouncementController do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp all_visible do
|
defp all_visible do
|
||||||
Announcement.list_all()
|
Announcement.list_all_visible()
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "POST /api/v1/announcements/:id/dismiss"
|
@doc "POST /api/v1/announcements/:id/dismiss"
|
||||||
|
|
|
@ -23,6 +23,30 @@ defmodule Pleroma.Web.MastodonAPI.AnnouncementControllerTest do
|
||||||
refute Map.has_key?(Enum.at(response, 0), "read")
|
refute Map.has_key?(Enum.at(response, 0), "read")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it does not list announcements starting after current time" do
|
||||||
|
time = NaiveDateTime.utc_now() |> NaiveDateTime.add(999999, :second)
|
||||||
|
insert(:announcement, starts_at: time)
|
||||||
|
|
||||||
|
response =
|
||||||
|
build_conn()
|
||||||
|
|> get("/api/v1/announcements")
|
||||||
|
|> json_response_and_validate_schema(:ok)
|
||||||
|
|
||||||
|
assert [] = response
|
||||||
|
end
|
||||||
|
|
||||||
|
test "it does not list announcements ending before current time" do
|
||||||
|
time = NaiveDateTime.utc_now() |> NaiveDateTime.add(-999999, :second)
|
||||||
|
insert(:announcement, ends_at: time)
|
||||||
|
|
||||||
|
response =
|
||||||
|
build_conn()
|
||||||
|
|> get("/api/v1/announcements")
|
||||||
|
|> json_response_and_validate_schema(:ok)
|
||||||
|
|
||||||
|
assert [] = response
|
||||||
|
end
|
||||||
|
|
||||||
test "when authenticated, also expose read property" do
|
test "when authenticated, also expose read property" do
|
||||||
%{id: id} = insert(:announcement)
|
%{id: id} = insert(:announcement)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue