forked from mirrors/akkoma
parent
87d5e5b06a
commit
8a4437d2be
5 changed files with 44 additions and 1 deletions
|
@ -225,6 +225,12 @@ defmodule Pleroma.Web.ApiSpec.FilterOperation do
|
|||
type: :integer,
|
||||
description:
|
||||
"Number of seconds from now the filter should expire. Otherwise, null for a filter that doesn't expire."
|
||||
},
|
||||
expires_at: %Schema{
|
||||
nullable: true,
|
||||
type: :string,
|
||||
description:
|
||||
"When the filter should no longer be applied. String (ISO 8601 Datetime), or null if the filter does not expire."
|
||||
}
|
||||
},
|
||||
required: [:phrase, :context],
|
||||
|
|
|
@ -116,6 +116,8 @@ defmodule Pleroma.Web.Plugs.HTTPSecurityPlug do
|
|||
|
||||
script_src = "script-src 'self' '#{nonce_tag}'"
|
||||
|
||||
script_src = if Mix.env() == :dev, do: [script_src, " 'unsafe-eval'"], else: script_src
|
||||
|
||||
report = if report_uri, do: ["report-uri ", report_uri, ";report-to csp-endpoint"]
|
||||
insecure = if scheme == "https", do: "upgrade-insecure-requests"
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/getting_started.js'>
|
||||
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/compose.js'>
|
||||
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/home_timeline.js'>
|
||||
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/public_timeline.js'>
|
||||
<link rel='preload' as='script' crossorigin='anonymous' href='/packs/js/features/notifications.js'>
|
||||
<script crossorigin='anonymous' src="/packs/js/application.js"></script>
|
||||
|
||||
|
|
|
@ -85,6 +85,40 @@ defmodule Pleroma.Web.MastodonAPI.FilterControllerTest do
|
|||
|
||||
assert Repo.aggregate(Filter, :count, :id) == 0
|
||||
end
|
||||
|
||||
test "a filter with expires_at", %{conn: conn, user: user} do
|
||||
response =
|
||||
with_mock NaiveDateTime, [:passthrough], utc_now: fn -> ~N[2017-03-17 17:09:58] end do
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/filters", %{
|
||||
"phrase" => "bad memes",
|
||||
context: ["home"],
|
||||
expires_at: "2017-03-17T17:19:58.000Z"
|
||||
})
|
||||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
assert response["irreversible"] == false
|
||||
|
||||
assert response["expires_at"] == "2017-03-17T17:19:58.000Z"
|
||||
|
||||
filter = Filter.get(response["id"], user)
|
||||
|
||||
id = filter.id
|
||||
|
||||
assert_enqueued(
|
||||
worker: PurgeExpiredFilter,
|
||||
args: %{filter_id: filter.id}
|
||||
)
|
||||
|
||||
assert {:ok, %{id: ^id}} =
|
||||
perform_job(PurgeExpiredFilter, %{
|
||||
filter_id: filter.id
|
||||
})
|
||||
|
||||
assert Repo.aggregate(Filter, :count, :id) == 0
|
||||
end
|
||||
end
|
||||
|
||||
test "fetching a list of filters" do
|
||||
|
|
Loading…
Reference in a new issue