Merge branch 'develop' into mutes-blocks-pagination
authorEgor Kislitsyn <egor@kislitsyn.com>
Mon, 19 Oct 2020 11:40:03 +0000 (15:40 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Mon, 19 Oct 2020 11:40:03 +0000 (15:40 +0400)
85 files changed:
.credo.exs
.gitignore
.gitlab-ci.yml
CHANGELOG.md
config/config.exs
config/description.exs
docs/administration/CLI_tasks/instance.md
docs/administration/CLI_tasks/release_environments.md [new file with mode: 0644]
docs/clients.md
docs/installation/alpine_linux_en.md
docs/installation/arch_linux_en.md
docs/installation/debian_based_en.md
docs/installation/debian_based_jp.md
docs/installation/gentoo_en.md
docs/installation/otp_en.md
installation/init.d/pleroma
installation/pleroma.service
lib/mix/tasks/pleroma/instance.ex
lib/mix/tasks/pleroma/release_env.ex [new file with mode: 0644]
lib/mix/tasks/pleroma/user.ex
lib/pleroma/application.ex
lib/pleroma/mime.ex [deleted file]
lib/pleroma/upload.ex
lib/pleroma/user.ex
lib/pleroma/user/search.ex
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/activity_pub_controller.ex
lib/pleroma/web/activity_pub/side_effects.ex
lib/pleroma/web/activity_pub/views/user_view.ex
lib/pleroma/web/admin_api/views/account_view.ex
lib/pleroma/web/api_spec/schemas/chat.ex
lib/pleroma/web/api_spec/schemas/status.ex
lib/pleroma/web/mastodon_api/controllers/account_controller.ex
lib/pleroma/web/mastodon_api/controllers/media_controller.ex
lib/pleroma/web/mastodon_api/views/account_view.ex
lib/pleroma/web/metadata/providers/restrict_indexing.ex
lib/pleroma/web/pleroma_api/controllers/account_controller.ex
lib/pleroma/web/pleroma_api/controllers/mascot_controller.ex
mix.exs
mix.lock
priv/repo/migrations/20201013141127_refactor_locked_user_field.exs [new file with mode: 0644]
priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs [new file with mode: 0644]
test/credo/check/consistency/file_location.ex [moved from lib/credo/check/consistency/file_location.ex with 100% similarity]
test/mix/tasks/pleroma/instance_test.exs
test/mix/tasks/pleroma/release_env_test.exs [new file with mode: 0644]
test/mix/tasks/pleroma/user_test.exs
test/pleroma/notification_test.exs
test/pleroma/object_test.exs
test/pleroma/upload/filter/anonymize_filename_test.exs
test/pleroma/upload/filter/dedupe_test.exs
test/pleroma/upload/filter/exiftool_test.exs
test/pleroma/upload/filter/mogrifun_test.exs
test/pleroma/upload/filter/mogrify_test.exs
test/pleroma/upload/filter_test.exs
test/pleroma/upload_test.exs
test/pleroma/uploaders/local_test.exs
test/pleroma/uploaders/s3_test.exs
test/pleroma/user_search_test.exs
test/pleroma/user_test.exs
test/pleroma/web/activity_pub/activity_pub_controller_test.exs
test/pleroma/web/activity_pub/activity_pub_test.exs
test/pleroma/web/activity_pub/object_validators/attachment_validator_test.exs
test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs
test/pleroma/web/activity_pub/transmogrifier/accept_handling_test.exs
test/pleroma/web/activity_pub/transmogrifier/follow_handling_test.exs
test/pleroma/web/activity_pub/transmogrifier/reject_handling_test.exs
test/pleroma/web/activity_pub/transmogrifier/user_update_handling_test.exs
test/pleroma/web/activity_pub/utils_test.exs
test/pleroma/web/admin_api/search_test.exs
test/pleroma/web/common_api_test.exs
test/pleroma/web/mastodon_api/controllers/account_controller_test.exs
test/pleroma/web/mastodon_api/controllers/follow_request_controller_test.exs
test/pleroma/web/mastodon_api/controllers/media_controller_test.exs
test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
test/pleroma/web/mastodon_api/update_credentials_test.exs
test/pleroma/web/mastodon_api/views/account_view_test.exs
test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs
test/pleroma/web/metadata/providers/restrict_indexing_test.exs
test/pleroma/web/metadata_test.exs
test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs
test/pleroma/web/pleroma_api/controllers/mascot_controller_test.exs
test/pleroma/web/pleroma_api/views/chat_message_reference_view_test.exs
test/pleroma/web/plugs/uploaded_media_plug_test.exs
test/pleroma/web/push/impl_test.exs
test/support/factory.ex

index 83e34a2b4de5b4fe3e4b0c36dc9cc6e17ee84000..b85898af361f7fe858db104b6206f5e3fd290e5e 100644 (file)
@@ -25,7 +25,7 @@
       #
       # If you create your own checks, you must specify the source files for
       # them here, so they can be loaded by Credo before running the analysis.
-      requires: ["./lib/credo/check/consistency/file_location.ex"],
+      requires: ["./test/credo/check/consistency/file_location.ex"],
       #
       # Credo automatically checks for updates, like e.g. Hex does.
       # You can disable this behaviour below:
index 599b52b9e0b8f2084a889bb9aca56ca0dec76e01..6ae21e9144f410f289fc0734b714bfcbd7226aac 100644 (file)
@@ -27,6 +27,8 @@ erl_crash.dump
 # variables.
 /config/*.secret.exs
 /config/generated_config.exs
+/config/*.env
+
 
 # Database setup file, some may forget to delete it
 /config/setup_db.psql
index 121e4abfe183d279ecdf73271841c8cc4525e165..e65cae9d8b987dc74c623bc7b6ecbd99ccafa022 100644 (file)
@@ -25,6 +25,8 @@ before_script:
   - apt-get update && apt-get install -y cmake
   - mix local.hex --force
   - mix local.rebar --force
+  - apt-get -qq update
+  - apt-get install -y libmagic-dev
 
 build:
   stage: build
index 216d7bb321e9fabaf64746dcb6d81ff2733aeb4d..41f0a4402c7ca010e962c1983b5f7accb841c3ce 100644 (file)
@@ -9,10 +9,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Mix tasks for controlling user account confirmation status in bulk (`mix pleroma.user confirm_all` and `mix pleroma.user unconfirm_all`)
 - Mix task for sending confirmation emails to all unconfirmed users (`mix pleroma.email send_confirmation_mails`)
 - Mix task option for force-unfollowing relays
+- Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details).
+- Pleroma API: Importing the mutes users from CSV files.
+- Experimental websocket-based federation between Pleroma instances.
 - Support pagination of blocks and mutes
 
 ### Changed
 
+- **Breaking** Requires `libmagic` (or `file`) to guess file types.
 - **Breaking:** Pleroma Admin API: emoji packs and files routes changed.
 - **Breaking:** Sensitive/NSFW statuses no longer disable link previews.
 - Search: Users are now findable by their urls.
@@ -23,11 +27,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Minimum lifetime for ephmeral activities changed to 10 minutes and made configurable (`:min_lifetime` option).
 - Introduced optional dependencies on `ffmpeg`, `ImageMagick`, `exiftool` software packages. Please refer to `docs/installation/optional/media_graphics_packages.md`.
 
-### Added
-- Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details).
-- Pleroma API: Importing the mutes users from CSV files.
-- Experimental websocket-based federation between Pleroma instances.
-
 <details>
   <summary>API Changes</summary>
 
index 273da5bb6728faf2daf12f5bee3e66c01347d12b..2c614236033863a8560fbeae068f54eb0c24fe51 100644 (file)
@@ -802,6 +802,8 @@ config :pleroma, :hackney_pools,
     timeout: 300_000
   ]
 
+config :pleroma, :majic_pool, size: 2
+
 private_instance? = :if_instance_is_private
 
 config :pleroma, :restrict_unauthenticated,
index 6e83a8e094571e8699a857191532c5991d51c9a6..2a18989224fd12e9c0f87a16d55ba63ea4b81847 100644 (file)
@@ -3708,5 +3708,19 @@ config :pleroma, :config_description, [
         ]
       }
     ]
+  },
+  %{
+    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]
+      }
+    ]
   }
 ]
index d6913280a1f5a5585c3966747b2e545ed028b70d..982b22bf3c9223aef29aec7109d78b8329105b95 100644 (file)
@@ -40,3 +40,5 @@ If any of the options are left unspecified, you will be prompted interactively.
 - `--strip-uploads <Y|N>` - use ExifTool to strip uploads of sensitive location data
 - `--anonymize-uploads <Y|N>` - randomize uploaded filenames
 - `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames
+- `--skip-release-env` - skip generation the release environment file
+- `--release-env-file` - release environment file path
diff --git a/docs/administration/CLI_tasks/release_environments.md b/docs/administration/CLI_tasks/release_environments.md
new file mode 100644 (file)
index 0000000..36ab438
--- /dev/null
@@ -0,0 +1,9 @@
+# Generate release environment file
+
+```sh tab="OTP"
+ ./bin/pleroma_ctl release_env gen
+```
+
+```sh tab="From Source"
+mix pleroma.release_env gen
+```
index f84295b1f50536bddc090feb29a6c5186d43209b..1e2c14f1baf706fbff35aa4d6d8d212605c7f5a7 100644 (file)
@@ -71,7 +71,7 @@ Feel free to contact us to be added to this list!
 ### Indigenous
 - Homepage: <https://indigenous.realize.be/>
 - Source Code: <https://github.com/swentel/indigenous-android/>
-- Contact: [@realize.be@realize.be](@realize.be@realize.be)
+- Contact: [@swentel@realize.be](https://realize.be)
 - Platforms: Android
 - Features: No Streaming
 
index d89c7f46f332c89f355e1999903670e536796269..62f2fb778e27dac29c496337dddc32cb86c7f043 100644 (file)
@@ -13,6 +13,7 @@ It assumes that you have administrative rights, either as root or a user with [s
 * `erlang-parsetools`
 * `erlang-xmerl`
 * `git`
+* `file-dev`
 * Development Tools
 * `cmake`
 
@@ -42,7 +43,7 @@ sudo apk upgrade
 * Install some tools, which are needed later:
 
 ```shell
-sudo apk add git build-base cmake
+sudo apk add git build-base cmake file-dev
 ```
 
 ### Install Elixir and Erlang
index 724b4660a4aa3af09fe6ebe64d1a587605b9f519..0eb6d2d5f8dd90762186207e76c4a8bc4d8a2184 100644 (file)
@@ -10,6 +10,7 @@ This guide will assume that you have administrative rights, either as root or a
 * `git`
 * `base-devel`
 * `cmake`
+* `file`
 
 #### Optional packages used in this guide
 
@@ -30,7 +31,7 @@ sudo pacman -Syu
 * Install some of the above mentioned programs:
 
 ```shell
-sudo pacman -S git base-devel elixir cmake
+sudo pacman -S git base-devel elixir cmake file
 ```
 
 ### Install PostgreSQL
index eac499a295ade15096e24f42e2ffffeaed59bef8..b9fc4e1126cdaac01e40e5d69742068e07b6c558 100644 (file)
@@ -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)
 * `erlang-dev`
 * `erlang-nox`
+* `libmagic-dev`
 * `git`
 * `build-essential`
 * `cmake`
@@ -34,7 +35,7 @@ sudo apt full-upgrade
 * Install some of the above mentioned programs:
 
 ```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
@@ -100,6 +101,7 @@ sudo -Hu pleroma mix deps.get
 mv config/{generated_config.exs,prod.secret.exs}
 ```
 
+
 * The previous command creates also the file `config/setup_db.psql`, with which you can create the database:
 
 ```shell
@@ -180,6 +182,7 @@ sudo cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.se
 ```
 
 * Edit the service file and make sure that all paths fit your installation
+* Check that `EnvironmentFile` contains the correct path to the env file. Or generate the env file: `sudo -Hu pleroma mix pleroma.release_env gen`
 * Enable and start `pleroma.service`:
 
 ```shell
index 764afbe1a4497940d69158ca2f7978e64a7c57ea..94e22325c37414289660fdc41c2109e451342f74 100644 (file)
@@ -17,6 +17,7 @@
 - `git`
 - `build-essential`
 - `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をインストールします
index 638fc4e47cdb941bd4a453a72f38f8f7a1b1d244..f2380ab72031f61a10ae186c2f60b4081563891f 100644 (file)
@@ -29,6 +29,7 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
 * `dev-lang/elixir`
 * `dev-vcs/git`
 * `dev-util/cmake`
+* `sys-apps/file`
 
 #### 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:
 
 ```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. 
index 92584d80dff47c2c95af471143d10e6ee1e7e880..676b10699c2c8b7cd7630abd0fd6ebc4220f0549 100644 (file)
@@ -27,17 +27,18 @@ Other than things bundled in the OTP release Pleroma depends on:
 * PostgreSQL (also utilizes extensions in postgresql-contrib)
 * 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)
+* libmagic/file
 
 === "Alpine"
     ```
     echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
     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"
     ```
-    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
@@ -148,6 +149,9 @@ chown -R pleroma /etc/pleroma
 # Run the config generator
 su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql"
 
+# Run the environment file generator.
+su pleroma -s $SHELL -lc "./bin/pleroma_ctl release_env gen"
+
 # Create the postgres database
 su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
 
@@ -158,7 +162,7 @@ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
 # su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
 
 # Start the instance to verify that everything is working as expected
-su pleroma -s $SHELL -lc "./bin/pleroma daemon"
+su pleroma -s $SHELL -lc "export $(cat /opt/pleroma/config/pleroma.env); ./bin/pleroma daemon"
 
 # Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly
 sleep 20 && curl http://localhost:4000/api/v1/instance
@@ -310,4 +314,3 @@ This will create an account withe the username of 'joeuser' with the email addre
 ## Questions
 
 Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
-
index 384536f7e99d50efdb17bfe1683990efb6b1ea04..e908cda1b318ab4bea6d6371b898b8ecb12a6667 100755 (executable)
@@ -8,6 +8,7 @@ pidfile="/var/run/pleroma.pid"
 directory=/opt/pleroma
 healthcheck_delay=60
 healthcheck_timer=30
+export $(cat /opt/pleroma/config/pleroma.env)
 
 : ${pleroma_port:-4000}
 
index 5dcbc13877f916de16443bec9ead491ee26bb687..ee00a3b7ad5b7654b7e8dcdf23f362f284e0786c 100644 (file)
@@ -17,6 +17,8 @@ Environment="MIX_ENV=prod"
 Environment="HOME=/var/lib/pleroma"
 ; Path to the folder containing the Pleroma installation.
 WorkingDirectory=/opt/pleroma
+; Path to the environment file. the file contains RELEASE_COOKIE and etc 
+EnvironmentFile=/opt/pleroma/config/pleroma.env
 ; Path to the Mix binary.
 ExecStart=/usr/bin/mix phx.server
 
index fc21ae06255b88677088beb4270d6871e6a5e30c..1915aacd9b2973092eebadd8adb708bf3d432371 100644 (file)
@@ -36,7 +36,9 @@ defmodule Mix.Tasks.Pleroma.Instance do
           listen_port: :string,
           strip_uploads: :string,
           anonymize_uploads: :string,
-          dedupe_uploads: :string
+          dedupe_uploads: :string,
+          skip_release_env: :boolean,
+          release_env_file: :string
         ],
         aliases: [
           o: :output,
@@ -241,6 +243,24 @@ defmodule Mix.Tasks.Pleroma.Instance do
 
       write_robots_txt(static_dir, indexable, template_dir)
 
+      if Keyword.get(options, :skip_release_env, false) do
+        shell_info("""
+        Release environment file is skip. Please generate the release env file before start.
+        `MIX_ENV=#{Mix.env()} mix pleroma.release_env gen`
+        """)
+      else
+        shell_info("Generation the environment file:")
+
+        release_env_args =
+          with path when not is_nil(path) <- Keyword.get(options, :release_env_file) do
+            ["gen", "--path", path]
+          else
+            _ -> ["gen"]
+          end
+
+        Mix.Tasks.Pleroma.ReleaseEnv.run(release_env_args)
+      end
+
       shell_info(
         "\n All files successfully written! Refer to the installation instructions for your platform for next steps."
       )
diff --git a/lib/mix/tasks/pleroma/release_env.ex b/lib/mix/tasks/pleroma/release_env.ex
new file mode 100644 (file)
index 0000000..9da74ff
--- /dev/null
@@ -0,0 +1,76 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Mix.Tasks.Pleroma.ReleaseEnv do
+  use Mix.Task
+  import Mix.Pleroma
+
+  @shortdoc "Generate Pleroma environment file."
+  @moduledoc File.read!("docs/administration/CLI_tasks/release_environments.md")
+
+  def run(["gen" | rest]) do
+    {options, [], []} =
+      OptionParser.parse(
+        rest,
+        strict: [
+          force: :boolean,
+          path: :string
+        ],
+        aliases: [
+          p: :path,
+          f: :force
+        ]
+      )
+
+    file_path =
+      get_option(
+        options,
+        :path,
+        "Environment file path",
+        "./config/pleroma.env"
+      )
+
+    env_path = Path.expand(file_path)
+
+    proceed? =
+      if File.exists?(env_path) do
+        get_option(
+          options,
+          :force,
+          "Environment file already exists. Do you want to overwrite the #{env_path} file? (y/n)",
+          "n"
+        ) === "y"
+      else
+        true
+      end
+
+    if proceed? do
+      case do_generate(env_path) do
+        {:error, reason} ->
+          shell_error(
+            File.Error.message(%{action: "write to file", reason: reason, path: env_path})
+          )
+
+        _ ->
+          shell_info("\nThe file generated: #{env_path}.\n")
+
+          shell_info("""
+          WARNING: before start pleroma app please make sure to make the file read-only and non-modifiable.
+            Example:
+              chmod 0444 #{file_path}
+              chattr +i #{file_path}
+          """)
+      end
+    else
+      shell_info("\nThe file is exist. #{env_path}.\n")
+    end
+  end
+
+  def do_generate(path) do
+    content = "RELEASE_COOKIE=#{Base.encode32(:crypto.strong_rand_bytes(32))}"
+
+    File.mkdir_p!(Path.dirname(path))
+    File.write(path, content)
+  end
+end
index e062628047b402d192a0a4be3cd41e1f5020c7ae..a8d2514118992eea0850b713d2471733b4ed5960 100644 (file)
@@ -419,7 +419,7 @@ defmodule Mix.Tasks.Pleroma.User do
       |> Enum.each(fn user ->
         shell_info(
           "#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
-            user.locked
+            user.is_locked
           }, deactivated: #{user.deactivated}"
         )
       end)
@@ -447,10 +447,10 @@ defmodule Mix.Tasks.Pleroma.User do
   defp set_locked(user, value) do
     {:ok, user} =
       user
-      |> Changeset.change(%{locked: value})
+      |> Changeset.change(%{is_locked: value})
       |> 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
   end
 
index 958e32db248075c33db6211e6aa4f9651b543f92..301b4e2735017efc9be8f362dadea9af25a193aa 100644 (file)
@@ -95,6 +95,7 @@ defmodule Pleroma.Application do
         [
           Pleroma.Stats,
           Pleroma.JobQueueMonitor,
+          {Majic.Pool, [name: Pleroma.MajicPool, pool_size: Config.get([:majic_pool, :size], 2)]},
           {Oban, Config.get(Oban)}
         ] ++
         task_children(@env) ++
diff --git a/lib/pleroma/mime.ex b/lib/pleroma/mime.ex
deleted file mode 100644 (file)
index 6ee055f..0000000
+++ /dev/null
@@ -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
index 015c875938967e3fed944f7eb21b46a85274cb96..db2cc1dae278009701222528e3bd159a7b7a494e 100644 (file)
@@ -66,6 +66,7 @@ defmodule Pleroma.Upload do
   end
 
   @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
     opts = get_opts(opts)
 
@@ -139,14 +140,13 @@ defmodule Pleroma.Upload do
   end
 
   defp prepare_upload(%Plug.Upload{} = file, opts) do
-    with :ok <- check_file_size(file.path, opts.size_limit),
-         {:ok, content_type, name} <- Pleroma.MIME.file_mime_type(file.path, file.filename) do
+    with :ok <- check_file_size(file.path, opts.size_limit) do
       {:ok,
        %__MODULE__{
          id: UUID.generate(),
-         name: name,
+         name: file.filename,
          tempfile: file.path,
-         content_type: content_type
+         content_type: file.content_type
        }}
     end
   end
@@ -154,16 +154,17 @@ defmodule Pleroma.Upload do
   defp prepare_upload(%{img: "data:image/" <> image_data}, opts) do
     parsed = Regex.named_captures(~r/(?<filetype>jpeg|png|gif);base64,(?<data>.*)/, image_data)
     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),
          tmp_path <- tempfile_for_image(data),
-         {:ok, content_type, name} <-
-           Pleroma.MIME.bin_mime_type(data, hash <> "." <> parsed["filetype"]) do
+         {:ok, %{mime_type: content_type}} <-
+           Majic.perform({:bytes, data}, pool: Pleroma.MajicPool),
+         [ext | _] <- MIME.extensions(content_type) do
       {:ok,
        %__MODULE__{
          id: UUID.generate(),
-         name: name,
+         name: hash <> "." <> ext,
          tempfile: tmp_path,
          content_type: content_type
        }}
@@ -172,7 +173,7 @@ defmodule Pleroma.Upload do
 
   # For Mix.Tasks.MigrateLocalUploads
   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}}
     end
   end
index 09ea8079391b6b8c7c882ee7d19778e58c1bce42..dc41d00014b6fba5c8874a01a696bf898dea8358 100644 (file)
@@ -107,7 +107,7 @@ defmodule Pleroma.User do
     field(:note_count, :integer, default: 0)
     field(:follower_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(:password_reset_pending, :boolean, default: false)
     field(:approval_pending, :boolean, default: false)
@@ -136,7 +136,7 @@ defmodule Pleroma.User do
     field(:pleroma_settings_store, :map, default: %{})
     field(:fields, {:array, :map}, default: [])
     field(:raw_fields, {:array, :map}, default: [])
-    field(:discoverable, :boolean, default: false)
+    field(:is_discoverable, :boolean, default: false)
     field(:invisible, :boolean, default: false)
     field(:allow_following_move, :boolean, default: true)
     field(:skip_thread_containment, :boolean, default: false)
@@ -436,7 +436,7 @@ defmodule Pleroma.User do
         :avatar,
         :ap_enabled,
         :banner,
-        :locked,
+        :is_locked,
         :last_refreshed_at,
         :uri,
         :follower_address,
@@ -448,7 +448,7 @@ defmodule Pleroma.User do
         :follower_count,
         :fields,
         :following_count,
-        :discoverable,
+        :is_discoverable,
         :invisible,
         :actor_type,
         :also_known_as,
@@ -479,7 +479,7 @@ defmodule Pleroma.User do
         :public_key,
         :inbox,
         :shared_inbox,
-        :locked,
+        :is_locked,
         :no_rich_text,
         :default_scope,
         :banner,
@@ -495,7 +495,7 @@ defmodule Pleroma.User do
         :fields,
         :raw_fields,
         :pleroma_settings_store,
-        :discoverable,
+        :is_discoverable,
         :actor_type,
         :also_known_as,
         :accepts_chat_messages
@@ -847,7 +847,7 @@ defmodule Pleroma.User do
   @spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t()} | {:error, String.t()}
 
   # "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)
   end
 
@@ -954,7 +954,7 @@ defmodule Pleroma.User do
   end
 
   def locked?(%User{} = user) do
-    user.locked || false
+    user.is_locked || false
   end
 
   def get_by_id(id) do
@@ -1601,7 +1601,7 @@ defmodule Pleroma.User do
       note_count: 0,
       follower_count: 0,
       following_count: 0,
-      locked: false,
+      is_locked: false,
       confirmation_pending: false,
       password_reset_pending: false,
       approval_pending: false,
@@ -1618,7 +1618,7 @@ defmodule Pleroma.User do
       pleroma_settings_store: %{},
       fields: [],
       raw_fields: [],
-      discoverable: false,
+      is_discoverable: false,
       also_known_as: []
     })
   end
index 35a828008ceb34e6b6653b34d47df68b65c54d53..2dab672112b9636c1e62fda0beb630f37d162216 100644 (file)
@@ -164,7 +164,7 @@ defmodule Pleroma.User.Search do
   end
 
   defp filter_discoverable_users(query) do
-    from(q in query, where: q.discoverable == true)
+    from(q in query, where: q.is_discoverable == true)
   end
 
   defp filter_internal_users(query) do
index eb44cffec14eddb5634a3973a1f6625fbcd14acb..d17c892a7e2b6d6600220e37a2812176354d32fe 100644 (file)
@@ -827,7 +827,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     query =
       from([activity] in query,
         where: fragment("not (? = ANY(?))", activity.actor, ^mutes),
-        where: fragment("not (?->'to' \\?| ?)", activity.data, ^mutes)
+        where:
+          fragment(
+            "not (?->'to' \\?| ?) or ? = ?",
+            activity.data,
+            ^mutes,
+            activity.actor,
+            ^user.ap_id
+          )
       )
 
     unless opts[:skip_preload] do
@@ -1228,11 +1235,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
         {String.trim(name, ":"), url}
       end)
 
-    locked = data["manuallyApprovesFollowers"] || false
+    is_locked = data["manuallyApprovesFollowers"] || false
     capabilities = data["capabilities"] || %{}
     accepts_chat_messages = capabilities["acceptsChatMessages"]
     data = Transmogrifier.maybe_fix_user_object(data)
-    discoverable = data["discoverable"] || false
+    is_discoverable = data["discoverable"] || false
     invisible = data["invisible"] || false
     actor_type = data["type"] || "Person"
 
@@ -1257,8 +1264,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       banner: banner,
       fields: fields,
       emoji: emojis,
-      locked: locked,
-      discoverable: discoverable,
+      is_locked: is_locked,
+      is_discoverable: is_discoverable,
       invisible: invisible,
       avatar: avatar,
       name: data["name"],
index 6bf7421bb6e9df004577262dd22c919f0543c489..570bcc7e7384613378d0462737cc8f435a3b859f 100644 (file)
@@ -45,6 +45,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
     when action in [:read_inbox, :update_outbox, :whoami, :upload_media]
   )
 
+  plug(Majic.Plug, [pool: Pleroma.MajicPool] when action in [:upload_media])
+
   plug(
     Pleroma.Web.Plugs.Cache,
     [query_params: false, tracking_fun: &__MODULE__.track_object_fetch/2]
index 2eec0ce86c4dfd7f2b1b10ded560e704d0f17906..d421ca7af59c713f6cba366bbecfbbd273f91d27 100644 (file)
@@ -102,7 +102,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
          %User{} = followed <- User.get_cached_by_ap_id(followed_user),
          {_, {:ok, _}, _, _} <-
            {: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, _activity, _} = Pipeline.common_pipeline(accept_data, local: true)
       end
index 3a4564912c2d1508bac155bc79b23f857c528a1d..4dc45cde344873d1f6d74a6b0c4b9783b3fde6ed 100644 (file)
@@ -101,7 +101,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
       "name" => user.name,
       "summary" => user.bio,
       "url" => user.ap_id,
-      "manuallyApprovesFollowers" => user.locked,
+      "manuallyApprovesFollowers" => user.is_locked,
       "publicKey" => %{
         "id" => "#{user.ap_id}#main-key",
         "owner" => user.ap_id,
@@ -110,7 +110,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
       "endpoints" => endpoints,
       "attachment" => fields,
       "tag" => emoji_tags,
-      "discoverable" => user.discoverable,
+      "discoverable" => user.is_discoverable,
       "capabilities" => capabilities
     }
     |> Map.merge(maybe_make_image(&User.avatar_url/2, "icon", user))
index 9c477feabb49812c96dcade416a9f65b52431015..bda7ea19ce710b2d4e666e59b35779b1cba63513 100644 (file)
@@ -39,7 +39,7 @@ defmodule Pleroma.Web.AdminAPI.AccountView do
       :fields,
       :name,
       :nickname,
-      :locked,
+      :is_locked,
       :no_rich_text,
       :default_scope,
       :hide_follows,
index b4986b734e9b7613504aa299a7b4b4cd0c226a95..65f908e33f47552b6bbfa7d587d6c3adb730d67b 100644 (file)
@@ -50,7 +50,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Chat do
           "fields" => []
         },
         "statuses_count" => 1,
-        "locked" => false,
+        "is_locked" => false,
         "created_at" => "2020-04-16T13:40:15.000Z",
         "display_name" => "lain",
         "fields" => [],
index 947e42890744d80117615417361bd881f1e9c709..e6890df2dd67dd6196bcc186588e93deadb44e82 100644 (file)
@@ -252,7 +252,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
         "header" => "http://localhost:4001/images/banner.png",
         "header_static" => "http://localhost:4001/images/banner.png",
         "id" => "9toJCsKN7SmSf3aj5c",
-        "locked" => false,
+        "is_locked" => false,
         "note" => "Tester Number 6",
         "pleroma" => %{
           "background_image" => nil,
index c8606e5d6eba6de554a045f2afdf87d3d2fc9a21..a2715cf28a3d35dc3363714c35f0f029d45523c8 100644 (file)
@@ -177,7 +177,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
     user_params =
       [
         :no_rich_text,
-        :locked,
         :hide_followers_count,
         :hide_follows_count,
         :hide_followers,
@@ -186,7 +185,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
         :show_role,
         :skip_thread_containment,
         :allow_following_move,
-        :discoverable,
         :accepts_chat_messages
       ]
       |> Enum.reduce(%{}, fn key, acc ->
@@ -210,6 +208,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
         if bot, do: {:ok, "Service"}, else: {:ok, "Person"}
       end)
       |> Maps.put_if_present(:actor_type, params[:actor_type])
+      |> Maps.put_if_present(:is_locked, params[:locked])
+      |> Maps.put_if_present(:is_discoverable, params[:discoverable])
 
     # What happens here:
     #
index 9586b14bc37c906d266e0c58fd41036a64ad5018..161193134132bb905ae0855a964f5bb008a273cf 100644 (file)
@@ -11,6 +11,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaController do
   alias Pleroma.Web.Plugs.OAuthScopesPlug
 
   action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
+  plug(Majic.Plug, [pool: Pleroma.MajicPool] when action in [:create, :create2])
   plug(Pleroma.Web.ApiSpec.CastAndValidate)
   plug(:put_view, Pleroma.Web.MastodonAPI.StatusView)
 
index 121ba1693155adf30f4c17b9be4d0c9b111bf001..82fdca5572984456403c76f565dc7a407195bcc0 100644 (file)
@@ -242,7 +242,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
       username: username_from_nickname(user.nickname),
       acct: user.nickname,
       display_name: display_name,
-      locked: user.locked,
+      locked: user.is_locked,
       created_at: Utils.to_masto_date(user.inserted_at),
       followers_count: followers_count,
       following_count: following_count,
@@ -261,7 +261,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
         sensitive: false,
         fields: user.raw_fields,
         pleroma: %{
-          discoverable: user.discoverable,
+          discoverable: user.is_discoverable,
           actor_type: user.actor_type
         }
       },
index a1dcb6e15145ea0da013a139a8723a6bb580c51a..900c2434de216363fb9243a91a654d9f7619983d 100644 (file)
@@ -10,7 +10,7 @@ defmodule Pleroma.Web.Metadata.Providers.RestrictIndexing do
   """
 
   @impl true
-  def build_tags(%{user: %{local: true, discoverable: true}}), do: []
+  def build_tags(%{user: %{local: true, is_discoverable: true}}), do: []
 
   def build_tags(_) do
     [
index 61f4a9bd9279abbe173b8c70a60f686d1af472ea..30cf835678ca592fe8d04bd723a80fbcff26ebec 100644 (file)
@@ -17,6 +17,11 @@ defmodule Pleroma.Web.PleromaAPI.AccountController do
 
   require Pleroma.Constants
 
+  plug(
+    Majic.Plug,
+    [pool: Pleroma.MajicPool] when action in [:update_avatar, :update_background, :update_banner]
+  )
+
   plug(
     OpenApiSpex.Plug.PutApiSpec,
     [module: Pleroma.Web.ApiSpec] when action == :confirmation_resend
index 0f6f0b9dbc6818f1efda0a2055275468fce09f1d..15210f1e65d4f4373d28876872eb8adf40bcb6b0 100644 (file)
@@ -9,6 +9,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotController do
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.Plugs.OAuthScopesPlug
 
+  plug(Majic.Plug, [pool: Pleroma.MajicPool] when action in [:update])
   plug(Pleroma.Web.ApiSpec.CastAndValidate)
   plug(OAuthScopesPlug, %{scopes: ["read:accounts"]} when action == :show)
   plug(OAuthScopesPlug, %{scopes: ["write:accounts"]} when action != :show)
@@ -22,14 +23,15 @@ defmodule Pleroma.Web.PleromaAPI.MascotController do
 
   @doc "PUT /api/v1/pleroma/mascot"
   def update(%{assigns: %{user: user}, body_params: %{file: file}} = conn, _) do
-    with {:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)),
-         # Reject if not an image
-         %{type: "image"} = attachment <- render_attachment(object) do
+    with {:content_type, "image" <> _} <- {:content_type, file.content_type},
+         {:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)) do
+      attachment = render_attachment(object)
       {:ok, _user} = User.mascot_update(user, attachment)
 
       json(conn, attachment)
     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
 
diff --git a/mix.exs b/mix.exs
index b9ce8c500641d64aef31510c7b18970dafc67da1..427329d38d2ab51b0ff44d4d0dabc85de8030bc2 100644 (file)
--- a/mix.exs
+++ b/mix.exs
@@ -188,6 +188,8 @@ defmodule Pleroma.Mixfile do
        git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
        ref: "e0f16822d578866e186a0974d65ad58cddc1e2ab"},
       {:restarter, path: "./restarter"},
+      {:majic,
+       git: "https://git.pleroma.social/pleroma/elixir-libraries/majic", branch: "develop"},
       {:open_api_spex,
        git: "https://git.pleroma.social/pleroma/elixir-libraries/open_api_spex.git",
        ref: "f296ac0924ba3cf79c7a588c4c252889df4c2edd"},
index 2603f70c0ec7605670126195e61668868c8ba97e..1f28854405ac407bf651efedfb3f362e45ffa47e 100644 (file)
--- a/mix.lock
+++ b/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_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"},
-  "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"},
   "eternal": {:hex, :eternal, "1.2.1", "d5b6b2499ba876c57be2581b5b999ee9bdf861c647401066d3eeed111d096bc4", [:mix], [], "hexpm", "b14f1dc204321429479c569cfbe8fb287541184ed040956c8862cb7a677b8406"},
   "ex2ms": {:hex, :ex2ms, "1.5.0", "19e27f9212be9a96093fed8cdfbef0a2b56c21237196d26760f11dfcfae58e97", [:mix], [], "hexpm"},
@@ -65,6 +65,7 @@
   "jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},
   "libring": {:hex, :libring, "1.4.0", "41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6", [:mix], [], "hexpm"},
   "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_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"},
diff --git a/priv/repo/migrations/20201013141127_refactor_locked_user_field.exs b/priv/repo/migrations/20201013141127_refactor_locked_user_field.exs
new file mode 100644 (file)
index 0000000..6cd23db
--- /dev/null
@@ -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
diff --git a/priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs b/priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs
new file mode 100644 (file)
index 0000000..3fdc190
--- /dev/null
@@ -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.RefactorDiscoverableUserField do
+  use Ecto.Migration
+
+  def up do
+    execute("ALTER TABLE users RENAME COLUMN discoverable TO is_discoverable;")
+  end
+
+  def down do
+    execute("ALTER TABLE users RENAME COLUMN is_discoverable TO discoverable;")
+  end
+end
index 8a02710ee2b336e7aed49b167de6217c711c6500..fe69a2def027b752dd0f44c9394c647658fac8bf 100644 (file)
@@ -5,6 +5,8 @@
 defmodule Mix.Tasks.Pleroma.InstanceTest do
   use ExUnit.Case
 
+  @release_env_file "./test/pleroma.test.env"
+
   setup do
     File.mkdir_p!(tmp_path())
 
@@ -16,6 +18,8 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
         File.rm_rf(Path.join(static_dir, "robots.txt"))
       end
 
+      if File.exists?(@release_env_file), do: File.rm_rf(@release_env_file)
+
       Pleroma.Config.put([:instance, :static_dir], static_dir)
     end)
 
@@ -69,7 +73,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
         "--dedupe-uploads",
         "n",
         "--anonymize-uploads",
-        "n"
+        "n",
+        "--release-env-file",
+        @release_env_file
       ])
     end
 
@@ -91,6 +97,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
     assert generated_config =~ "filters: [Pleroma.Upload.Filter.ExifTool]"
     assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
     assert File.exists?(Path.expand("./test/instance/static/robots.txt"))
+    assert File.exists?(@release_env_file)
+
+    assert File.read!(@release_env_file) =~ ~r/^RELEASE_COOKIE=.*/
   end
 
   defp generated_setup_psql do
diff --git a/test/mix/tasks/pleroma/release_env_test.exs b/test/mix/tasks/pleroma/release_env_test.exs
new file mode 100644 (file)
index 0000000..519f1eb
--- /dev/null
@@ -0,0 +1,30 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Mix.Tasks.Pleroma.ReleaseEnvTest do
+  use ExUnit.Case
+  import ExUnit.CaptureIO, only: [capture_io: 1]
+
+  @path "config/pleroma.test.env"
+
+  def do_clean do
+    if File.exists?(@path) do
+      File.rm_rf(@path)
+    end
+  end
+
+  setup do
+    do_clean()
+    on_exit(fn -> do_clean() end)
+    :ok
+  end
+
+  test "generate pleroma.env" do
+    assert capture_io(fn ->
+             Mix.Tasks.Pleroma.ReleaseEnv.run(["gen", "--path", @path, "--force"])
+           end) =~ "The file generated"
+
+    assert File.read!(@path) =~ "RELEASE_COOKIE="
+  end
+end
index b8c423c48455590765345bbc15faac0d68c441f7..ce819f815064affd5b8570a08ddcd0cec56e5922 100644 (file)
@@ -248,14 +248,19 @@ defmodule Mix.Tasks.Pleroma.UserTest do
 
       user = User.get_cached_by_nickname(user.nickname)
       assert user.is_moderator
-      assert user.locked
+      assert user.is_locked
       assert user.is_admin
       refute user.confirmation_pending
     end
 
     test "All statuses unset" do
       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([
         "set",
@@ -280,7 +285,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
 
       user = User.get_cached_by_nickname(user.nickname)
       refute user.is_moderator
-      refute user.locked
+      refute user.is_locked
       refute user.is_admin
       assert user.confirmation_pending
     end
index f2e0f0b0d8ccfa26ae7b6cc5c3f4cc33893e07c1..0e9630f28518297f7a9be155d169a007debd0362 100644 (file)
@@ -346,7 +346,7 @@ defmodule Pleroma.NotificationTest do
   describe "follow / follow_request notifications" do
     test "it creates `follow` notification for approved Follow activity" do
       user = insert(:user)
-      followed_user = insert(:user, locked: false)
+      followed_user = insert(:user, is_locked: false)
 
       {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
       assert FollowingRelationship.following?(user, followed_user)
@@ -361,7 +361,7 @@ defmodule Pleroma.NotificationTest do
 
     test "it creates `follow_request` notification for pending Follow activity" do
       user = insert(:user)
-      followed_user = insert(:user, locked: true)
+      followed_user = insert(:user, is_locked: true)
 
       {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
       refute FollowingRelationship.following?(user, followed_user)
@@ -383,7 +383,7 @@ defmodule Pleroma.NotificationTest do
 
     test "it doesn't create a notification for follow-unfollow-follow chains" do
       user = insert(:user)
-      followed_user = insert(:user, locked: false)
+      followed_user = insert(:user, is_locked: false)
 
       {:ok, _, _, _activity} = CommonAPI.follow(user, followed_user)
       assert FollowingRelationship.following?(user, followed_user)
@@ -397,7 +397,7 @@ defmodule Pleroma.NotificationTest do
     end
 
     test "dismisses the notification on follow request rejection" do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
       follower = insert(:user)
       {:ok, _, _, _follow_activity} = CommonAPI.follow(follower, user)
       assert [notification] = Notification.for_user(user)
index 198d3b1cf1ac969016e0ca5effc2f0000ee9210b..99caba3369ef289d979c46bb22fe77c7b7e88adb 100644 (file)
@@ -82,7 +82,7 @@ defmodule Pleroma.ObjectTest do
       Pleroma.Config.put([:instance, :cleanup_attachments], false)
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -116,7 +116,7 @@ defmodule Pleroma.ObjectTest do
       Pleroma.Config.put([:instance, :cleanup_attachments], true)
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -155,7 +155,7 @@ defmodule Pleroma.ObjectTest do
       File.mkdir_p!(uploads_dir)
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -188,7 +188,7 @@ defmodule Pleroma.ObjectTest do
       Pleroma.Config.put([:instance, :cleanup_attachments], true)
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -225,7 +225,7 @@ defmodule Pleroma.ObjectTest do
       Pleroma.Config.put([:instance, :cleanup_attachments], true)
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
index 19b915cc80dc0bca750203fe08e9dbb19effc8b7..7ef01ce9106ec7f010dc9eec6c4784e656d6e90b 100644 (file)
@@ -13,7 +13,7 @@ defmodule Pleroma.Upload.Filter.AnonymizeFilenameTest do
 
     upload_file = %Upload{
       name: "an… image.jpg",
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/image_tmp.jpg")
     }
 
index 75c7198e1bf3e8970f56e5dc929535a1e5971b89..92a3d7df32e8175cff045d46f876a67d09673749 100644 (file)
@@ -18,7 +18,7 @@ defmodule Pleroma.Upload.Filter.DedupeTest do
 
     upload = %Upload{
       name: "an… image.jpg",
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/image_tmp.jpg"),
       tempfile: Path.absname("test/fixtures/image_tmp.jpg")
     }
index d4cd4ba1145eb2e50f996bb41d60196972522159..6b978b64cbf69a8a8d4941cc62c276d31ba1b4d0 100644 (file)
@@ -16,7 +16,7 @@ defmodule Pleroma.Upload.Filter.ExiftoolTest do
 
     upload = %Pleroma.Upload{
       name: "image_with_GPS_data.jpg",
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/DSCN0010.jpg"),
       tempfile: Path.absname("test/fixtures/DSCN0010_tmp.jpg")
     }
index dc1e9e78f0f898983bf5886d837db25e96a5cdbf..fc2f6827611795ba41c12cb69da9ec9f2f8878b1 100644 (file)
@@ -17,7 +17,7 @@ defmodule Pleroma.Upload.Filter.MogrifunTest do
 
     upload = %Upload{
       name: "an… image.jpg",
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/image_tmp.jpg"),
       tempfile: Path.absname("test/fixtures/image_tmp.jpg")
     }
index bf64b96b365697df9e6544867da50f33345eed9f..6dee02e8bd15f312c5555d8d35fa5f6cff472df6 100644 (file)
@@ -18,7 +18,7 @@ defmodule Pleroma.Upload.Filter.MogrifyTest do
 
     upload = %Pleroma.Upload{
       name: "an… image.jpg",
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/image_tmp.jpg"),
       tempfile: Path.absname("test/fixtures/image_tmp.jpg")
     }
index 352b664024ed68e94a0f3477b3b37e04d55da685..09394929ca94551c0bc3e24558a9dfa0dd1a3ce5 100644 (file)
@@ -20,7 +20,7 @@ defmodule Pleroma.Upload.FilterTest do
 
     upload = %Pleroma.Upload{
       name: "an… image.jpg",
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/image_tmp.jpg"),
       tempfile: Path.absname("test/fixtures/image_tmp.jpg")
     }
index b06b54487e152dc397e3127930e481cefbaedace..f52d4dff6d4306aaaf71fa5618b533e1c109d6cf 100644 (file)
@@ -11,7 +11,7 @@ defmodule Pleroma.UploadTest do
   alias Pleroma.Uploaders.Uploader
 
   @upload_file %Plug.Upload{
-    content_type: "image/jpg",
+    content_type: "image/jpeg",
     path: Path.absname("test/fixtures/image_tmp.jpg"),
     filename: "image.jpg"
   }
@@ -112,7 +112,7 @@ defmodule Pleroma.UploadTest do
       File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image_tmp.jpg"),
         filename: "image.jpg"
       }
@@ -124,7 +124,7 @@ defmodule Pleroma.UploadTest do
       File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image_tmp.jpg"),
         filename: "image.jpg"
       }
@@ -140,7 +140,7 @@ defmodule Pleroma.UploadTest do
       File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image_tmp.jpg"),
         filename: "an [image.jpg"
       }
@@ -156,7 +156,7 @@ defmodule Pleroma.UploadTest do
       File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image_tmp.jpg"),
         filename: "an [image.jpg"
       }
@@ -165,63 +165,31 @@ defmodule Pleroma.UploadTest do
       assert data["name"] == "an [image.jpg"
     end
 
-    test "fixes incorrect content type" do
-      File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
-
-      file = %Plug.Upload{
-        content_type: "application/octet-stream",
-        path: Path.absname("test/fixtures/image_tmp.jpg"),
-        filename: "an [image.jpg"
+    test "fixes incorrect content type when base64 is given" do
+      params = %{
+        img: "data:image/png;base64,#{Base.encode64(File.read!("test/fixtures/image.jpg"))}"
       }
 
-      {:ok, data} = Upload.store(file, filters: [Pleroma.Upload.Filter.Dedupe])
+      {:ok, data} = Upload.store(params)
       assert hd(data["url"])["mediaType"] == "image/jpeg"
     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 = %Plug.Upload{
-        content_type: "image/jpg",
-        path: Path.absname("test/fixtures/image_tmp.jpg"),
-        filename: "an [image"
+      params = %{
+        img: "data:image/png;base64,#{Base.encode64(File.read!("test/fixtures/image.jpg"))}"
       }
 
-      {:ok, data} = Upload.store(file)
-      assert data["name"] == "an [image.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"
+      {:ok, data} = Upload.store(params)
+      assert String.ends_with?(data["name"], ".jpg")
     end
 
     test "copies the file to the configured folder with anonymizing filename" do
       File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image_tmp.jpg"),
         filename: "an [image.jpg"
       }
@@ -235,7 +203,7 @@ defmodule Pleroma.UploadTest do
       File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image_tmp.jpg"),
         filename: "an… image.jpg"
       }
@@ -250,7 +218,7 @@ defmodule Pleroma.UploadTest do
       File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image_tmp.jpg"),
         filename: ":?#[]@!$&\\'()*+,;=.jpg"
       }
@@ -272,7 +240,7 @@ defmodule Pleroma.UploadTest do
       File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image_tmp.jpg"),
         filename: "image.jpg"
       }
index 18122ff6c372c98c74230dcfb9790d0178bfd92e..1ce7be485607ef3ef723a4bf7fc90cdd3f408ed6 100644 (file)
@@ -19,7 +19,7 @@ defmodule Pleroma.Uploaders.LocalTest do
 
       file = %Pleroma.Upload{
         name: "image.jpg",
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: file_path,
         tempfile: Path.absname("test/fixtures/image_tmp.jpg")
       }
@@ -38,7 +38,7 @@ defmodule Pleroma.Uploaders.LocalTest do
 
       file = %Pleroma.Upload{
         name: "image.jpg",
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: file_path,
         tempfile: Path.absname("test/fixtures/image_tmp.jpg")
       }
index d949c90a5c2ce183fb0a8d869a4f4edee1891ca4..e7a013dd8e843311fd34447cdea762ac454be54a 100644 (file)
@@ -56,7 +56,7 @@ defmodule Pleroma.Uploaders.S3Test do
     setup do
       file_upload = %Pleroma.Upload{
         name: "image-tet.jpg",
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: "test_folder/image-tet.jpg",
         tempfile: Path.absname("test/instance_static/add/shortcode.png")
       }
index c4b8050055b04c167ed4e0afeacd65c1f40feb67..31d787ffa0ed35e2ef817c99956a2ee1d5241e7d 100644 (file)
@@ -66,7 +66,7 @@ defmodule Pleroma.UserSearchTest do
     end
 
     test "excludes users when discoverable is false" do
-      insert(:user, %{nickname: "john 3000", discoverable: false})
+      insert(:user, %{nickname: "john 3000", is_discoverable: false})
       insert(:user, %{nickname: "john 3001"})
 
       users = User.search("john")
index d506f704708a6c7f501bf51db735b8f5cd301b21..7220ce84636914abdadfe129184a0ae14b8854a5 100644 (file)
@@ -174,7 +174,7 @@ defmodule Pleroma.UserTest do
 
   test "returns all pending follow requests" do
     unlocked = insert(:user)
-    locked = insert(:user, locked: true)
+    locked = insert(:user, is_locked: true)
     follower = insert(:user)
 
     CommonAPI.follow(follower, unlocked)
@@ -187,7 +187,7 @@ defmodule Pleroma.UserTest do
   end
 
   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)
     accepted_follower = insert(:user)
 
@@ -201,7 +201,7 @@ defmodule Pleroma.UserTest do
   end
 
   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})
 
     CommonAPI.follow(pending_follower, locked)
@@ -211,7 +211,7 @@ defmodule Pleroma.UserTest do
   end
 
   test "clears follow requests when requester is blocked" do
-    followed = insert(:user, locked: true)
+    followed = insert(:user, is_locked: true)
     follower = insert(:user)
 
     CommonAPI.follow(follower, followed)
@@ -299,8 +299,8 @@ defmodule Pleroma.UserTest do
   end
 
   test "local users do not automatically follow local locked accounts" do
-    follower = insert(:user, locked: true)
-    followed = insert(:user, locked: true)
+    follower = insert(:user, is_locked: true)
+    followed = insert(:user, is_locked: true)
 
     {:ok, follower} = User.maybe_direct_follow(follower, followed)
 
@@ -1360,7 +1360,7 @@ defmodule Pleroma.UserTest do
       follower = insert(: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)
 
       object = insert(:note, user: user)
@@ -1450,7 +1450,7 @@ defmodule Pleroma.UserTest do
         note_count: 9,
         follower_count: 9,
         following_count: 9001,
-        locked: true,
+        is_locked: true,
         confirmation_pending: true,
         password_reset_pending: true,
         approval_pending: true,
@@ -1467,7 +1467,7 @@ defmodule Pleroma.UserTest do
         pleroma_settings_store: %{"q" => "x"},
         fields: [%{"gg" => "qq"}],
         raw_fields: [%{"gg" => "qq"}],
-        discoverable: true,
+        is_discoverable: true,
         also_known_as: ["https://lol.olo/users/loll"]
       })
 
@@ -1492,7 +1492,7 @@ defmodule Pleroma.UserTest do
              note_count: 0,
              follower_count: 0,
              following_count: 0,
-             locked: false,
+             is_locked: false,
              confirmation_pending: false,
              password_reset_pending: false,
              approval_pending: false,
@@ -1509,7 +1509,7 @@ defmodule Pleroma.UserTest do
              pleroma_settings_store: %{},
              fields: [],
              raw_fields: [],
-             discoverable: false,
+             is_discoverable: false,
              also_known_as: []
            } = user
   end
index 0517571f28f7cde9cbfa7bc36cb9fe274da313e9..b11e2f9619defd0fe2fd42f4af3aaa000a3f9613 100644 (file)
@@ -1487,9 +1487,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
       desc = "Description of the image"
 
       image = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "bad/content-type",
         path: Path.absname("test/fixtures/image.jpg"),
-        filename: "an_image.jpg"
+        filename: "an_image.png"
       }
 
       object =
@@ -1504,6 +1504,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
       assert [%{"href" => object_href, "mediaType" => object_mediatype}] = object["url"]
       assert is_binary(object_href)
       assert object_mediatype == "image/jpeg"
+      assert String.ends_with?(object_href, ".jpg")
 
       activity_request = %{
         "@context" => "https://www.w3.org/ns/activitystreams",
index 804305a1381321e35c4ae38dcc8d67febcecf5de..e6b6086e674aa3deb1cc6781bc795f13dd3110ec 100644 (file)
@@ -752,6 +752,22 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
     refute repeat_activity in activities
   end
 
+  test "returns your own posts regardless of mute" do
+    user = insert(:user)
+    muted = insert(:user)
+
+    {:ok, muted_post} = CommonAPI.post(muted, %{status: "Im stupid"})
+
+    {:ok, reply} =
+      CommonAPI.post(user, %{status: "I'm muting you", in_reply_to_status_id: muted_post.id})
+
+    {:ok, _} = User.mute(user, muted)
+
+    [activity] = ActivityPub.fetch_activities([], %{muting_user: user, skip_preload: true})
+
+    assert activity.id == reply.id
+  end
+
   test "doesn't return muted activities" do
     activity_one = insert(:note_activity)
     activity_two = insert(:note_activity)
@@ -1029,7 +1045,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
   describe "uploading files" do
     setup do
       test_file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -1120,7 +1136,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
 
     test "creates an undo activity for a pending follow request" do
       follower = insert(:user)
-      followed = insert(:user, %{locked: true})
+      followed = insert(:user, %{is_locked: true})
 
       {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
       {:ok, activity} = ActivityPub.unfollow(follower, followed)
index 558bb3131c048af523c298f47e7529dc48a5a0d4..760388e802434261813b56319b864552686be23d 100644 (file)
@@ -56,7 +56,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidatorTest do
       user = insert(:user)
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
index 16e4808e59708e415dba4ec59ffe8807befdae1b..d7e29922443163b0e5c4d1031e302f4e4f49c26a 100644 (file)
@@ -77,7 +77,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
       user: user
     } do
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -98,7 +98,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
       user: user
     } do
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -119,7 +119,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
       user: user
     } do
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
index 77d468f5c98351b00a58ebc4dc9f8532d7aa8d12..c6ff96f08926b507e5377171005b28d7f0ba325e 100644 (file)
@@ -46,7 +46,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
 
   test "it works for incoming accepts which are referenced by IRI only" do
     follower = insert(:user)
-    followed = insert(:user, locked: true)
+    followed = insert(:user, is_locked: true)
 
     {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
 
@@ -72,7 +72,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
 
   test "it fails for incoming accepts which cannot be correlated" do
     follower = insert(:user)
-    followed = insert(:user, locked: true)
+    followed = insert(:user, is_locked: true)
 
     accept_data =
       File.read!("test/fixtures/mastodon-accept-activity.json")
index 757d90941f85fd93c16d9af7696774cb63f70916..4ef8210ad8a946a5724fcb08328ccaf7c021aef3 100644 (file)
@@ -65,7 +65,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
     end
 
     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 =
         File.read!("test/fixtures/mastodon-follow-activity.json")
@@ -188,7 +188,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
 
     test "it works for incoming follows to locked account" do
       pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
 
       data =
         File.read!("test/fixtures/mastodon-follow-activity.json")
index 7592fbe1c6c23126e7fddb6fca76f34d2e1648dd..5c1451defa070129aa7a7f05f035455bbf606275 100644 (file)
@@ -14,7 +14,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
 
   test "it fails for incoming rejects which cannot be correlated" do
     follower = insert(:user)
-    followed = insert(:user, locked: true)
+    followed = insert(:user, is_locked: true)
 
     accept_data =
       File.read!("test/fixtures/mastodon-reject-activity.json")
@@ -33,7 +33,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
 
   test "it works for incoming rejects which are referenced by IRI only" do
     follower = insert(:user)
-    followed = insert(:user, locked: true)
+    followed = insert(:user, is_locked: true)
 
     {:ok, follower} = User.follow(follower, followed)
     {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
index 64636656cab11a0ffe6610a7478ed47e427c6d92..7c4d16db723cc0f7c2537a99a28ea8c773ee2951 100644 (file)
@@ -154,6 +154,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UserUpdateHandlingTest do
     {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(update_data)
 
     user = User.get_cached_by_ap_id(user.ap_id)
-    assert user.locked == true
+    assert user.is_locked == true
   end
 end
index d5021354595756eeb7d4f20b546db953d622857a..be9cd7d13eb45f6f5a3bd0326a9f7f9be2b4b512 100644 (file)
@@ -193,7 +193,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
 
   describe "update_follow_state_for_all/2" 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)
 
       {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
@@ -217,7 +217,7 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
 
   describe "update_follow_state/2" 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)
 
       {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user)
index d88867c5272e0242b0978d809999dcc6c2df191d..ceec64f1e73ec81c78015f5bbe41d5d38ffd90a3 100644 (file)
@@ -180,7 +180,7 @@ defmodule Pleroma.Web.AdminAPI.SearchTest do
 
     test "it returns non-discoverable users" do
       insert(:user)
-      insert(:user, discoverable: false)
+      insert(:user, is_discoverable: false)
 
       {:ok, _results, total} = Search.user()
 
index e34f5a49b39b8ae7f29ba6c03ac66cb503497b80..f5d09f39657eabd614de0491b3a665a445a7df3f 100644 (file)
@@ -100,7 +100,7 @@ defmodule Pleroma.Web.CommonAPITest do
       recipient = insert(:user)
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -1071,7 +1071,7 @@ defmodule Pleroma.Web.CommonAPITest do
 
     test "cancels a pending follow for a local user" do
       follower = insert(:user)
-      followed = insert(:user, locked: true)
+      followed = insert(:user, is_locked: true)
 
       assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
                CommonAPI.follow(follower, followed)
@@ -1093,7 +1093,7 @@ defmodule Pleroma.Web.CommonAPITest do
 
     test "cancels a pending follow for a remote user" do
       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"}}} =
                CommonAPI.follow(follower, followed)
@@ -1116,7 +1116,7 @@ defmodule Pleroma.Web.CommonAPITest do
 
   describe "accept_follow_request/2" 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_two = insert(:user)
 
@@ -1136,7 +1136,7 @@ defmodule Pleroma.Web.CommonAPITest do
     end
 
     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_two = insert(:user)
 
@@ -1156,7 +1156,7 @@ defmodule Pleroma.Web.CommonAPITest do
     end
 
     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)
       CommonAPI.accept_follow_request(not_follower, user)
 
index 69f2b6f4a063ff7a64dd6a9da8aac04bcb14cfa3..c86223b264fbce22456af83add7ad973360053c3 100644 (file)
@@ -380,7 +380,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
       other_user = insert(:user)
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -706,7 +706,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
     end
 
     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} =
                conn
index 6749e0e83a480dcf843b2348735cc2b3bc9e6a4c..a9dd7cd30aaeee4e516223909b127d9be9112aa3 100644 (file)
@@ -12,7 +12,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
 
   describe "locked accounts" do
     setup do
-      user = insert(:user, locked: true)
+      user = insert(:user, is_locked: true)
       %{conn: conn} = oauth_access(["follow"], user: user)
       %{user: user, conn: conn}
     end
index 906fd940f7c1c6ad09f8359d58c8ad915278d391..d2bd57515bb84e08e53939e7a7d5bbd1e589d373 100644 (file)
@@ -14,7 +14,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
 
     setup do
       image = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -74,7 +74,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
 
     setup %{user: actor} do
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -106,7 +106,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
 
     setup %{user: actor} do
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
index 633a25e506b1ee3cdf779bcf81d8423956966424..61359214a1085001d9dc4152c1e78d0208aab6ae 100644 (file)
@@ -167,7 +167,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
 
     test "posting an undefined status with an attachment", %{user: user, conn: conn} do
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -408,7 +408,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
         |> Kernel.<>("Z")
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
index fe462caa38c07739e182c264093c2ab774280c51..ed1921c9145d2b503b6a1c7160bdab4cbba89961 100644 (file)
@@ -222,7 +222,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
 
     test "updates the user's avatar", %{user: user, conn: conn} do
       new_avatar = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -246,7 +246,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
 
     test "updates the user's banner", %{user: user, conn: conn} do
       new_header = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
@@ -265,7 +265,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
 
     test "updates the user's background", %{conn: conn, user: user} do
       new_header = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
index a5f39b215dd6e5ad92ba2962b49506ed21abaa60..203e61c716a74fa38512cca633c32219f3d70e94 100644 (file)
@@ -332,7 +332,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
 
     test "represent a relationship for the user with a pending follow request" do
       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)
       user = User.get_cached_by_id(user.id)
@@ -481,7 +481,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
     end
 
     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})
 
@@ -493,7 +493,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
     end
 
     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})
 
@@ -510,7 +510,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
     end
 
     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})
 
@@ -527,14 +527,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
     end
 
     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})
 
       other_user = insert(: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} =
                AccountView.render("show.json", %{user: user, for: user})
index fbfd873effc817ef0dca6ff9173e5b3a1cb41349..04f73f5a015aff6e56d6f37a63225786cd4cef38 100644 (file)
@@ -22,7 +22,7 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityViewTest do
       |> NaiveDateTime.to_iso8601()
 
     file = %Plug.Upload{
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/image.jpg"),
       filename: "an_image.jpg"
     }
index 6b3a653724dcca51d29815b560a1afcc7388b1eb..282d132c8104a672f52087fb52316d24c91de170 100644 (file)
@@ -14,13 +14,13 @@ defmodule Pleroma.Web.Metadata.Providers.RestrictIndexingTest do
 
     test "for local user" do
       assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{
-               user: %Pleroma.User{local: true, discoverable: true}
+               user: %Pleroma.User{local: true, is_discoverable: true}
              }) == []
     end
 
     test "for local user when discoverable is false" do
       assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{
-               user: %Pleroma.User{local: true, discoverable: false}
+               user: %Pleroma.User{local: true, is_discoverable: false}
              }) == [{:meta, [name: "robots", content: "noindex, noarchive"], []}]
     end
   end
index ca6cbe67faa875c7cf69da661884d4808cdd90b4..8fb946540d92a8774e9abe14fcd43255350e3e1f 100644 (file)
@@ -16,14 +16,14 @@ defmodule Pleroma.Web.MetadataTest do
     end
 
     test "for local user" do
-      user = insert(:user, discoverable: false)
+      user = insert(:user, is_discoverable: false)
 
       assert Pleroma.Web.Metadata.build_tags(%{user: user}) =~
                "<meta content=\"noindex, noarchive\" name=\"robots\">"
     end
 
     test "for local user set to discoverable" do
-      user = insert(:user, discoverable: true)
+      user = insert(:user, is_discoverable: true)
 
       refute Pleroma.Web.Metadata.build_tags(%{user: user}) =~
                "<meta content=\"noindex, noarchive\" name=\"robots\">"
@@ -33,14 +33,14 @@ defmodule Pleroma.Web.MetadataTest do
   describe "no metadata for private instances" do
     test "for local user set to discoverable" do
       clear_config([:instance, :public], false)
-      user = insert(:user, bio: "This is my secret fedi account bio", discoverable: true)
+      user = insert(:user, bio: "This is my secret fedi account bio", is_discoverable: true)
 
       assert "" = Pleroma.Web.Metadata.build_tags(%{user: user})
     end
 
     test "search exclusion metadata is included" do
       clear_config([:instance, :public], false)
-      user = insert(:user, bio: "This is my secret fedi account bio", discoverable: false)
+      user = insert(:user, bio: "This is my secret fedi account bio", is_discoverable: false)
 
       assert ~s(<meta content="noindex, noarchive" name="robots">) ==
                Pleroma.Web.Metadata.build_tags(%{user: user})
index 11d5ba3739def5970ba9875dcd7658ac9b1ba3bf..6381f9757e5f33ff429d51aa7dc8e38754f0c1a9 100644 (file)
@@ -105,7 +105,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
 
     test "it works with an attachment", %{conn: conn, user: user} do
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
index e2ead6e154e85c77b215e069984f67a62c2d75e1..d6be92869a85f2e1f268e9793edbb809dbe494be 100644 (file)
@@ -24,7 +24,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
     assert json_response_and_validate_schema(ret_conn, 415)
 
     file = %Plug.Upload{
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/image.jpg"),
       filename: "an_image.jpg"
     }
@@ -48,7 +48,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
 
     # When a user sets their mascot, we should get that back
     file = %Plug.Upload{
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/image.jpg"),
       filename: "an_image.jpg"
     }
index 26272c12513ffefeb363b0b8725fc631ef220971..f171a1e55be4e5df38376e5703c85637c87a687c 100644 (file)
@@ -19,7 +19,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
     recipient = insert(:user)
 
     file = %Plug.Upload{
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/image.jpg"),
       filename: "an_image.jpg"
     }
index 07f52c8cd0b3195aa4a9e645fb2b4dc9411ee0da..7c83131212dda896e286c7f8be4259ce47fdd893 100644 (file)
@@ -11,7 +11,7 @@ defmodule Pleroma.Web.Plugs.UploadedMediaPlugTest do
     File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
 
     file = %Plug.Upload{
-      content_type: "image/jpg",
+      content_type: "image/jpeg",
       path: Path.absname("test/fixtures/image_tmp.jpg"),
       filename: "nice_tf.jpg"
     }
index 6cab46696dede96a40a9a4a618f0834ec3892968..7d8cc999a9035faff4fb93977763650778a1cec8 100644 (file)
@@ -219,7 +219,7 @@ defmodule Pleroma.Web.Push.ImplTest do
       recipient = insert(:user)
 
       file = %Plug.Upload{
-        content_type: "image/jpg",
+        content_type: "image/jpeg",
         path: Path.absname("test/fixtures/image.jpg"),
         filename: "an_image.jpg"
       }
index fb82be0c4d4908b2cb32471a110d8ce9927a61a9..80b882ee413d5b4a6de7f7dcf3723428eacac4ec 100644 (file)
@@ -31,7 +31,7 @@ defmodule Pleroma.Factory do
       nickname: sequence(:nickname, &"nick#{&1}"),
       password_hash: Pbkdf2.hash_pwd_salt("test"),
       bio: sequence(:bio, &"Tester Number #{&1}"),
-      discoverable: true,
+      is_discoverable: true,
       last_digest_emailed_at: NaiveDateTime.utc_now(),
       last_refreshed_at: NaiveDateTime.utc_now(),
       notification_settings: %Pleroma.User.NotificationSetting{},