forked from AkkomaGang/akkoma
Merge remote-tracking branch 'upstream/develop' into aliases
This commit is contained in:
commit
83770b7b39
65 changed files with 195 additions and 286 deletions
|
@ -25,6 +25,8 @@ before_script:
|
||||||
- apt-get update && apt-get install -y cmake
|
- apt-get update && apt-get install -y cmake
|
||||||
- mix local.hex --force
|
- mix local.hex --force
|
||||||
- mix local.rebar --force
|
- mix local.rebar --force
|
||||||
|
- apt-get -qq update
|
||||||
|
- apt-get install -y libmagic-dev
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
|
|
@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- **Breaking** Requires `libmagic` (or `file`) to guess file types.
|
||||||
- **Breaking:** Pleroma Admin API: emoji packs and files routes changed.
|
- **Breaking:** Pleroma Admin API: emoji packs and files routes changed.
|
||||||
- **Breaking:** Sensitive/NSFW statuses no longer disable link previews.
|
- **Breaking:** Sensitive/NSFW statuses no longer disable link previews.
|
||||||
- Search: Users are now findable by their urls.
|
- Search: Users are now findable by their urls.
|
||||||
|
|
|
@ -802,6 +802,8 @@
|
||||||
timeout: 300_000
|
timeout: 300_000
|
||||||
]
|
]
|
||||||
|
|
||||||
|
config :pleroma, :majic_pool, size: 2
|
||||||
|
|
||||||
private_instance? = :if_instance_is_private
|
private_instance? = :if_instance_is_private
|
||||||
|
|
||||||
config :pleroma, :restrict_unauthenticated,
|
config :pleroma, :restrict_unauthenticated,
|
||||||
|
|
|
@ -3708,5 +3708,19 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
group: :pleroma,
|
||||||
|
key: :majic_pool,
|
||||||
|
type: :group,
|
||||||
|
description: "Majic/libmagic configuration",
|
||||||
|
children: [
|
||||||
|
%{
|
||||||
|
key: :size,
|
||||||
|
type: :integer,
|
||||||
|
description: "Number of majic workers to start.",
|
||||||
|
suggestions: [2]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -13,6 +13,7 @@ It assumes that you have administrative rights, either as root or a user with [s
|
||||||
* `erlang-parsetools`
|
* `erlang-parsetools`
|
||||||
* `erlang-xmerl`
|
* `erlang-xmerl`
|
||||||
* `git`
|
* `git`
|
||||||
|
* `file-dev`
|
||||||
* Development Tools
|
* Development Tools
|
||||||
* `cmake`
|
* `cmake`
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ sudo apk upgrade
|
||||||
* Install some tools, which are needed later:
|
* Install some tools, which are needed later:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apk add git build-base cmake
|
sudo apk add git build-base cmake file-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install Elixir and Erlang
|
### Install Elixir and Erlang
|
||||||
|
|
|
@ -10,6 +10,7 @@ This guide will assume that you have administrative rights, either as root or a
|
||||||
* `git`
|
* `git`
|
||||||
* `base-devel`
|
* `base-devel`
|
||||||
* `cmake`
|
* `cmake`
|
||||||
|
* `file`
|
||||||
|
|
||||||
#### Optional packages used in this guide
|
#### Optional packages used in this guide
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ sudo pacman -Syu
|
||||||
* Install some of the above mentioned programs:
|
* Install some of the above mentioned programs:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo pacman -S git base-devel elixir cmake
|
sudo pacman -S git base-devel elixir cmake file
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install PostgreSQL
|
### Install PostgreSQL
|
||||||
|
|
|
@ -10,6 +10,7 @@ This guide will assume you are on Debian Stretch. This guide should also work wi
|
||||||
* `elixir` (1.8+, Follow the guide to install from the Erlang Solutions repo or use [asdf](https://github.com/asdf-vm/asdf) as the pleroma user)
|
* `elixir` (1.8+, Follow the guide to install from the Erlang Solutions repo or use [asdf](https://github.com/asdf-vm/asdf) as the pleroma user)
|
||||||
* `erlang-dev`
|
* `erlang-dev`
|
||||||
* `erlang-nox`
|
* `erlang-nox`
|
||||||
|
* `libmagic-dev`
|
||||||
* `git`
|
* `git`
|
||||||
* `build-essential`
|
* `build-essential`
|
||||||
* `cmake`
|
* `cmake`
|
||||||
|
@ -34,7 +35,7 @@ sudo apt full-upgrade
|
||||||
* Install some of the above mentioned programs:
|
* Install some of the above mentioned programs:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apt install git build-essential postgresql postgresql-contrib cmake
|
sudo apt install git build-essential postgresql postgresql-contrib cmake libmagic-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install Elixir and Erlang
|
### Install Elixir and Erlang
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
- `git`
|
- `git`
|
||||||
- `build-essential`
|
- `build-essential`
|
||||||
- `cmake`
|
- `cmake`
|
||||||
|
- `libmagic-dev`
|
||||||
|
|
||||||
#### このガイドで利用している追加パッケージ
|
#### このガイドで利用している追加パッケージ
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ sudo apt full-upgrade
|
||||||
|
|
||||||
* 上記に挙げたパッケージをインストールしておきます。
|
* 上記に挙げたパッケージをインストールしておきます。
|
||||||
```
|
```
|
||||||
sudo apt install git build-essential postgresql postgresql-contrib cmake ffmpeg imagemagick
|
sudo apt install git build-essential postgresql postgresql-contrib cmake ffmpeg imagemagick libmagic-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### ElixirとErlangをインストールします
|
### ElixirとErlangをインストールします
|
||||||
|
|
|
@ -29,6 +29,7 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
|
||||||
* `dev-lang/elixir`
|
* `dev-lang/elixir`
|
||||||
* `dev-vcs/git`
|
* `dev-vcs/git`
|
||||||
* `dev-util/cmake`
|
* `dev-util/cmake`
|
||||||
|
* `sys-apps/file`
|
||||||
|
|
||||||
#### Optional ebuilds used in this guide
|
#### Optional ebuilds used in this guide
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
|
||||||
* Emerge all required the required and suggested software in one go:
|
* Emerge all required the required and suggested software in one go:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# emerge --ask dev-db/postgresql dev-lang/elixir dev-vcs/git www-servers/nginx app-crypt/certbot app-crypt/certbot-nginx dev-util/cmake
|
# emerge --ask dev-db/postgresql dev-lang/elixir dev-vcs/git www-servers/nginx app-crypt/certbot app-crypt/certbot-nginx dev-util/cmake sys-apps/file
|
||||||
```
|
```
|
||||||
|
|
||||||
If you would not like to install the optional packages, remove them from this line.
|
If you would not like to install the optional packages, remove them from this line.
|
||||||
|
|
|
@ -27,17 +27,18 @@ Other than things bundled in the OTP release Pleroma depends on:
|
||||||
* PostgreSQL (also utilizes extensions in postgresql-contrib)
|
* PostgreSQL (also utilizes extensions in postgresql-contrib)
|
||||||
* nginx (could be swapped with another reverse proxy but this guide covers only it)
|
* nginx (could be swapped with another reverse proxy but this guide covers only it)
|
||||||
* certbot (for Let's Encrypt certificates, could be swapped with another ACME client, but this guide covers only it)
|
* certbot (for Let's Encrypt certificates, could be swapped with another ACME client, but this guide covers only it)
|
||||||
|
* libmagic/file
|
||||||
|
|
||||||
=== "Alpine"
|
=== "Alpine"
|
||||||
```
|
```
|
||||||
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
||||||
apk update
|
apk update
|
||||||
apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot
|
apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot file-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
```
|
```
|
||||||
apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot
|
apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot libmagic-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installing optional packages
|
### Installing optional packages
|
||||||
|
|
|
@ -419,7 +419,7 @@ def run(["list"]) do
|
||||||
|> Enum.each(fn user ->
|
|> Enum.each(fn user ->
|
||||||
shell_info(
|
shell_info(
|
||||||
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
|
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
|
||||||
user.locked
|
user.is_locked
|
||||||
}, deactivated: #{user.deactivated}"
|
}, deactivated: #{user.deactivated}"
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
@ -447,10 +447,10 @@ defp set_admin(user, value) do
|
||||||
defp set_locked(user, value) do
|
defp set_locked(user, value) do
|
||||||
{:ok, user} =
|
{:ok, user} =
|
||||||
user
|
user
|
||||||
|> Changeset.change(%{locked: value})
|
|> Changeset.change(%{is_locked: value})
|
||||||
|> User.update_and_set_cache()
|
|> User.update_and_set_cache()
|
||||||
|
|
||||||
shell_info("Locked status of #{user.nickname}: #{user.locked}")
|
shell_info("Locked status of #{user.nickname}: #{user.is_locked}")
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ def start(_type, _args) do
|
||||||
[
|
[
|
||||||
Pleroma.Stats,
|
Pleroma.Stats,
|
||||||
Pleroma.JobQueueMonitor,
|
Pleroma.JobQueueMonitor,
|
||||||
|
{Majic.Pool, [name: Pleroma.MajicPool, pool_size: Config.get([:majic_pool, :size], 2)]},
|
||||||
{Oban, Config.get(Oban)}
|
{Oban, Config.get(Oban)}
|
||||||
] ++
|
] ++
|
||||||
task_children(@env) ++
|
task_children(@env) ++
|
||||||
|
|
|
@ -1,120 +0,0 @@
|
||||||
# Pleroma: A lightweight social networking server
|
|
||||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
|
|
||||||
defmodule Pleroma.MIME do
|
|
||||||
@moduledoc """
|
|
||||||
Returns the mime-type of a binary and optionally a normalized file-name.
|
|
||||||
"""
|
|
||||||
@default "application/octet-stream"
|
|
||||||
@read_bytes 35
|
|
||||||
|
|
||||||
@spec file_mime_type(String.t(), String.t()) ::
|
|
||||||
{:ok, content_type :: String.t(), filename :: String.t()} | {:error, any()} | :error
|
|
||||||
def file_mime_type(path, filename) do
|
|
||||||
with {:ok, content_type} <- file_mime_type(path),
|
|
||||||
filename <- fix_extension(filename, content_type) do
|
|
||||||
{:ok, content_type, filename}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec file_mime_type(String.t()) :: {:ok, String.t()} | {:error, any()} | :error
|
|
||||||
def file_mime_type(filename) do
|
|
||||||
File.open(filename, [:read], fn f ->
|
|
||||||
check_mime_type(IO.binread(f, @read_bytes))
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
def bin_mime_type(binary, filename) do
|
|
||||||
with {:ok, content_type} <- bin_mime_type(binary),
|
|
||||||
filename <- fix_extension(filename, content_type) do
|
|
||||||
{:ok, content_type, filename}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec bin_mime_type(binary()) :: {:ok, String.t()} | :error
|
|
||||||
def bin_mime_type(<<head::binary-size(@read_bytes), _::binary>>) do
|
|
||||||
{:ok, check_mime_type(head)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def bin_mime_type(_), do: :error
|
|
||||||
|
|
||||||
def mime_type(<<_::binary>>), do: {:ok, @default}
|
|
||||||
|
|
||||||
defp fix_extension(filename, content_type) do
|
|
||||||
parts = String.split(filename, ".")
|
|
||||||
|
|
||||||
new_filename =
|
|
||||||
if length(parts) > 1 do
|
|
||||||
Enum.drop(parts, -1) |> Enum.join(".")
|
|
||||||
else
|
|
||||||
Enum.join(parts)
|
|
||||||
end
|
|
||||||
|
|
||||||
cond do
|
|
||||||
content_type == "application/octet-stream" ->
|
|
||||||
filename
|
|
||||||
|
|
||||||
ext = List.first(MIME.extensions(content_type)) ->
|
|
||||||
new_filename <> "." <> ext
|
|
||||||
|
|
||||||
true ->
|
|
||||||
Enum.join([new_filename, String.split(content_type, "/") |> List.last()], ".")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, _::binary>>) do
|
|
||||||
"image/png"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x47, 0x49, 0x46, 0x38, _, 0x61, _::binary>>) do
|
|
||||||
"image/gif"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0xFF, 0xD8, 0xFF, _::binary>>) do
|
|
||||||
"image/jpeg"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x1A, 0x45, 0xDF, 0xA3, _::binary>>) do
|
|
||||||
"video/webm"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x00, 0x00, 0x00, _, 0x66, 0x74, 0x79, 0x70, _::binary>>) do
|
|
||||||
"video/mp4"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x49, 0x44, 0x33, _::binary>>) do
|
|
||||||
"audio/mpeg"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<255, 251, _, 68, 0, 0, 0, 0, _::binary>>) do
|
|
||||||
"audio/mpeg"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(
|
|
||||||
<<0x4F, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00, _::size(160), 0x80, 0x74, 0x68, 0x65,
|
|
||||||
0x6F, 0x72, 0x61, _::binary>>
|
|
||||||
) do
|
|
||||||
"video/ogg"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x4F, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00, _::binary>>) do
|
|
||||||
"audio/ogg"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<"RIFF", _::binary-size(4), "WAVE", _::binary>>) do
|
|
||||||
"audio/wav"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<"RIFF", _::binary-size(4), "WEBP", _::binary>>) do
|
|
||||||
"image/webp"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<"RIFF", _::binary-size(4), "AVI.", _::binary>>) do
|
|
||||||
"video/avi"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(_) do
|
|
||||||
@default
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -66,6 +66,7 @@ defp get_description(opts, upload) do
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
|
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
|
||||||
|
@doc "Store a file. If using a `Plug.Upload{}` as the source, be sure to use `Majic.Plug` to ensure its content_type and filename is correct."
|
||||||
def store(upload, opts \\ []) do
|
def store(upload, opts \\ []) do
|
||||||
opts = get_opts(opts)
|
opts = get_opts(opts)
|
||||||
|
|
||||||
|
@ -139,14 +140,13 @@ defp get_opts(opts) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp prepare_upload(%Plug.Upload{} = file, opts) do
|
defp prepare_upload(%Plug.Upload{} = file, opts) do
|
||||||
with :ok <- check_file_size(file.path, opts.size_limit),
|
with :ok <- check_file_size(file.path, opts.size_limit) do
|
||||||
{:ok, content_type, name} <- Pleroma.MIME.file_mime_type(file.path, file.filename) do
|
|
||||||
{:ok,
|
{:ok,
|
||||||
%__MODULE__{
|
%__MODULE__{
|
||||||
id: UUID.generate(),
|
id: UUID.generate(),
|
||||||
name: name,
|
name: file.filename,
|
||||||
tempfile: file.path,
|
tempfile: file.path,
|
||||||
content_type: content_type
|
content_type: file.content_type
|
||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -154,16 +154,17 @@ defp prepare_upload(%Plug.Upload{} = file, opts) do
|
||||||
defp prepare_upload(%{img: "data:image/" <> image_data}, opts) do
|
defp prepare_upload(%{img: "data:image/" <> image_data}, opts) do
|
||||||
parsed = Regex.named_captures(~r/(?<filetype>jpeg|png|gif);base64,(?<data>.*)/, image_data)
|
parsed = Regex.named_captures(~r/(?<filetype>jpeg|png|gif);base64,(?<data>.*)/, image_data)
|
||||||
data = Base.decode64!(parsed["data"], ignore: :whitespace)
|
data = Base.decode64!(parsed["data"], ignore: :whitespace)
|
||||||
hash = String.downcase(Base.encode16(:crypto.hash(:sha256, data)))
|
hash = Base.encode16(:crypto.hash(:sha256, data), lower: true)
|
||||||
|
|
||||||
with :ok <- check_binary_size(data, opts.size_limit),
|
with :ok <- check_binary_size(data, opts.size_limit),
|
||||||
tmp_path <- tempfile_for_image(data),
|
tmp_path <- tempfile_for_image(data),
|
||||||
{:ok, content_type, name} <-
|
{:ok, %{mime_type: content_type}} <-
|
||||||
Pleroma.MIME.bin_mime_type(data, hash <> "." <> parsed["filetype"]) do
|
Majic.perform({:bytes, data}, pool: Pleroma.MajicPool),
|
||||||
|
[ext | _] <- MIME.extensions(content_type) do
|
||||||
{:ok,
|
{:ok,
|
||||||
%__MODULE__{
|
%__MODULE__{
|
||||||
id: UUID.generate(),
|
id: UUID.generate(),
|
||||||
name: name,
|
name: hash <> "." <> ext,
|
||||||
tempfile: tmp_path,
|
tempfile: tmp_path,
|
||||||
content_type: content_type
|
content_type: content_type
|
||||||
}}
|
}}
|
||||||
|
@ -172,7 +173,7 @@ defp prepare_upload(%{img: "data:image/" <> image_data}, opts) do
|
||||||
|
|
||||||
# For Mix.Tasks.MigrateLocalUploads
|
# For Mix.Tasks.MigrateLocalUploads
|
||||||
defp prepare_upload(%__MODULE__{tempfile: path} = upload, _opts) do
|
defp prepare_upload(%__MODULE__{tempfile: path} = upload, _opts) do
|
||||||
with {:ok, content_type} <- Pleroma.MIME.file_mime_type(path) do
|
with {:ok, %{mime_type: content_type}} <- Majic.perform(path, pool: Pleroma.MajicPool) do
|
||||||
{:ok, %__MODULE__{upload | content_type: content_type}}
|
{:ok, %__MODULE__{upload | content_type: content_type}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -108,7 +108,7 @@ defmodule Pleroma.User do
|
||||||
field(:note_count, :integer, default: 0)
|
field(:note_count, :integer, default: 0)
|
||||||
field(:follower_count, :integer, default: 0)
|
field(:follower_count, :integer, default: 0)
|
||||||
field(:following_count, :integer, default: 0)
|
field(:following_count, :integer, default: 0)
|
||||||
field(:locked, :boolean, default: false)
|
field(:is_locked, :boolean, default: false)
|
||||||
field(:confirmation_pending, :boolean, default: false)
|
field(:confirmation_pending, :boolean, default: false)
|
||||||
field(:password_reset_pending, :boolean, default: false)
|
field(:password_reset_pending, :boolean, default: false)
|
||||||
field(:approval_pending, :boolean, default: false)
|
field(:approval_pending, :boolean, default: false)
|
||||||
|
@ -437,7 +437,7 @@ def remote_user_changeset(struct \\ %User{local: false}, params) do
|
||||||
:avatar,
|
:avatar,
|
||||||
:ap_enabled,
|
:ap_enabled,
|
||||||
:banner,
|
:banner,
|
||||||
:locked,
|
:is_locked,
|
||||||
:last_refreshed_at,
|
:last_refreshed_at,
|
||||||
:uri,
|
:uri,
|
||||||
:follower_address,
|
:follower_address,
|
||||||
|
@ -480,7 +480,7 @@ def update_changeset(struct, params \\ %{}) do
|
||||||
:public_key,
|
:public_key,
|
||||||
:inbox,
|
:inbox,
|
||||||
:shared_inbox,
|
:shared_inbox,
|
||||||
:locked,
|
:is_locked,
|
||||||
:no_rich_text,
|
:no_rich_text,
|
||||||
:default_scope,
|
:default_scope,
|
||||||
:banner,
|
:banner,
|
||||||
|
@ -849,7 +849,7 @@ def needs_update?(_), do: true
|
||||||
@spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t()} | {:error, String.t()}
|
@spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t()} | {:error, String.t()}
|
||||||
|
|
||||||
# "Locked" (self-locked) users demand explicit authorization of follow requests
|
# "Locked" (self-locked) users demand explicit authorization of follow requests
|
||||||
def maybe_direct_follow(%User{} = follower, %User{local: true, locked: true} = followed) do
|
def maybe_direct_follow(%User{} = follower, %User{local: true, is_locked: true} = followed) do
|
||||||
follow(follower, followed, :follow_pending)
|
follow(follower, followed, :follow_pending)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -956,7 +956,7 @@ def get_follow_state(
|
||||||
end
|
end
|
||||||
|
|
||||||
def locked?(%User{} = user) do
|
def locked?(%User{} = user) do
|
||||||
user.locked || false
|
user.is_locked || false
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_by_id(id) do
|
def get_by_id(id) do
|
||||||
|
@ -1603,7 +1603,7 @@ def purge_user_changeset(user) do
|
||||||
note_count: 0,
|
note_count: 0,
|
||||||
follower_count: 0,
|
follower_count: 0,
|
||||||
following_count: 0,
|
following_count: 0,
|
||||||
locked: false,
|
is_locked: false,
|
||||||
confirmation_pending: false,
|
confirmation_pending: false,
|
||||||
password_reset_pending: false,
|
password_reset_pending: false,
|
||||||
approval_pending: false,
|
approval_pending: false,
|
||||||
|
|
|
@ -1228,7 +1228,7 @@ defp object_to_user_data(data) do
|
||||||
{String.trim(name, ":"), url}
|
{String.trim(name, ":"), url}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
locked = data["manuallyApprovesFollowers"] || false
|
is_locked = data["manuallyApprovesFollowers"] || false
|
||||||
capabilities = data["capabilities"] || %{}
|
capabilities = data["capabilities"] || %{}
|
||||||
accepts_chat_messages = capabilities["acceptsChatMessages"]
|
accepts_chat_messages = capabilities["acceptsChatMessages"]
|
||||||
data = Transmogrifier.maybe_fix_user_object(data)
|
data = Transmogrifier.maybe_fix_user_object(data)
|
||||||
|
@ -1257,7 +1257,7 @@ defp object_to_user_data(data) do
|
||||||
banner: banner,
|
banner: banner,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
emoji: emojis,
|
emoji: emojis,
|
||||||
locked: locked,
|
is_locked: is_locked,
|
||||||
discoverable: discoverable,
|
discoverable: discoverable,
|
||||||
invisible: invisible,
|
invisible: invisible,
|
||||||
avatar: avatar,
|
avatar: avatar,
|
||||||
|
|
|
@ -45,6 +45,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
||||||
when action in [:read_inbox, :update_outbox, :whoami, :upload_media]
|
when action in [:read_inbox, :update_outbox, :whoami, :upload_media]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
plug(Majic.Plug, [pool: Pleroma.MajicPool] when action in [:upload_media])
|
||||||
|
|
||||||
plug(
|
plug(
|
||||||
Pleroma.Web.Plugs.Cache,
|
Pleroma.Web.Plugs.Cache,
|
||||||
[query_params: false, tracking_fun: &__MODULE__.track_object_fetch/2]
|
[query_params: false, tracking_fun: &__MODULE__.track_object_fetch/2]
|
||||||
|
|
|
@ -102,7 +102,7 @@ def handle(
|
||||||
%User{} = followed <- User.get_cached_by_ap_id(followed_user),
|
%User{} = followed <- User.get_cached_by_ap_id(followed_user),
|
||||||
{_, {:ok, _}, _, _} <-
|
{_, {:ok, _}, _, _} <-
|
||||||
{:following, User.follow(follower, followed, :follow_pending), follower, followed} do
|
{:following, User.follow(follower, followed, :follow_pending), follower, followed} do
|
||||||
if followed.local && !followed.locked do
|
if followed.local && !followed.is_locked do
|
||||||
{:ok, accept_data, _} = Builder.accept(followed, object)
|
{:ok, accept_data, _} = Builder.accept(followed, object)
|
||||||
{:ok, _activity, _} = Pipeline.common_pipeline(accept_data, local: true)
|
{:ok, _activity, _} = Pipeline.common_pipeline(accept_data, local: true)
|
||||||
end
|
end
|
||||||
|
|
|
@ -101,7 +101,7 @@ def render("user.json", %{user: user}) do
|
||||||
"name" => user.name,
|
"name" => user.name,
|
||||||
"summary" => user.bio,
|
"summary" => user.bio,
|
||||||
"url" => user.ap_id,
|
"url" => user.ap_id,
|
||||||
"manuallyApprovesFollowers" => user.locked,
|
"manuallyApprovesFollowers" => user.is_locked,
|
||||||
"publicKey" => %{
|
"publicKey" => %{
|
||||||
"id" => "#{user.ap_id}#main-key",
|
"id" => "#{user.ap_id}#main-key",
|
||||||
"owner" => user.ap_id,
|
"owner" => user.ap_id,
|
||||||
|
|
|
@ -39,7 +39,7 @@ def render("credentials.json", %{user: user, for: for_user}) do
|
||||||
:fields,
|
:fields,
|
||||||
:name,
|
:name,
|
||||||
:nickname,
|
:nickname,
|
||||||
:locked,
|
:is_locked,
|
||||||
:no_rich_text,
|
:no_rich_text,
|
||||||
:default_scope,
|
:default_scope,
|
||||||
:hide_follows,
|
:hide_follows,
|
||||||
|
|
|
@ -50,7 +50,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Chat do
|
||||||
"fields" => []
|
"fields" => []
|
||||||
},
|
},
|
||||||
"statuses_count" => 1,
|
"statuses_count" => 1,
|
||||||
"locked" => false,
|
"is_locked" => false,
|
||||||
"created_at" => "2020-04-16T13:40:15.000Z",
|
"created_at" => "2020-04-16T13:40:15.000Z",
|
||||||
"display_name" => "lain",
|
"display_name" => "lain",
|
||||||
"fields" => [],
|
"fields" => [],
|
||||||
|
|
|
@ -252,7 +252,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
|
||||||
"header" => "http://localhost:4001/images/banner.png",
|
"header" => "http://localhost:4001/images/banner.png",
|
||||||
"header_static" => "http://localhost:4001/images/banner.png",
|
"header_static" => "http://localhost:4001/images/banner.png",
|
||||||
"id" => "9toJCsKN7SmSf3aj5c",
|
"id" => "9toJCsKN7SmSf3aj5c",
|
||||||
"locked" => false,
|
"is_locked" => false,
|
||||||
"note" => "Tester Number 6",
|
"note" => "Tester Number 6",
|
||||||
"pleroma" => %{
|
"pleroma" => %{
|
||||||
"background_image" => nil,
|
"background_image" => nil,
|
||||||
|
|
|
@ -177,7 +177,6 @@ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _p
|
||||||
user_params =
|
user_params =
|
||||||
[
|
[
|
||||||
:no_rich_text,
|
:no_rich_text,
|
||||||
:locked,
|
|
||||||
:hide_followers_count,
|
:hide_followers_count,
|
||||||
:hide_follows_count,
|
:hide_follows_count,
|
||||||
:hide_followers,
|
:hide_followers,
|
||||||
|
@ -212,6 +211,7 @@ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _p
|
||||||
end)
|
end)
|
||||||
|> Maps.put_if_present(:actor_type, params[:actor_type])
|
|> Maps.put_if_present(:actor_type, params[:actor_type])
|
||||||
|> Maps.put_if_present(:also_known_as, params[:also_known_as])
|
|> Maps.put_if_present(:also_known_as, params[:also_known_as])
|
||||||
|
|> Maps.put_if_present(:is_locked, params[:locked])
|
||||||
|
|
||||||
# What happens here:
|
# What happens here:
|
||||||
#
|
#
|
||||||
|
|
|
@ -11,6 +11,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaController do
|
||||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||||
|
|
||||||
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
|
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
|
||||||
|
plug(Majic.Plug, [pool: Pleroma.MajicPool] when action in [:create, :create2])
|
||||||
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
||||||
plug(:put_view, Pleroma.Web.MastodonAPI.StatusView)
|
plug(:put_view, Pleroma.Web.MastodonAPI.StatusView)
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ defp do_render("show.json", %{user: user} = opts) do
|
||||||
username: username_from_nickname(user.nickname),
|
username: username_from_nickname(user.nickname),
|
||||||
acct: user.nickname,
|
acct: user.nickname,
|
||||||
display_name: display_name,
|
display_name: display_name,
|
||||||
locked: user.locked,
|
locked: user.is_locked,
|
||||||
created_at: Utils.to_masto_date(user.inserted_at),
|
created_at: Utils.to_masto_date(user.inserted_at),
|
||||||
followers_count: followers_count,
|
followers_count: followers_count,
|
||||||
following_count: following_count,
|
following_count: following_count,
|
||||||
|
|
|
@ -17,6 +17,11 @@ defmodule Pleroma.Web.PleromaAPI.AccountController do
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
|
plug(
|
||||||
|
Majic.Plug,
|
||||||
|
[pool: Pleroma.MajicPool] when action in [:update_avatar, :update_background, :update_banner]
|
||||||
|
)
|
||||||
|
|
||||||
plug(
|
plug(
|
||||||
OpenApiSpex.Plug.PutApiSpec,
|
OpenApiSpex.Plug.PutApiSpec,
|
||||||
[module: Pleroma.Web.ApiSpec] when action == :confirmation_resend
|
[module: Pleroma.Web.ApiSpec] when action == :confirmation_resend
|
||||||
|
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotController do
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||||
|
|
||||||
|
plug(Majic.Plug, [pool: Pleroma.MajicPool] when action in [:update])
|
||||||
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
||||||
plug(OAuthScopesPlug, %{scopes: ["read:accounts"]} when action == :show)
|
plug(OAuthScopesPlug, %{scopes: ["read:accounts"]} when action == :show)
|
||||||
plug(OAuthScopesPlug, %{scopes: ["write:accounts"]} when action != :show)
|
plug(OAuthScopesPlug, %{scopes: ["write:accounts"]} when action != :show)
|
||||||
|
@ -22,14 +23,15 @@ def show(%{assigns: %{user: user}} = conn, _params) do
|
||||||
|
|
||||||
@doc "PUT /api/v1/pleroma/mascot"
|
@doc "PUT /api/v1/pleroma/mascot"
|
||||||
def update(%{assigns: %{user: user}, body_params: %{file: file}} = conn, _) do
|
def update(%{assigns: %{user: user}, body_params: %{file: file}} = conn, _) do
|
||||||
with {:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)),
|
with {:content_type, "image" <> _} <- {:content_type, file.content_type},
|
||||||
# Reject if not an image
|
{:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)) do
|
||||||
%{type: "image"} = attachment <- render_attachment(object) do
|
attachment = render_attachment(object)
|
||||||
{:ok, _user} = User.mascot_update(user, attachment)
|
{:ok, _user} = User.mascot_update(user, attachment)
|
||||||
|
|
||||||
json(conn, attachment)
|
json(conn, attachment)
|
||||||
else
|
else
|
||||||
%{type: _} -> render_error(conn, :unsupported_media_type, "mascots can only be images")
|
{:content_type, _} ->
|
||||||
|
render_error(conn, :unsupported_media_type, "mascots can only be images")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
2
mix.exs
2
mix.exs
|
@ -188,6 +188,8 @@ defp deps do
|
||||||
git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
|
git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
|
||||||
ref: "e0f16822d578866e186a0974d65ad58cddc1e2ab"},
|
ref: "e0f16822d578866e186a0974d65ad58cddc1e2ab"},
|
||||||
{:restarter, path: "./restarter"},
|
{:restarter, path: "./restarter"},
|
||||||
|
{:majic,
|
||||||
|
git: "https://git.pleroma.social/pleroma/elixir-libraries/majic", branch: "develop"},
|
||||||
{:open_api_spex,
|
{:open_api_spex,
|
||||||
git: "https://git.pleroma.social/pleroma/elixir-libraries/open_api_spex.git",
|
git: "https://git.pleroma.social/pleroma/elixir-libraries/open_api_spex.git",
|
||||||
ref: "f296ac0924ba3cf79c7a588c4c252889df4c2edd"},
|
ref: "f296ac0924ba3cf79c7a588c4c252889df4c2edd"},
|
||||||
|
|
3
mix.lock
3
mix.lock
|
@ -32,7 +32,7 @@
|
||||||
"ecto_enum": {:hex, :ecto_enum, "1.4.0", "d14b00e04b974afc69c251632d1e49594d899067ee2b376277efd8233027aec8", [:mix], [{:ecto, ">= 3.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "> 3.0.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:mariaex, ">= 0.0.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "8fb55c087181c2b15eee406519dc22578fa60dd82c088be376d0010172764ee4"},
|
"ecto_enum": {:hex, :ecto_enum, "1.4.0", "d14b00e04b974afc69c251632d1e49594d899067ee2b376277efd8233027aec8", [:mix], [{:ecto, ">= 3.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "> 3.0.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:mariaex, ">= 0.0.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "8fb55c087181c2b15eee406519dc22578fa60dd82c088be376d0010172764ee4"},
|
||||||
"ecto_sql": {:hex, :ecto_sql, "3.4.5", "30161f81b167d561a9a2df4329c10ae05ff36eca7ccc84628f2c8b9fa1e43323", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0 or ~> 0.4.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.0", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "31990c6a3579b36a3c0841d34a94c275e727de8b84f58509da5f1b2032c98ac2"},
|
"ecto_sql": {:hex, :ecto_sql, "3.4.5", "30161f81b167d561a9a2df4329c10ae05ff36eca7ccc84628f2c8b9fa1e43323", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0 or ~> 0.4.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.0", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "31990c6a3579b36a3c0841d34a94c275e727de8b84f58509da5f1b2032c98ac2"},
|
||||||
"eimp": {:hex, :eimp, "1.0.14", "fc297f0c7e2700457a95a60c7010a5f1dcb768a083b6d53f49cd94ab95a28f22", [:rebar3], [{:p1_utils, "1.0.18", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "501133f3112079b92d9e22da8b88bf4f0e13d4d67ae9c15c42c30bd25ceb83b6"},
|
"eimp": {:hex, :eimp, "1.0.14", "fc297f0c7e2700457a95a60c7010a5f1dcb768a083b6d53f49cd94ab95a28f22", [:rebar3], [{:p1_utils, "1.0.18", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "501133f3112079b92d9e22da8b88bf4f0e13d4d67ae9c15c42c30bd25ceb83b6"},
|
||||||
"elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm", "d522695b93b7f0b4c0fcb2dfe73a6b905b1c301226a5a55cb42e5b14d509e050"},
|
"elixir_make": {:hex, :elixir_make, "0.6.1", "8faa29a5597faba999aeeb72bbb9c91694ef8068f0131192fb199f98d32994ef", [:mix], [], "hexpm", "35d33270680f8d839a4003c3e9f43afb595310a592405a00afc12de4c7f55a18"},
|
||||||
"esshd": {:hex, :esshd, "0.1.1", "d4dd4c46698093a40a56afecce8a46e246eb35463c457c246dacba2e056f31b5", [:mix], [], "hexpm", "d73e341e3009d390aa36387dc8862860bf9f874c94d9fd92ade2926376f49981"},
|
"esshd": {:hex, :esshd, "0.1.1", "d4dd4c46698093a40a56afecce8a46e246eb35463c457c246dacba2e056f31b5", [:mix], [], "hexpm", "d73e341e3009d390aa36387dc8862860bf9f874c94d9fd92ade2926376f49981"},
|
||||||
"eternal": {:hex, :eternal, "1.2.1", "d5b6b2499ba876c57be2581b5b999ee9bdf861c647401066d3eeed111d096bc4", [:mix], [], "hexpm", "b14f1dc204321429479c569cfbe8fb287541184ed040956c8862cb7a677b8406"},
|
"eternal": {:hex, :eternal, "1.2.1", "d5b6b2499ba876c57be2581b5b999ee9bdf861c647401066d3eeed111d096bc4", [:mix], [], "hexpm", "b14f1dc204321429479c569cfbe8fb287541184ed040956c8862cb7a677b8406"},
|
||||||
"ex2ms": {:hex, :ex2ms, "1.5.0", "19e27f9212be9a96093fed8cdfbef0a2b56c21237196d26760f11dfcfae58e97", [:mix], [], "hexpm"},
|
"ex2ms": {:hex, :ex2ms, "1.5.0", "19e27f9212be9a96093fed8cdfbef0a2b56c21237196d26760f11dfcfae58e97", [:mix], [], "hexpm"},
|
||||||
|
@ -65,6 +65,7 @@
|
||||||
"jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},
|
"jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},
|
||||||
"libring": {:hex, :libring, "1.4.0", "41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6", [:mix], [], "hexpm"},
|
"libring": {:hex, :libring, "1.4.0", "41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6", [:mix], [], "hexpm"},
|
||||||
"linkify": {:hex, :linkify, "0.2.0", "2518bbbea21d2caa9d372424e1ad845b640c6630e2d016f1bd1f518f9ebcca28", [:mix], [], "hexpm", "b8ca8a68b79e30b7938d6c996085f3db14939f29538a59ca5101988bb7f917f6"},
|
"linkify": {:hex, :linkify, "0.2.0", "2518bbbea21d2caa9d372424e1ad845b640c6630e2d016f1bd1f518f9ebcca28", [:mix], [], "hexpm", "b8ca8a68b79e30b7938d6c996085f3db14939f29538a59ca5101988bb7f917f6"},
|
||||||
|
"majic": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/majic", "4c692e544b28d1f5e543fb8a44be090f8cd96f80", [branch: "develop"]},
|
||||||
"makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"},
|
"makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"},
|
||||||
"makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"},
|
"makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"},
|
||||||
"meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm", "d34f013c156db51ad57cc556891b9720e6a1c1df5fe2e15af999c84d6cebeb1a"},
|
"meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm", "d34f013c156db51ad57cc556891b9720e6a1c1df5fe2e15af999c84d6cebeb1a"},
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Repo.Migrations.RefactorLockedUserField do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def up do
|
||||||
|
execute("ALTER TABLE users RENAME COLUMN locked TO is_locked;")
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
execute("ALTER TABLE users RENAME COLUMN is_locked TO locked;")
|
||||||
|
end
|
||||||
|
end
|
|
@ -248,14 +248,19 @@ test "All statuses set" do
|
||||||
|
|
||||||
user = User.get_cached_by_nickname(user.nickname)
|
user = User.get_cached_by_nickname(user.nickname)
|
||||||
assert user.is_moderator
|
assert user.is_moderator
|
||||||
assert user.locked
|
assert user.is_locked
|
||||||
assert user.is_admin
|
assert user.is_admin
|
||||||
refute user.confirmation_pending
|
refute user.confirmation_pending
|
||||||
end
|
end
|
||||||
|
|
||||||
test "All statuses unset" do
|
test "All statuses unset" do
|
||||||
user =
|
user =
|
||||||
insert(:user, locked: true, is_moderator: true, is_admin: true, confirmation_pending: true)
|
insert(:user,
|
||||||
|
is_locked: true,
|
||||||
|
is_moderator: true,
|
||||||
|
is_admin: true,
|
||||||
|
confirmation_pending: true
|
||||||
|
)
|
||||||
|
|
||||||
Mix.Tasks.Pleroma.User.run([
|
Mix.Tasks.Pleroma.User.run([
|
||||||
"set",
|
"set",
|
||||||
|
@ -280,7 +285,7 @@ test "All statuses unset" do
|
||||||
|
|
||||||
user = User.get_cached_by_nickname(user.nickname)
|
user = User.get_cached_by_nickname(user.nickname)
|
||||||
refute user.is_moderator
|
refute user.is_moderator
|
||||||
refute user.locked
|
refute user.is_locked
|
||||||
refute user.is_admin
|
refute user.is_admin
|
||||||
assert user.confirmation_pending
|
assert user.confirmation_pending
|
||||||
end
|
end
|
||||||
|
|
|
@ -346,7 +346,7 @@ test "it creates notifications when someone likes user's status with a filtered
|
||||||
describe "follow / follow_request notifications" do
|
describe "follow / follow_request notifications" do
|
||||||
test "it creates `follow` notification for approved Follow activity" do
|
test "it creates `follow` notification for approved Follow activity" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
followed_user = insert(:user, locked: false)
|
followed_user = insert(:user, is_locked: false)
|
||||||
|
|
||||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||||
assert FollowingRelationship.following?(user, followed_user)
|
assert FollowingRelationship.following?(user, followed_user)
|
||||||
|
@ -361,7 +361,7 @@ test "it creates `follow` notification for approved Follow activity" do
|
||||||
|
|
||||||
test "it creates `follow_request` notification for pending Follow activity" do
|
test "it creates `follow_request` notification for pending Follow activity" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
followed_user = insert(:user, locked: true)
|
followed_user = insert(:user, is_locked: true)
|
||||||
|
|
||||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||||
refute FollowingRelationship.following?(user, followed_user)
|
refute FollowingRelationship.following?(user, followed_user)
|
||||||
|
@ -383,7 +383,7 @@ test "it creates `follow_request` notification for pending Follow activity" do
|
||||||
|
|
||||||
test "it doesn't create a notification for follow-unfollow-follow chains" do
|
test "it doesn't create a notification for follow-unfollow-follow chains" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
followed_user = insert(:user, locked: false)
|
followed_user = insert(:user, is_locked: false)
|
||||||
|
|
||||||
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
{:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
|
||||||
assert FollowingRelationship.following?(user, followed_user)
|
assert FollowingRelationship.following?(user, followed_user)
|
||||||
|
@ -397,7 +397,7 @@ test "it doesn't create a notification for follow-unfollow-follow chains" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "dismisses the notification on follow request rejection" do
|
test "dismisses the notification on follow request rejection" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
{:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user)
|
{:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user)
|
||||||
assert [notification] = Notification.for_user(user)
|
assert [notification] = Notification.for_user(user)
|
||||||
|
|
|
@ -82,7 +82,7 @@ test "Disabled via config" do
|
||||||
Pleroma.Config.put([:instance, :cleanup_attachments], false)
|
Pleroma.Config.put([:instance, :cleanup_attachments], false)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ test "in subdirectories" do
|
||||||
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ test "with dedupe enabled" do
|
||||||
File.mkdir_p!(uploads_dir)
|
File.mkdir_p!(uploads_dir)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ test "with objects that have legacy data.url attribute" do
|
||||||
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ test "With custom base_url" do
|
||||||
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
Pleroma.Config.put([:instance, :cleanup_attachments], true)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ defmodule Pleroma.Upload.Filter.AnonymizeFilenameTest do
|
||||||
|
|
||||||
upload_file = %Upload{
|
upload_file = %Upload{
|
||||||
name: "an… image.jpg",
|
name: "an… image.jpg",
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg")
|
path: Path.absname("test/fixtures/image_tmp.jpg")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ test "adds shasum" do
|
||||||
|
|
||||||
upload = %Upload{
|
upload = %Upload{
|
||||||
name: "an… image.jpg",
|
name: "an… image.jpg",
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ test "apply exiftool filter" do
|
||||||
|
|
||||||
upload = %Pleroma.Upload{
|
upload = %Pleroma.Upload{
|
||||||
name: "image_with_GPS_data.jpg",
|
name: "image_with_GPS_data.jpg",
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/DSCN0010.jpg"),
|
path: Path.absname("test/fixtures/DSCN0010.jpg"),
|
||||||
tempfile: Path.absname("test/fixtures/DSCN0010_tmp.jpg")
|
tempfile: Path.absname("test/fixtures/DSCN0010_tmp.jpg")
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ test "apply mogrify filter" do
|
||||||
|
|
||||||
upload = %Upload{
|
upload = %Upload{
|
||||||
name: "an… image.jpg",
|
name: "an… image.jpg",
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ test "apply mogrify filter" do
|
||||||
|
|
||||||
upload = %Pleroma.Upload{
|
upload = %Pleroma.Upload{
|
||||||
name: "an… image.jpg",
|
name: "an… image.jpg",
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ test "applies filters" do
|
||||||
|
|
||||||
upload = %Pleroma.Upload{
|
upload = %Pleroma.Upload{
|
||||||
name: "an… image.jpg",
|
name: "an… image.jpg",
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.UploadTest do
|
||||||
alias Pleroma.Uploaders.Uploader
|
alias Pleroma.Uploaders.Uploader
|
||||||
|
|
||||||
@upload_file %Plug.Upload{
|
@upload_file %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
filename: "image.jpg"
|
filename: "image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ test "does not allow descriptions longer than the post limit" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
filename: "image.jpg"
|
filename: "image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ test "returns a media url" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
filename: "image.jpg"
|
filename: "image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ test "copies the file to the configured folder with deduping" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
filename: "an [image.jpg"
|
filename: "an [image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ test "copies the file to the configured folder without deduping" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
filename: "an [image.jpg"
|
filename: "an [image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -165,63 +165,31 @@ test "copies the file to the configured folder without deduping" do
|
||||||
assert data["name"] == "an [image.jpg"
|
assert data["name"] == "an [image.jpg"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "fixes incorrect content type" do
|
test "fixes incorrect content type when base64 is given" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
params = %{
|
||||||
|
img: "data:image/png;base64,#{Base.encode64(File.read!("test/fixtures/image.jpg"))}"
|
||||||
file = %Plug.Upload{
|
|
||||||
content_type: "application/octet-stream",
|
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
|
||||||
filename: "an [image.jpg"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{:ok, data} = Upload.store(file, filters: [Pleroma.Upload.Filter.Dedupe])
|
{:ok, data} = Upload.store(params)
|
||||||
assert hd(data["url"])["mediaType"] == "image/jpeg"
|
assert hd(data["url"])["mediaType"] == "image/jpeg"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "adds missing extension" do
|
test "adds extension when base64 is given" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
params = %{
|
||||||
content_type: "image/jpg",
|
img: "data:image/png;base64,#{Base.encode64(File.read!("test/fixtures/image.jpg"))}"
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
|
||||||
filename: "an [image"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{:ok, data} = Upload.store(file)
|
{:ok, data} = Upload.store(params)
|
||||||
assert data["name"] == "an [image.jpg"
|
assert String.ends_with?(data["name"], ".jpg")
|
||||||
end
|
|
||||||
|
|
||||||
test "fixes incorrect file extension" do
|
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
|
||||||
|
|
||||||
file = %Plug.Upload{
|
|
||||||
content_type: "image/jpg",
|
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
|
||||||
filename: "an [image.blah"
|
|
||||||
}
|
|
||||||
|
|
||||||
{:ok, data} = Upload.store(file)
|
|
||||||
assert data["name"] == "an [image.jpg"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "don't modify filename of an unknown type" do
|
|
||||||
File.cp("test/fixtures/test.txt", "test/fixtures/test_tmp.txt")
|
|
||||||
|
|
||||||
file = %Plug.Upload{
|
|
||||||
content_type: "text/plain",
|
|
||||||
path: Path.absname("test/fixtures/test_tmp.txt"),
|
|
||||||
filename: "test.txt"
|
|
||||||
}
|
|
||||||
|
|
||||||
{:ok, data} = Upload.store(file)
|
|
||||||
assert data["name"] == "test.txt"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "copies the file to the configured folder with anonymizing filename" do
|
test "copies the file to the configured folder with anonymizing filename" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
filename: "an [image.jpg"
|
filename: "an [image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -235,7 +203,7 @@ test "escapes invalid characters in url" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
filename: "an… image.jpg"
|
filename: "an… image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -250,7 +218,7 @@ test "escapes reserved uri characters" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
filename: ":?#[]@!$&\\'()*+,;=.jpg"
|
filename: ":?#[]@!$&\\'()*+,;=.jpg"
|
||||||
}
|
}
|
||||||
|
@ -272,7 +240,7 @@ test "returns a media url with configured base_url" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
filename: "image.jpg"
|
filename: "image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ test "put file to local folder" do
|
||||||
|
|
||||||
file = %Pleroma.Upload{
|
file = %Pleroma.Upload{
|
||||||
name: "image.jpg",
|
name: "image.jpg",
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: file_path,
|
path: file_path,
|
||||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ test "deletes local file" do
|
||||||
|
|
||||||
file = %Pleroma.Upload{
|
file = %Pleroma.Upload{
|
||||||
name: "image.jpg",
|
name: "image.jpg",
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: file_path,
|
path: file_path,
|
||||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ test "it returns path with bucket namespace when namespace is set" do
|
||||||
setup do
|
setup do
|
||||||
file_upload = %Pleroma.Upload{
|
file_upload = %Pleroma.Upload{
|
||||||
name: "image-tet.jpg",
|
name: "image-tet.jpg",
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: "test_folder/image-tet.jpg",
|
path: "test_folder/image-tet.jpg",
|
||||||
tempfile: Path.absname("test/instance_static/add/shortcode.png")
|
tempfile: Path.absname("test/instance_static/add/shortcode.png")
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ test "ap_following returns the following collection for the user" do
|
||||||
|
|
||||||
test "returns all pending follow requests" do
|
test "returns all pending follow requests" do
|
||||||
unlocked = insert(:user)
|
unlocked = insert(:user)
|
||||||
locked = insert(:user, locked: true)
|
locked = insert(:user, is_locked: true)
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
|
|
||||||
CommonAPI.follow(follower, unlocked)
|
CommonAPI.follow(follower, unlocked)
|
||||||
|
@ -187,7 +187,7 @@ test "returns all pending follow requests" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "doesn't return already accepted or duplicate follow requests" do
|
test "doesn't return already accepted or duplicate follow requests" do
|
||||||
locked = insert(:user, locked: true)
|
locked = insert(:user, is_locked: true)
|
||||||
pending_follower = insert(:user)
|
pending_follower = insert(:user)
|
||||||
accepted_follower = insert(:user)
|
accepted_follower = insert(:user)
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ test "doesn't return already accepted or duplicate follow requests" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "doesn't return follow requests for deactivated accounts" do
|
test "doesn't return follow requests for deactivated accounts" do
|
||||||
locked = insert(:user, locked: true)
|
locked = insert(:user, is_locked: true)
|
||||||
pending_follower = insert(:user, %{deactivated: true})
|
pending_follower = insert(:user, %{deactivated: true})
|
||||||
|
|
||||||
CommonAPI.follow(pending_follower, locked)
|
CommonAPI.follow(pending_follower, locked)
|
||||||
|
@ -211,7 +211,7 @@ test "doesn't return follow requests for deactivated accounts" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "clears follow requests when requester is blocked" do
|
test "clears follow requests when requester is blocked" do
|
||||||
followed = insert(:user, locked: true)
|
followed = insert(:user, is_locked: true)
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
|
|
||||||
CommonAPI.follow(follower, followed)
|
CommonAPI.follow(follower, followed)
|
||||||
|
@ -299,8 +299,8 @@ test "can't subscribe to a user who blocked us" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "local users do not automatically follow local locked accounts" do
|
test "local users do not automatically follow local locked accounts" do
|
||||||
follower = insert(:user, locked: true)
|
follower = insert(:user, is_locked: true)
|
||||||
followed = insert(:user, locked: true)
|
followed = insert(:user, is_locked: true)
|
||||||
|
|
||||||
{:ok, follower} = User.maybe_direct_follow(follower, followed)
|
{:ok, follower} = User.maybe_direct_follow(follower, followed)
|
||||||
|
|
||||||
|
@ -1360,7 +1360,7 @@ test "it deactivates a user, all follow relationships and all activities", %{use
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
{:ok, follower} = User.follow(follower, user)
|
{:ok, follower} = User.follow(follower, user)
|
||||||
|
|
||||||
locked_user = insert(:user, name: "locked", locked: true)
|
locked_user = insert(:user, name: "locked", is_locked: true)
|
||||||
{:ok, _} = User.follow(user, locked_user, :follow_pending)
|
{:ok, _} = User.follow(user, locked_user, :follow_pending)
|
||||||
|
|
||||||
object = insert(:note, user: user)
|
object = insert(:note, user: user)
|
||||||
|
@ -1450,7 +1450,7 @@ test "delete/1 purges a user when they wouldn't be fully deleted" do
|
||||||
note_count: 9,
|
note_count: 9,
|
||||||
follower_count: 9,
|
follower_count: 9,
|
||||||
following_count: 9001,
|
following_count: 9001,
|
||||||
locked: true,
|
is_locked: true,
|
||||||
confirmation_pending: true,
|
confirmation_pending: true,
|
||||||
password_reset_pending: true,
|
password_reset_pending: true,
|
||||||
approval_pending: true,
|
approval_pending: true,
|
||||||
|
@ -1492,7 +1492,7 @@ test "delete/1 purges a user when they wouldn't be fully deleted" do
|
||||||
note_count: 0,
|
note_count: 0,
|
||||||
follower_count: 0,
|
follower_count: 0,
|
||||||
following_count: 0,
|
following_count: 0,
|
||||||
locked: false,
|
is_locked: false,
|
||||||
confirmation_pending: false,
|
confirmation_pending: false,
|
||||||
password_reset_pending: false,
|
password_reset_pending: false,
|
||||||
approval_pending: false,
|
approval_pending: false,
|
||||||
|
|
|
@ -1487,9 +1487,9 @@ test "POST /api/ap/upload_media", %{conn: conn} do
|
||||||
desc = "Description of the image"
|
desc = "Description of the image"
|
||||||
|
|
||||||
image = %Plug.Upload{
|
image = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "bad/content-type",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
object =
|
object =
|
||||||
|
@ -1504,6 +1504,7 @@ test "POST /api/ap/upload_media", %{conn: conn} do
|
||||||
assert [%{"href" => object_href, "mediaType" => object_mediatype}] = object["url"]
|
assert [%{"href" => object_href, "mediaType" => object_mediatype}] = object["url"]
|
||||||
assert is_binary(object_href)
|
assert is_binary(object_href)
|
||||||
assert object_mediatype == "image/jpeg"
|
assert object_mediatype == "image/jpeg"
|
||||||
|
assert String.ends_with?(object_href, ".jpg")
|
||||||
|
|
||||||
activity_request = %{
|
activity_request = %{
|
||||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||||
|
|
|
@ -1029,7 +1029,7 @@ test "returns reblogs for users for whom reblogs have not been muted" do
|
||||||
describe "uploading files" do
|
describe "uploading files" do
|
||||||
setup do
|
setup do
|
||||||
test_file = %Plug.Upload{
|
test_file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -1120,7 +1120,7 @@ test "creates an undo activity for the last follow" do
|
||||||
|
|
||||||
test "creates an undo activity for a pending follow request" do
|
test "creates an undo activity for a pending follow request" do
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
followed = insert(:user, %{locked: true})
|
followed = insert(:user, %{is_locked: true})
|
||||||
|
|
||||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||||
{:ok, activity} = ActivityPub.unfollow(follower, followed)
|
{:ok, activity} = ActivityPub.unfollow(follower, followed)
|
||||||
|
|
|
@ -56,7 +56,7 @@ test "it handles our own uploads" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ test "validates for a basic object with an attachment", %{
|
||||||
user: user
|
user: user
|
||||||
} do
|
} do
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ test "validates for a basic object with an attachment in an array", %{
|
||||||
user: user
|
user: user
|
||||||
} do
|
} do
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ test "validates for a basic object with an attachment but without content", %{
|
||||||
user: user
|
user: user
|
||||||
} do
|
} do
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ test "it works for incoming accepts which were pre-accepted" do
|
||||||
|
|
||||||
test "it works for incoming accepts which are referenced by IRI only" do
|
test "it works for incoming accepts which are referenced by IRI only" do
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
followed = insert(:user, locked: true)
|
followed = insert(:user, is_locked: true)
|
||||||
|
|
||||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ test "it works for incoming accepts which are referenced by IRI only" do
|
||||||
|
|
||||||
test "it fails for incoming accepts which cannot be correlated" do
|
test "it fails for incoming accepts which cannot be correlated" do
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
followed = insert(:user, locked: true)
|
followed = insert(:user, is_locked: true)
|
||||||
|
|
||||||
accept_data =
|
accept_data =
|
||||||
File.read!("test/fixtures/mastodon-accept-activity.json")
|
File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||||
|
|
|
@ -65,7 +65,7 @@ test "it works for incoming follow requests" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "with locked accounts, it does create a Follow, but not an Accept" do
|
test "with locked accounts, it does create a Follow, but not an Accept" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
|
|
||||||
data =
|
data =
|
||||||
File.read!("test/fixtures/mastodon-follow-activity.json")
|
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||||
|
@ -188,7 +188,7 @@ test "it works for incoming follow requests from hubzilla" do
|
||||||
|
|
||||||
test "it works for incoming follows to locked account" do
|
test "it works for incoming follows to locked account" do
|
||||||
pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
|
pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
|
|
||||||
data =
|
data =
|
||||||
File.read!("test/fixtures/mastodon-follow-activity.json")
|
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||||
|
|
|
@ -14,7 +14,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
|
||||||
|
|
||||||
test "it fails for incoming rejects which cannot be correlated" do
|
test "it fails for incoming rejects which cannot be correlated" do
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
followed = insert(:user, locked: true)
|
followed = insert(:user, is_locked: true)
|
||||||
|
|
||||||
accept_data =
|
accept_data =
|
||||||
File.read!("test/fixtures/mastodon-reject-activity.json")
|
File.read!("test/fixtures/mastodon-reject-activity.json")
|
||||||
|
@ -33,7 +33,7 @@ test "it fails for incoming rejects which cannot be correlated" do
|
||||||
|
|
||||||
test "it works for incoming rejects which are referenced by IRI only" do
|
test "it works for incoming rejects which are referenced by IRI only" do
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
followed = insert(:user, locked: true)
|
followed = insert(:user, is_locked: true)
|
||||||
|
|
||||||
{:ok, follower} = User.follow(follower, followed)
|
{:ok, follower} = User.follow(follower, followed)
|
||||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||||
|
|
|
@ -154,6 +154,6 @@ test "it works for incoming update activities which lock the account" do
|
||||||
{:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(update_data)
|
{:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(update_data)
|
||||||
|
|
||||||
user = User.get_cached_by_ap_id(user.ap_id)
|
user = User.get_cached_by_ap_id(user.ap_id)
|
||||||
assert user.locked == true
|
assert user.is_locked == true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -193,7 +193,7 @@ test "fetches only Create activities" do
|
||||||
|
|
||||||
describe "update_follow_state_for_all/2" do
|
describe "update_follow_state_for_all/2" do
|
||||||
test "updates the state of all Follow activities with the same actor and object" do
|
test "updates the state of all Follow activities with the same actor and object" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
|
|
||||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
||||||
|
@ -217,7 +217,7 @@ test "updates the state of all Follow activities with the same actor and object"
|
||||||
|
|
||||||
describe "update_follow_state/2" do
|
describe "update_follow_state/2" do
|
||||||
test "updates the state of the given follow activity" do
|
test "updates the state of the given follow activity" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
|
|
||||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
|
||||||
|
|
|
@ -100,7 +100,7 @@ test "it posts a chat message without content but with an attachment" do
|
||||||
recipient = insert(:user)
|
recipient = insert(:user)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -1071,7 +1071,7 @@ test "also unsubscribes a user" do
|
||||||
|
|
||||||
test "cancels a pending follow for a local user" do
|
test "cancels a pending follow for a local user" do
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
followed = insert(:user, locked: true)
|
followed = insert(:user, is_locked: true)
|
||||||
|
|
||||||
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
||||||
CommonAPI.follow(follower, followed)
|
CommonAPI.follow(follower, followed)
|
||||||
|
@ -1093,7 +1093,7 @@ test "cancels a pending follow for a local user" do
|
||||||
|
|
||||||
test "cancels a pending follow for a remote user" do
|
test "cancels a pending follow for a remote user" do
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
followed = insert(:user, locked: true, local: false, ap_enabled: true)
|
followed = insert(:user, is_locked: true, local: false, ap_enabled: true)
|
||||||
|
|
||||||
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
||||||
CommonAPI.follow(follower, followed)
|
CommonAPI.follow(follower, followed)
|
||||||
|
@ -1116,7 +1116,7 @@ test "cancels a pending follow for a remote user" do
|
||||||
|
|
||||||
describe "accept_follow_request/2" do
|
describe "accept_follow_request/2" do
|
||||||
test "after acceptance, it sets all existing pending follow request states to 'accept'" do
|
test "after acceptance, it sets all existing pending follow request states to 'accept'" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
follower_two = insert(:user)
|
follower_two = insert(:user)
|
||||||
|
|
||||||
|
@ -1136,7 +1136,7 @@ test "after acceptance, it sets all existing pending follow request states to 'a
|
||||||
end
|
end
|
||||||
|
|
||||||
test "after rejection, it sets all existing pending follow request states to 'reject'" do
|
test "after rejection, it sets all existing pending follow request states to 'reject'" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
follower_two = insert(:user)
|
follower_two = insert(:user)
|
||||||
|
|
||||||
|
@ -1156,7 +1156,7 @@ test "after rejection, it sets all existing pending follow request states to 're
|
||||||
end
|
end
|
||||||
|
|
||||||
test "doesn't create a following relationship if the corresponding follow request doesn't exist" do
|
test "doesn't create a following relationship if the corresponding follow request doesn't exist" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
not_follower = insert(:user)
|
not_follower = insert(:user)
|
||||||
CommonAPI.accept_follow_request(not_follower, user)
|
CommonAPI.accept_follow_request(not_follower, user)
|
||||||
|
|
||||||
|
|
|
@ -380,7 +380,7 @@ test "gets an users media, excludes reblogs", %{conn: conn} do
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -706,7 +706,7 @@ test "following / unfollowing a user", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "cancelling follow request", %{conn: conn} do
|
test "cancelling follow request", %{conn: conn} do
|
||||||
%{id: other_user_id} = insert(:user, %{locked: true})
|
%{id: other_user_id} = insert(:user, %{is_locked: true})
|
||||||
|
|
||||||
assert %{"id" => ^other_user_id, "following" => false, "requested" => true} =
|
assert %{"id" => ^other_user_id, "following" => false, "requested" => true} =
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -12,7 +12,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
|
||||||
|
|
||||||
describe "locked accounts" do
|
describe "locked accounts" do
|
||||||
setup do
|
setup do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
%{conn: conn} = oauth_access(["follow"], user: user)
|
%{conn: conn} = oauth_access(["follow"], user: user)
|
||||||
%{user: user, conn: conn}
|
%{user: user, conn: conn}
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
image = %Plug.Upload{
|
image = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ test "/api/v2/media", %{conn: conn, user: user, image: image} do
|
||||||
|
|
||||||
setup %{user: actor} do
|
setup %{user: actor} do
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ test "/api/v1/media/:id good request", %{conn: conn, object: object} do
|
||||||
|
|
||||||
setup %{user: actor} do
|
setup %{user: actor} do
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ test "Get MRF reason when posting a status is rejected by one", %{conn: conn} do
|
||||||
|
|
||||||
test "posting an undefined status with an attachment", %{user: user, conn: conn} do
|
test "posting an undefined status with an attachment", %{user: user, conn: conn} do
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ test "creates a scheduled activity with a media attachment", %{user: user, conn:
|
||||||
|> Kernel.<>("Z")
|
|> Kernel.<>("Z")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ test "updates the user's AKAs", %{conn: conn} do
|
||||||
|
|
||||||
test "updates the user's avatar", %{user: user, conn: conn} do
|
test "updates the user's avatar", %{user: user, conn: conn} do
|
||||||
new_avatar = %Plug.Upload{
|
new_avatar = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ test "updates the user's avatar", %{user: user, conn: conn} do
|
||||||
|
|
||||||
test "updates the user's banner", %{user: user, conn: conn} do
|
test "updates the user's banner", %{user: user, conn: conn} do
|
||||||
new_header = %Plug.Upload{
|
new_header = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ test "updates the user's banner", %{user: user, conn: conn} do
|
||||||
|
|
||||||
test "updates the user's background", %{conn: conn, user: user} do
|
test "updates the user's background", %{conn: conn, user: user} do
|
||||||
new_header = %Plug.Upload{
|
new_header = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ test "represent a relationship for the user blocking a domain" do
|
||||||
|
|
||||||
test "represent a relationship for the user with a pending follow request" do
|
test "represent a relationship for the user with a pending follow request" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
other_user = insert(:user, locked: true)
|
other_user = insert(:user, is_locked: true)
|
||||||
|
|
||||||
{:ok, user, other_user, _} = CommonAPI.follow(user, other_user)
|
{:ok, user, other_user, _} = CommonAPI.follow(user, other_user)
|
||||||
user = User.get_cached_by_id(user.id)
|
user = User.get_cached_by_id(user.id)
|
||||||
|
@ -484,7 +484,7 @@ test "shows zero when no follow requests are pending" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "shows non-zero when follow requests are pending" do
|
test "shows non-zero when follow requests are pending" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
|
|
||||||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ test "shows non-zero when follow requests are pending" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "decreases when accepting a follow request" do
|
test "decreases when accepting a follow request" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
|
|
||||||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ test "decreases when accepting a follow request" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "decreases when rejecting a follow request" do
|
test "decreases when rejecting a follow request" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
|
|
||||||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||||
|
|
||||||
|
@ -530,14 +530,14 @@ test "decreases when rejecting a follow request" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "shows non-zero when historical unapproved requests are present" do
|
test "shows non-zero when historical unapproved requests are present" do
|
||||||
user = insert(:user, locked: true)
|
user = insert(:user, is_locked: true)
|
||||||
|
|
||||||
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
assert %{locked: true} = AccountView.render("show.json", %{user: user, for: user})
|
||||||
|
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
{:ok, _other_user, user, _activity} = CommonAPI.follow(other_user, user)
|
||||||
|
|
||||||
{:ok, user} = User.update_and_set_cache(user, %{locked: false})
|
{:ok, user} = User.update_and_set_cache(user, %{is_locked: false})
|
||||||
|
|
||||||
assert %{locked: false, follow_requests_count: 1} =
|
assert %{locked: false, follow_requests_count: 1} =
|
||||||
AccountView.render("show.json", %{user: user, for: user})
|
AccountView.render("show.json", %{user: user, for: user})
|
||||||
|
|
|
@ -22,7 +22,7 @@ test "A scheduled activity with a media attachment" do
|
||||||
|> NaiveDateTime.to_iso8601()
|
|> NaiveDateTime.to_iso8601()
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ test "it fails if there is no content", %{conn: conn, user: user} do
|
||||||
|
|
||||||
test "it works with an attachment", %{conn: conn, user: user} do
|
test "it works with an attachment", %{conn: conn, user: user} do
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ test "mascot upload" do
|
||||||
assert json_response_and_validate_schema(ret_conn, 415)
|
assert json_response_and_validate_schema(ret_conn, 415)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ test "mascot retrieving" do
|
||||||
|
|
||||||
# When a user sets their mascot, we should get that back
|
# When a user sets their mascot, we should get that back
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ test "it displays a chat message" do
|
||||||
recipient = insert(:user)
|
recipient = insert(:user)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ defp upload_file(context) do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
path: Path.absname("test/fixtures/image_tmp.jpg"),
|
||||||
filename: "nice_tf.jpg"
|
filename: "nice_tf.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ test "builds content for chat messages with no content" do
|
||||||
recipient = insert(:user)
|
recipient = insert(:user)
|
||||||
|
|
||||||
file = %Plug.Upload{
|
file = %Plug.Upload{
|
||||||
content_type: "image/jpg",
|
content_type: "image/jpeg",
|
||||||
path: Path.absname("test/fixtures/image.jpg"),
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
filename: "an_image.jpg"
|
filename: "an_image.jpg"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue