forked from AkkomaGang/akkoma
Compare commits
10 commits
ab0355a210
...
fe20d12e94
| Author | SHA1 | Date | |
|---|---|---|---|
| fe20d12e94 | |||
| 6a6d4254d5 | |||
|
|
984e5a121a | ||
| ff3aaa73ee | |||
| 3d032493eb | |||
| ab9a4ce0d5 | |||
| 699c051101 | |||
|
|
7ffbe2ad26 | ||
| dcfae9bfbf | |||
| efb901bdb5 |
4 changed files with 61 additions and 7 deletions
|
|
@ -10,6 +10,7 @@ This guide will assume that you have administrative rights, either as root or a
|
|||
|
||||
* `postgresql`
|
||||
* `elixir`
|
||||
* `erlang-headless` or `erlang`
|
||||
* `git`
|
||||
* `base-devel`
|
||||
* `cmake`
|
||||
|
|
@ -35,6 +36,7 @@ sudo pacman -Syu
|
|||
|
||||
```shell
|
||||
sudo pacman -S git base-devel elixir cmake file
|
||||
sudo pacman -S --asdeps erlang-headless
|
||||
```
|
||||
|
||||
### Install PostgreSQL
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripMetadata do
|
|||
args = ["-ignoreMinorErrors", "-overwrite_original" | purge_args] ++ preserve_args ++ [file]
|
||||
|
||||
try do
|
||||
case System.cmd("exiftool", args, parallelism: true) do
|
||||
case System.cmd("exiftool", args, parallelism: true, stderr_to_stdout: true) do
|
||||
{_response, 0} -> {:ok, :filtered}
|
||||
{error, 1} -> {:error, error}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -172,14 +172,15 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
|> put_application(conn)
|
||||
|
||||
expires_in_seconds =
|
||||
if is_nil(user.status_ttl_days),
|
||||
do: nil,
|
||||
else: 60 * 60 * 24 * user.status_ttl_days
|
||||
Map.get(params, :expires_in) ||
|
||||
(user.status_ttl_days && 60 * 60 * 24 * user.status_ttl_days)
|
||||
|
||||
params =
|
||||
if is_nil(expires_in_seconds),
|
||||
do: params,
|
||||
else: Map.put(params, :expires_in, expires_in_seconds)
|
||||
case expires_in_seconds do
|
||||
nil -> params
|
||||
0 -> Map.delete(params, :expires_in)
|
||||
_ -> Map.put(params, :expires_in, expires_in_seconds)
|
||||
end
|
||||
|
||||
with {:ok, activity} <- CommonAPI.post(user, params) do
|
||||
try_render(conn, "show.json",
|
||||
|
|
|
|||
|
|
@ -162,6 +162,57 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
)
|
||||
end
|
||||
|
||||
test "API paramater overrides user status_ttl_days default" do
|
||||
user = insert(:user, status_ttl_days: 1)
|
||||
%{user: _user, token: _token, conn: conn} = oauth_access(["write:statuses"], user: user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" => "aa chikichiki banban",
|
||||
"expires_in" => 2 * 60 * 60
|
||||
})
|
||||
|
||||
assert %{"id" => id} = json_response_and_validate_schema(conn, 200)
|
||||
|
||||
activity = Activity.get_by_id_with_object(id)
|
||||
{:ok, expires_at, _} = DateTime.from_iso8601(activity.data["expires_at"])
|
||||
|
||||
expiry_delay = Timex.diff(expires_at, DateTime.utc_now(), :minutes)
|
||||
assert(expiry_delay in [120, 119])
|
||||
|
||||
assert_enqueued(
|
||||
worker: Pleroma.Workers.PurgeExpiredActivity,
|
||||
args: %{activity_id: id},
|
||||
scheduled_at: expires_at
|
||||
)
|
||||
end
|
||||
|
||||
test "API paramater can disable expiry from user-level status_ttl_default" do
|
||||
user = insert(:user, status_ttl_days: 1)
|
||||
%{user: _user, token: _token, conn: conn} = oauth_access(["write:statuses"], user: user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" => "aa chikichiki banban",
|
||||
"expires_in" => 0
|
||||
})
|
||||
|
||||
assert %{"id" => id} = json_response_and_validate_schema(conn, 200)
|
||||
|
||||
activity = Activity.get_by_id_with_object(id)
|
||||
|
||||
refute activity.data["expires_at"]
|
||||
|
||||
refute_enqueued(
|
||||
worker: Pleroma.Workers.PurgeExpiredActivity,
|
||||
args: %{activity_id: id}
|
||||
)
|
||||
end
|
||||
|
||||
test "it fails to create a status if `expires_in` is less or equal than an hour", %{
|
||||
conn: conn
|
||||
} do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue