summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md40
-rw-r--r--config/config.exs8
-rw-r--r--config/description.exs14
-rw-r--r--docs/administration/CLI_tasks/email.md7
-rw-r--r--docs/administration/CLI_tasks/user.md4
-rwxr-xr-xinstallation/download-mastofe-build.sh21
-rw-r--r--lib/mix/pleroma.ex16
-rw-r--r--lib/mix/tasks/pleroma/database.ex12
-rw-r--r--lib/mix/tasks/pleroma/user.ex4
-rw-r--r--lib/pleroma/emails/user_email.ex17
-rw-r--r--lib/pleroma/user.ex79
-rw-r--r--lib/pleroma/web/admin_api/controllers/admin_api_controller.ex2
-rw-r--r--lib/pleroma/web/feed/feed_view.ex2
-rw-r--r--lib/pleroma/web/templates/email/digest.html.eex2
-rw-r--r--lib/pleroma/web/twitter_api/controller.ex5
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api.ex13
-rw-r--r--lib/pleroma/web/web_finger.ex3
-rw-r--r--mix.exs4
-rw-r--r--mix.lock4
-rw-r--r--priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs13
-rw-r--r--priv/static/images/logo.pngbin0 -> 1304 bytes
-rw-r--r--priv/templates/sample_config.eex3
-rw-r--r--test/mix/tasks/pleroma/database_test.exs3
-rw-r--r--test/mix/tasks/pleroma/user_test.exs14
-rw-r--r--test/pleroma/emails/user_email_test.exs11
-rw-r--r--test/pleroma/user_test.exs126
-rw-r--r--test/pleroma/web/feed/tag_controller_test.exs2
-rw-r--r--test/pleroma/web/preload/providers/instance_test.exs2
-rw-r--r--test/pleroma/web/twitter_api/twitter_api_test.exs21
-rw-r--r--test/pleroma/web/web_finger_test.exs3
-rw-r--r--test/pleroma/workers/cron/new_users_digest_worker_test.exs2
31 files changed, 324 insertions, 133 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 07d0c63c1..e1604ab3a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Polls now always return a `voters_count`, even if they are single-choice.
- Admin Emails: The ap id is used as the user link in emails now.
+- Improved registration workflow for email confirmation and account approval modes.
+- **Breaking:** Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
- Search: When using Postgres 11+, Pleroma will use the `websearch_to_tsvector` function to parse search queries.
- Emoji: Support the full Unicode 13.1 set of Emoji for reactions, plus regional indicators.
@@ -17,14 +19,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Reports now generate notifications for admins and mods.
- Experimental websocket-based federation between Pleroma instances.
-- Support for local-only statuses
+- Support for local-only statuses.
- Support pagination of blocks and mutes.
- Account backup.
- Configuration: Add `:instance, autofollowing_nicknames` setting to provide a way to make accounts automatically follow new users that register on the local Pleroma instance.
- Ability to view remote timelines, with ex. `/api/v1/timelines/public?instance=lain.com` and streams `public:remote` and `public:remote:media`.
- The site title is now injected as a `title` tag like preloads or metadata.
- Password reset tokens now are not accepted after a certain age.
-- Mix tasks to help with displaying and removing ConfigDB entries. See `mix pleroma.config`
+- Mix tasks to help with displaying and removing ConfigDB entries. See `mix pleroma.config`.
- OAuth form improvements: users are remembered by their cookie, the CSS is overridable by the admin, and the style has been improved.
- OAuth improvements and fixes: more secure session-based authentication (by token that could be revoked anytime), ability to revoke belonging OAuth token from any client etc.
@@ -34,13 +36,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Pleroma API: Add `idempotency_key` to the chat message entity that can be used for optimistic message sending.
- Pleroma API: (`GET /api/v1/pleroma/federation_status`) Add a way to get a list of unreachable instances.
- Mastodon API: User and conversation mutes can now auto-expire if `expires_in` parameter was given while adding the mute.
-- Admin API: An endpoint to manage frontends
-- Streaming API: Add follow relationships updates
+- Admin API: An endpoint to manage frontends.
+- Streaming API: Add follow relationships updates.
</details>
### Fixed
- Users with `is_discoverable` field set to false (default value) will appear in in-service search results but be hidden from external services (search bots etc.).
+- Streaming API: Posts and notifications are not dropped, when CLI task is executing.
+- Creating incorrect IPv4 address-style HTTP links when encountering certain numbers.
<details>
<summary>API Changes</summary>
@@ -50,24 +54,34 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased (Patch)
+### Fixed
+
+- Fix ability to update Pleroma Chat push notifications with PUT /api/v1/push/subscription and alert type pleroma:chat_mention
+- Emoji Reaction activity filtering from blocked and muted accounts.
+
+## [2.2.1] - 2020-12-22
+
### Changed
+- Updated Pleroma FE
### Fixed
- Config generation: rename `Pleroma.Upload.Filter.ExifTool` to `Pleroma.Upload.Filter.Exiftool`.
-- Search: RUM index search speed has been fixed.
- S3 Uploads with Elixir 1.11.
-- Emoji Reaction activity filtering from blocked and muted accounts.
- Mix task pleroma.user delete_activities for source installations.
-- Fix ability to update Pleroma Chat push notifications with PUT /api/v1/push/subscription and alert type pleroma:chat_mention
-- Forwarded reports duplication from Pleroma instances.
+- Search: RUM index search speed has been fixed.
- Rich Media Previews sometimes showed the wrong preview due to a bug following redirects.
+- Fixes for the autolinker.
+- Forwarded reports duplication from Pleroma instances.
-<details>
- <summary>API</summary>
-- Statuses were not displayed for Mastodon forwarded reports.
+- <details>
+ <summary>API</summary>
+ - Statuses were not displayed for Mastodon forwarded reports.
+ </details>
-</details>
+### Upgrade notes
+
+1. Restart Pleroma
## [2.2.0] - 2020-11-12
@@ -105,7 +119,7 @@ switched to a new configuration mechanism, however it was not officially removed
- Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details).
- 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 for sending confirmation emails to all unconfirmed users (`mix pleroma.email resend_confirmation_emails`)
- Mix task option for force-unfollowing relays
- App metrics: ability to restrict access to specified IP whitelist.
diff --git a/config/config.exs b/config/config.exs
index 77a1e606e..d6d116314 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -305,7 +305,7 @@ config :pleroma, :frontend_configurations,
hideSitename: false,
hideUserStats: false,
loginMethod: "password",
- logo: "/static/logo.png",
+ logo: "/static/logo.svg",
logoMargin: ".1em",
logoMask: true,
minimalScopesMode: false,
@@ -342,8 +342,8 @@ config :pleroma, :assets,
config :pleroma, :manifest,
icons: [
%{
- src: "/static/logo.png",
- type: "image/png"
+ src: "/static/logo.svg",
+ type: "image/svg+xml"
}
],
theme_color: "#282c37",
@@ -647,7 +647,7 @@ config :pleroma, :email_notifications,
}
config :pleroma, :oauth2,
- token_expires_in: 3600 * 24 * 30,
+ token_expires_in: 3600 * 24 * 365 * 100,
issue_new_refresh_token: true,
clean_expired_tokens: false
diff --git a/config/description.exs b/config/description.exs
index f4b8768da..cf004f0cf 100644
--- a/config/description.exs
+++ b/config/description.exs
@@ -1254,7 +1254,7 @@ config :pleroma, :config_description, [
hideSitename: false,
hideUserStats: false,
loginMethod: "password",
- logo: "/static/logo.png",
+ logo: "/static/logo.svg",
logoMargin: ".1em",
logoMask: true,
minimalScopesMode: false,
@@ -1340,7 +1340,7 @@ config :pleroma, :config_description, [
key: :logo,
type: {:string, :image},
description: "URL of the logo, defaults to Pleroma's logo",
- suggestions: ["/static/logo.png"]
+ suggestions: ["/static/logo.svg"]
},
%{
key: :logoMargin,
@@ -1953,14 +1953,8 @@ config :pleroma, :config_description, [
group: :pleroma,
key: Oban,
type: :group,
- description: """
- [Oban](https://github.com/sorentwo/oban) asynchronous job processor configuration.
-
- Note: if you are running PostgreSQL in [`silent_mode`](https://postgresqlco.nf/en/doc/param/silent_mode?version=9.1),
- it's advised to set [`log_destination`](https://postgresqlco.nf/en/doc/param/log_destination?version=9.1) to `syslog`,
- otherwise `postmaster.log` file may grow because of "you don't own a lock of type ShareLock" warnings
- (see https://github.com/sorentwo/oban/issues/52).
- """,
+ description:
+ "[Oban](https://github.com/sorentwo/oban) asynchronous job processor configuration.",
children: [
%{
key: :log,
diff --git a/docs/administration/CLI_tasks/email.md b/docs/administration/CLI_tasks/email.md
index d9aa0e71b..2bb57bea4 100644
--- a/docs/administration/CLI_tasks/email.md
+++ b/docs/administration/CLI_tasks/email.md
@@ -16,8 +16,7 @@
mix pleroma.email test [--to <destination email address>]
```
-
-Example:
+Example:
=== "OTP"
@@ -36,11 +35,11 @@ Example:
=== "OTP"
```sh
- ./bin/pleroma_ctl email send_confirmation_mails
+ ./bin/pleroma_ctl email resend_confirmation_emails
```
=== "From Source"
```sh
- mix pleroma.email send_confirmation_mails
+ mix pleroma.email resend_confirmation_emails
```
diff --git a/docs/administration/CLI_tasks/user.md b/docs/administration/CLI_tasks/user.md
index c64ed4f22..b57dce0e7 100644
--- a/docs/administration/CLI_tasks/user.md
+++ b/docs/administration/CLI_tasks/user.md
@@ -264,13 +264,13 @@
=== "OTP"
```sh
- ./bin/pleroma_ctl user toggle_confirmed <nickname>
+ ./bin/pleroma_ctl user confirm <nickname>
```
=== "From Source"
```sh
- mix pleroma.user toggle_confirmed <nickname>
+ mix pleroma.user confirm <nickname>
```
## Set confirmation status for all regular active users
diff --git a/installation/download-mastofe-build.sh b/installation/download-mastofe-build.sh
index ee9e1c217..b8a021ef3 100755
--- a/installation/download-mastofe-build.sh
+++ b/installation/download-mastofe-build.sh
@@ -9,29 +9,32 @@ static_dir="instance/static"
# project_branch="pleroma"
# static_dir="priv/static"
-if [[ ! -d "${static_dir}" ]]
+if [ ! -d "${static_dir}" ]
then
echo "Error: ${static_dir} directory is missing, are you sure you are running this script at the root of pleroma’s repository?"
exit 1
fi
-last_modified="$(curl -s -I 'https://git.pleroma.social/api/v4/projects/'${project_id}'/jobs/artifacts/'${project_branch}'/download?job=build' | grep '^Last-Modified:' | cut -d: -f2-)"
+last_modified="$(curl --fail -s -I 'https://git.pleroma.social/api/v4/projects/'${project_id}'/jobs/artifacts/'${project_branch}'/download?job=build' | grep '^Last-Modified:' | cut -d: -f2-)"
echo "branch:${project_branch}"
echo "Last-Modified:${last_modified}"
artifact="mastofe.zip"
-if [[ -e mastofe.timestamp ]] && [[ "${last_modified}" != "" ]]
+if [ "${last_modified}x" = "x" ]
then
- if [[ "$(cat mastofe.timestamp)" == "${last_modified}" ]]
- then
- echo "MastoFE is up-to-date, exiting…"
- exit 0
- fi
+ echo "ERROR: Couldn't get the modification date of the latest build archive, maybe it expired, exiting..."
+ exit 1
+fi
+
+if [ -e mastofe.timestamp ] && [ "$(cat mastofe.timestamp)" = "${last_modified}" ]
+then
+ echo "MastoFE is up-to-date, exiting..."
+ exit 0
fi
-curl -c - "https://git.pleroma.social/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=build" -o "${artifact}" || exit
+curl --fail -c - "https://git.pleroma.social/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=build" -o "${artifact}" || exit
# TODO: Update the emoji as well
rm -fr "${static_dir}/sw.js" "${static_dir}/packs" || exit
diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex
index 7575f0ef8..a33a9951c 100644
--- a/lib/mix/pleroma.ex
+++ b/lib/mix/pleroma.ex
@@ -12,7 +12,8 @@ defmodule Mix.Pleroma do
:cachex,
:flake_id,
:swoosh,
- :timex
+ :timex,
+ :fast_html
]
@cachex_children ["object", "user", "scrubber", "web_resp"]
@doc "Common functions to be reused in mix tasks"
@@ -37,12 +38,23 @@ defmodule Mix.Pleroma do
Enum.each(apps, &Application.ensure_all_started/1)
+ oban_config = [
+ crontab: [],
+ repo: Pleroma.Repo,
+ log: false,
+ queues: [],
+ plugins: []
+ ]
+
children =
[
Pleroma.Repo,
+ Pleroma.Emoji,
{Pleroma.Config.TransferTask, false},
Pleroma.Web.Endpoint,
- {Oban, Pleroma.Config.get(Oban)}
+ {Oban, oban_config},
+ {Majic.Pool,
+ [name: Pleroma.MajicPool, pool_size: Pleroma.Config.get([:majic_pool, :size], 2)]}
] ++
http_children(adapter)
diff --git a/lib/mix/tasks/pleroma/database.ex b/lib/mix/tasks/pleroma/database.ex
index a01c36ece..22151ce08 100644
--- a/lib/mix/tasks/pleroma/database.ex
+++ b/lib/mix/tasks/pleroma/database.ex
@@ -48,9 +48,15 @@ defmodule Mix.Tasks.Pleroma.Database do
def run(["update_users_following_followers_counts"]) do
start_pleroma()
- User
- |> Repo.all()
- |> Enum.each(&User.update_follower_count/1)
+ Repo.transaction(
+ fn ->
+ from(u in User, select: u)
+ |> Repo.stream()
+ |> Stream.each(&User.update_follower_count/1)
+ |> Stream.run()
+ end,
+ timeout: :infinity
+ )
end
def run(["prune_objects" | args]) do
diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex
index ca9c8579f..20fe6c6e4 100644
--- a/lib/mix/tasks/pleroma/user.ex
+++ b/lib/mix/tasks/pleroma/user.ex
@@ -345,11 +345,11 @@ defmodule Mix.Tasks.Pleroma.User do
end
end
- def run(["toggle_confirmed", nickname]) do
+ def run(["confirm", nickname]) do
start_pleroma()
with %User{} = user <- User.get_cached_by_nickname(nickname) do
- {:ok, user} = User.toggle_confirmation(user)
+ {:ok, user} = User.confirm(user)
message = if user.confirmation_pending, do: "needs", else: "doesn't need"
diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex
index 806a61fd2..d3625dbf2 100644
--- a/lib/pleroma/emails/user_email.ex
+++ b/lib/pleroma/emails/user_email.ex
@@ -93,6 +93,19 @@ defmodule Pleroma.Emails.UserEmail do
|> html_body(html_body)
end
+ def approval_pending_email(user) do
+ html_body = """
+ <h3>Awaiting Approval</h3>
+ <p>Your account at #{instance_name()} is being reviewed by staff. You will receive another email once your account is approved.</p>
+ """
+
+ new()
+ |> to(recipient(user))
+ |> from(sender())
+ |> subject("Your account is awaiting approval")
+ |> html_body(html_body)
+ end
+
@doc """
Email used in digest email notifications
Includes Mentions and New Followers data
@@ -151,7 +164,7 @@ defmodule Pleroma.Emails.UserEmail do
logo_path =
if is_nil(logo) do
- Path.join(:code.priv_dir(:pleroma), "static/static/logo.png")
+ Path.join(:code.priv_dir(:pleroma), "static/static/logo.svg")
else
Path.join(Config.get([:instance, :static_dir]), logo)
end
@@ -162,7 +175,7 @@ defmodule Pleroma.Emails.UserEmail do
|> subject("Your digest from #{instance_name()}")
|> put_layout(false)
|> render_body("digest.html", html_data)
- |> attachment(Swoosh.Attachment.new(logo_path, filename: "logo.png", type: :inline))
+ |> attachment(Swoosh.Attachment.new(logo_path, filename: "logo.svg", type: :inline))
end
end
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index 26a9572a4..bd4801058 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -808,18 +808,50 @@ defmodule Pleroma.User do
end
end
- def post_register_action(%User{} = user) do
+ def post_register_action(%User{confirmation_pending: true} = user) do
+ with {:ok, _} <- try_send_confirmation_email(user) do
+ {:ok, user}
+ end
+ end
+
+ def post_register_action(%User{approval_pending: true} = user) do
+ with {:ok, _} <- send_user_approval_email(user),
+ {:ok, _} <- send_admin_approval_emails(user) do
+ {:ok, user}
+ end
+ end
+
+ def post_register_action(%User{approval_pending: false, confirmation_pending: false} = user) do
with {:ok, user} <- autofollow_users(user),
{:ok, _} <- autofollowing_users(user),
{:ok, user} <- set_cache(user),
{:ok, _} <- send_welcome_email(user),
{:ok, _} <- send_welcome_message(user),
- {:ok, _} <- send_welcome_chat_message(user),
- {:ok, _} <- try_send_confirmation_email(user) do
+ {:ok, _} <- send_welcome_chat_message(user) do
{:ok, user}
end
end
+ defp send_user_approval_email(user) do
+ user
+ |> Pleroma.Emails.UserEmail.approval_pending_email()
+ |> Pleroma.Emails.Mailer.deliver_async()
+
+ {:ok, :enqueued}
+ end
+
+ defp send_admin_approval_emails(user) do
+ all_superusers()
+ |> Enum.filter(fn user -> not is_nil(user.email) end)
+ |> Enum.each(fn superuser ->
+ superuser
+ |> Pleroma.Emails.AdminEmail.new_unapproved_registration(user)
+ |> Pleroma.Emails.Mailer.deliver_async()
+ end)
+
+ {:ok, :enqueued}
+ end
+
def send_welcome_message(user) do
if User.WelcomeMessage.enabled?() do
User.WelcomeMessage.post_message(user)
@@ -1592,11 +1624,34 @@ defmodule Pleroma.User do
end)
end
- def approve(%User{} = user) do
- change(user, approval_pending: false)
- |> update_and_set_cache()
+ def approve(%User{approval_pending: true} = user) do
+ with chg <- change(user, approval_pending: false),
+ {:ok, user} <- update_and_set_cache(chg) do
+ post_register_action(user)
+ {:ok, user}
+ end
+ end
+
+ def approve(%User{} = user), do: {:ok, user}
+
+ def confirm(users) when is_list(users) do
+ Repo.transaction(fn ->
+ Enum.map(users, fn user ->
+ with {:ok, user} <- confirm(user), do: user
+ end)
+ end)
+ end
+
+ def confirm(%User{confirmation_pending: true} = user) do
+ with chg <- confirmation_changeset(user, need_confirmation: false),
+ {:ok, user} <- update_and_set_cache(chg) do
+ post_register_action(user)
+ {:ok, user}
+ end
end
+ def confirm(%User{} = user), do: {:ok, user}
+
def update_notification_settings(%User{} = user, settings) do
user
|> cast(%{notification_settings: settings}, [])
@@ -2083,18 +2138,6 @@ defmodule Pleroma.User do
updated_user
end
- @spec toggle_confirmation(User.t()) :: {:ok, User.t()} | {:error, Changeset.t()}
- def toggle_confirmation(%User{} = user) do
- user
- |> confirmation_changeset(need_confirmation: !user.confirmation_pending)
- |> update_and_set_cache()
- end
-
- @spec toggle_confirmation([User.t()]) :: [{:ok, User.t()} | {:error, Changeset.t()}]
- def toggle_confirmation(users) do
- Enum.map(users, &toggle_confirmation/1)
- end
-
@spec need_confirmation(User.t(), boolean()) :: {:ok, User.t()} | {:error, Changeset.t()}
def need_confirmation(%User{} = user, bool) do
user
diff --git a/lib/pleroma/web/admin_api/controllers/admin_api_controller.ex b/lib/pleroma/web/admin_api/controllers/admin_api_controller.ex
index 5c2c282b3..75525104f 100644
--- a/lib/pleroma/web/admin_api/controllers/admin_api_controller.ex
+++ b/lib/pleroma/web/admin_api/controllers/admin_api_controller.ex
@@ -415,7 +415,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
def confirm_email(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
- User.toggle_confirmation(users)
+ User.confirm(users)
ModerationLog.insert_log(%{actor: admin, subject: users, action: "confirm_email"})
diff --git a/lib/pleroma/web/feed/feed_view.ex b/lib/pleroma/web/feed/feed_view.ex
index 56c024617..30e0a2a55 100644
--- a/lib/pleroma/web/feed/feed_view.ex
+++ b/lib/pleroma/web/feed/feed_view.ex
@@ -51,7 +51,7 @@ defmodule Pleroma.Web.Feed.FeedView do
def feed_logo do
case Pleroma.Config.get([:feed, :logo]) do
nil ->
- "#{Pleroma.Web.base_url()}/static/logo.png"
+ "#{Pleroma.Web.base_url()}/static/logo.svg"
logo ->
"#{Pleroma.Web.base_url()}#{logo}"
diff --git a/lib/pleroma/web/templates/email/digest.html.eex b/lib/pleroma/web/templates/email/digest.html.eex
index 860df5f9c..60eceff22 100644
--- a/lib/pleroma/web/templates/email/digest.html.eex
+++ b/lib/pleroma/web/templates/email/digest.html.eex
@@ -126,7 +126,7 @@
<div align="center" class="img-container center"
style="padding-right: 0px;padding-left: 0px;">
<!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr style="line-height:0px"><td style="padding-right: 0px;padding-left: 0px;" align="center"><![endif]--><img
- align="center" alt="Image" border="0" class="center" src="cid:logo.png"
+ align="center" alt="Image" border="0" class="center" src="cid:logo.svg"
style="text-decoration: none; -ms-interpolation-mode: bicubic; border: 0; height: 80px; width: auto; max-height: 80px; display: block;"
title="Image" height="80" />
<!--[if mso]></td></tr></table><![endif]-->
diff --git a/lib/pleroma/web/twitter_api/controller.ex b/lib/pleroma/web/twitter_api/controller.ex
index f42dba442..16f43863c 100644
--- a/lib/pleroma/web/twitter_api/controller.ex
+++ b/lib/pleroma/web/twitter_api/controller.ex
@@ -31,10 +31,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def confirm_email(conn, %{"user_id" => uid, "token" => token}) do
with %User{} = user <- User.get_cached_by_id(uid),
true <- user.local and user.confirmation_pending and user.confirmation_token == token,
- {:ok, _} <-
- user
- |> User.confirmation_changeset(need_confirmation: false)
- |> User.update_and_set_cache() do
+ {:ok, _} <- User.confirm(user) do
redirect(conn, to: "/")
end
end
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex
index 5d7948507..8e20b0d55 100644
--- a/lib/pleroma/web/twitter_api/twitter_api.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api.ex
@@ -45,7 +45,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
case User.register(changeset) do
{:ok, user} ->
- maybe_notify_admins(user)
{:ok, user}
{:error, changeset} ->
@@ -58,18 +57,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
end
end
- defp maybe_notify_admins(%User{} = account) do
- if Pleroma.Config.get([:instance, :account_approval_required]) do
- User.all_superusers()
- |> Enum.filter(fn user -> not is_nil(user.email) end)
- |> Enum.each(fn superuser ->
- superuser
- |> Pleroma.Emails.AdminEmail.new_unapproved_registration(account)
- |> Pleroma.Emails.Mailer.deliver_async()
- end)
- end
- end
-
def password_reset(nickname_or_email) do
with true <- is_binary(nickname_or_email),
%User{local: true, email: email, deactivated: false} = user when is_binary(email) <-
diff --git a/lib/pleroma/web/web_finger.ex b/lib/pleroma/web/web_finger.ex
index 6629f5356..2e39ae048 100644
--- a/lib/pleroma/web/web_finger.ex
+++ b/lib/pleroma/web/web_finger.ex
@@ -116,6 +116,9 @@ defmodule Pleroma.Web.WebFinger do
{"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", "self"} ->
Map.put(data, "ap_id", link["href"])
+ {nil, "http://ostatus.org/schema/1.0/subscribe"} ->
+ Map.put(data, "subscribe_address", link["template"])
+
_ ->
Logger.debug("Unhandled type: #{inspect(link["type"])}")
data
diff --git a/mix.exs b/mix.exs
index 6fac1c66b..a596e34ea 100644
--- a/mix.exs
+++ b/mix.exs
@@ -22,7 +22,7 @@ defmodule Pleroma.Mixfile do
docs: [
source_url_pattern:
"https://git.pleroma.social/pleroma/pleroma/blob/develop/%{path}#L%{line}",
- logo: "priv/static/static/logo.png",
+ logo: "priv/static/images/logo.png",
extras: ["README.md", "CHANGELOG.md"] ++ Path.wildcard("docs/**/*.md"),
groups_for_extras: [
"Installation manuals": Path.wildcard("docs/installation/*.md"),
@@ -158,7 +158,7 @@ defmodule Pleroma.Mixfile do
{:floki, "~> 0.27"},
{:timex, "~> 3.6"},
{:ueberauth, "~> 0.4"},
- {:linkify, "~> 0.4.0"},
+ {:linkify, "~> 0.4.1"},
{:http_signatures, "~> 0.1.0"},
{:telemetry, "~> 0.3"},
{:poolboy, "~> 1.5"},
diff --git a/mix.lock b/mix.lock
index 538be9e20..32b2e1391 100644
--- a/mix.lock
+++ b/mix.lock
@@ -33,7 +33,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.1", "8faa29a5597faba999aeeb72bbb9c91694ef8068f0131192fb199f98d32994ef", [:mix], [], "hexpm", "35d33270680f8d839a4003c3e9f43afb595310a592405a00afc12de4c7f55a18"},
+ "elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"},
"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,7 +65,7 @@
"jose": {:hex, :jose, "1.10.1", "16d8e460dae7203c6d1efa3f277e25b5af8b659febfc2f2eb4bacf87f128b80a", [:mix, :rebar3], [], "hexpm", "3c7ddc8a9394b92891db7c2771da94bf819834a1a4c92e30857b7d582e2f8257"},
"jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},
"libring": {:hex, :libring, "1.4.0", "41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6", [:mix], [], "hexpm"},
- "linkify": {:hex, :linkify, "0.4.0", "7845b6ac33050a41acaf9318923ce6e7f3854418be9a5f22184de103f7a68ff9", [:mix], [], "hexpm", "a0ceb4c78591fecccf1d99fecc10c13dba75a307c663c80e28af9e2cdd9776ee"},
+ "linkify": {:hex, :linkify, "0.4.1", "f881eb3429ae88010cf736e6fb3eed406c187bcdd544902ec937496636b7c7b3", [:mix], [], "hexpm", "ce98693f54ae9ace59f2f7a8aed3de2ef311381a8ce7794804bd75484c371dda"},
"majic": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/majic.git", "4c692e544b28d1f5e543fb8a44be090f8cd96f80", [ref: "4c692e544b28d1f5e543fb8a44be090f8cd96f80"]},
"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"},
diff --git a/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs b/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs
new file mode 100644
index 000000000..560cc7447
--- /dev/null
+++ b/priv/repo/migrations/20201217172858_data_migration_prolong_o_auth_tokens_valid_until.exs
@@ -0,0 +1,13 @@
+defmodule Pleroma.Repo.Migrations.DataMigrationProlongOAuthTokensValidUntil do
+ use Ecto.Migration
+
+ def up do
+ expires_in = Pleroma.Config.get!([:oauth2, :token_expires_in])
+ valid_until = NaiveDateTime.add(NaiveDateTime.utc_now(), expires_in, :second)
+ execute("update oauth_tokens set valid_until = '#{valid_until}'")
+ end
+
+ def down do
+ :noop
+ end
+end
diff --git a/priv/static/images/logo.png b/priv/static/images/logo.png
new file mode 100644
index 000000000..7744b1acc
--- /dev/null
+++ b/priv/static/images/logo.png
Binary files differ
diff --git a/priv/templates/sample_config.eex b/priv/templates/sample_config.eex
index cdddc47ea..2f5952ef1 100644
--- a/priv/templates/sample_config.eex
+++ b/priv/templates/sample_config.eex
@@ -32,8 +32,7 @@ config :pleroma, Pleroma.Repo,
username: "<%= dbuser %>",
password: "<%= dbpass %>",
database: "<%= dbname %>",
- hostname: "<%= dbhost %>",
- pool_size: 10
+ hostname: "<%= dbhost %>"
# Configure web push notifications
config :web_push_encryption, :vapid_details,
diff --git a/test/mix/tasks/pleroma/database_test.exs b/test/mix/tasks/pleroma/database_test.exs
index 4f54f13c0..eefb12426 100644
--- a/test/mix/tasks/pleroma/database_test.exs
+++ b/test/mix/tasks/pleroma/database_test.exs
@@ -87,7 +87,8 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
assert user.follower_count == 3
- assert :ok == Mix.Tasks.Pleroma.Database.run(["update_users_following_followers_counts"])
+ assert {:ok, :ok} ==
+ Mix.Tasks.Pleroma.Database.run(["update_users_following_followers_counts"])
user = User.get_by_id(user.id)
diff --git a/test/mix/tasks/pleroma/user_test.exs b/test/mix/tasks/pleroma/user_test.exs
index 127771212..de8ab27e5 100644
--- a/test/mix/tasks/pleroma/user_test.exs
+++ b/test/mix/tasks/pleroma/user_test.exs
@@ -462,24 +462,24 @@ defmodule Mix.Tasks.Pleroma.UserTest do
end
end
- describe "running toggle_confirmed" do
+ describe "running confirm" do
test "user is confirmed" do
%{id: id, nickname: nickname} = insert(:user, confirmation_pending: false)
- assert :ok = Mix.Tasks.Pleroma.User.run(["toggle_confirmed", nickname])
+ assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname])
assert_received {:mix_shell, :info, [message]}
- assert message == "#{nickname} needs confirmation."
+ assert message == "#{nickname} doesn't need confirmation."
user = Repo.get(User, id)
- assert user.confirmation_pending
- assert user.confirmation_token
+ refute user.confirmation_pending
+ refute user.confirmation_token
end
test "user is not confirmed" do
%{id: id, nickname: nickname} =
insert(:user, confirmation_pending: true, confirmation_token: "some token")
- assert :ok = Mix.Tasks.Pleroma.User.run(["toggle_confirmed", nickname])
+ assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname])
assert_received {:mix_shell, :info, [message]}
assert message == "#{nickname} doesn't need confirmation."
@@ -489,7 +489,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
end
test "it prints an error message when user is not exist" do
- Mix.Tasks.Pleroma.User.run(["toggle_confirmed", "foo"])
+ Mix.Tasks.Pleroma.User.run(["confirm", "foo"])
assert_received {:mix_shell, :error, [message]}
assert message =~ "No local user"
diff --git a/test/pleroma/emails/user_email_test.exs b/test/pleroma/emails/user_email_test.exs
index d81eff004..bd21d8dec 100644
--- a/test/pleroma/emails/user_email_test.exs
+++ b/test/pleroma/emails/user_email_test.exs
@@ -45,4 +45,15 @@ defmodule Pleroma.Emails.UserEmailTest do
assert email.html_body =~
Router.Helpers.confirm_email_url(Endpoint, :confirm_email, user.id, "conf-token")
end
+
+ test "build approval pending email" do
+ config = Pleroma.Config.get(:instance)
+ user = insert(:user)
+ email = UserEmail.approval_pending_email(user)
+
+ assert email.from == {config[:name], config[:notify_email]}
+ assert email.to == [{user.name, user.email}]
+ assert email.subject == "Your account is awaiting approval"
+ assert email.html_body =~ "Awaiting Approval"
+ end
end
diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs
index 5d544fe7d..40bbcad0b 100644
--- a/test/pleroma/user_test.exs
+++ b/test/pleroma/user_test.exs
@@ -535,6 +535,22 @@ defmodule Pleroma.UserTest do
|> assert_email_sent()
end
+ test "sends a pending approval email" do
+ clear_config([:instance, :account_approval_required], true)
+
+ {:ok, user} =
+ User.register_changeset(%User{}, @full_user_data)
+ |> User.register()
+
+ ObanHelpers.perform_all()
+
+ assert_email_sent(
+ from: Pleroma.Config.Helpers.sender(),
+ to: {user.name, user.email},
+ subject: "Your account is awaiting approval"
+ )
+ end
+
test "it requires an email, name, nickname and password, bio is optional when account_activation_required is enabled" do
Pleroma.Config.put([:instance, :account_activation_required], true)
@@ -1393,6 +1409,98 @@ defmodule Pleroma.UserTest do
assert false == user.approval_pending
end)
end
+
+ test "it sends welcome email if it is set" do
+ clear_config([:welcome, :email, :enabled], true)
+ clear_config([:welcome, :email, :sender], "tester@test.me")
+
+ user = insert(:user, approval_pending: true)
+ welcome_user = insert(:user, email: "tester@test.me")
+ instance_name = Pleroma.Config.get([:instance, :name])
+
+ User.approve(user)
+
+ ObanHelpers.perform_all()
+
+ assert_email_sent(
+ from: {instance_name, welcome_user.email},
+ to: {user.name, user.email},
+ html_body: "Welcome to #{instance_name}"
+ )
+ end
+
+ test "approving an approved user does not trigger post-register actions" do
+ clear_config([:welcome, :email, :enabled], true)
+
+ user = insert(:user, approval_pending: false)
+ User.approve(user)
+
+ ObanHelpers.perform_all()
+
+ assert_no_email_sent()
+ end
+ end
+
+ describe "confirm" do
+ test "confirms a user" do
+ user = insert(:user, confirmation_pending: true)
+ assert true == user.confirmation_pending
+ {:ok, user} = User.confirm(user)
+ assert false == user.confirmation_pending
+ end
+
+ test "confirms a list of users" do
+ unconfirmed_users = [
+ insert(:user, confirmation_pending: true),
+ insert(:user, confirmation_pending: true),
+ insert(:user, confirmation_pending: true)
+ ]
+
+ {:ok, users} = User.confirm(unconfirmed_users)
+
+ assert Enum.count(users) == 3
+
+ Enum.each(users, fn user ->
+ assert false == user.confirmation_pending
+ end)
+ end
+
+ test "sends approval emails when `approval_pending: true`" do
+ admin = insert(:user, is_admin: true)
+ user = insert(:user, confirmation_pending: true, approval_pending: true)
+ User.confirm(user)
+
+ ObanHelpers.perform_all()
+
+ user_email = Pleroma.Emails.UserEmail.approval_pending_email(user)
+ admin_email = Pleroma.Emails.AdminEmail.new_unapproved_registration(admin, user)
+
+ notify_email = Pleroma.Config.get([:instance, :notify_email])
+ instance_name = Pleroma.Config.get([:instance, :name])
+
+ # User approval email
+ assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {user.name, user.email},
+ html_body: user_email.html_body
+ )
+
+ # Admin email
+ assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {admin.name, admin.email},
+ html_body: admin_email.html_body
+ )
+ end
+
+ test "confirming a confirmed user does not trigger post-register actions" do
+ user = insert(:user, confirmation_pending: false, approval_pending: true)
+ User.confirm(user)
+
+ ObanHelpers.perform_all()
+
+ assert_no_email_sent()
+ end
end
describe "delete" do
@@ -1889,24 +1997,6 @@ defmodule Pleroma.UserTest do
end
end
- describe "toggle_confirmation/1" do
- test "if user is confirmed" do
- user = insert(:user, confirmation_pending: false)
- {:ok, user} = User.toggle_confirmation(user)
-
- assert user.confirmation_pending
- assert user.confirmation_token
- end
-
- test "if user is unconfirmed" do
- user = insert(:user, confirmation_pending: true, confirmation_token: "some token")
- {:ok, user} = User.toggle_confirmation(user)
-
- refute user.confirmation_pending
- refute user.confirmation_token
- end
- end
-
describe "ensure_keys_present" do
test "it creates keys for a user and stores them in info" do
user = insert(:user)
diff --git a/test/pleroma/web/feed/tag_controller_test.exs b/test/pleroma/web/feed/tag_controller_test.exs
index e4084b0e5..b4abcf6f2 100644
--- a/test/pleroma/web/feed/tag_controller_test.exs
+++ b/test/pleroma/web/feed/tag_controller_test.exs
@@ -131,7 +131,7 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
'#{Pleroma.Web.base_url()}/tags/pleromaart.rss'
assert xpath(xml, ~x"//channel/webfeeds:logo/text()") ==
- '#{Pleroma.Web.base_url()}/static/logo.png'
+ '#{Pleroma.Web.base_url()}/static/logo.svg'
assert xpath(xml, ~x"//channel/item/title/text()"l) == [
'42 This is :moominmamm...',
diff --git a/test/pleroma/web/preload/providers/instance_test.exs b/test/pleroma/web/preload/providers/instance_test.exs
index 8493f2a94..6033899b0 100644
--- a/test/pleroma/web/preload/providers/instance_test.exs
+++ b/test/pleroma/web/preload/providers/instance_test.exs
@@ -50,7 +50,7 @@ defmodule Pleroma.Web.Preload.Providers.InstanceTest do
"/api/pleroma/frontend_configurations" => fe_configs
} do
assert %{
- pleroma_fe: %{background: "/images/city.jpg", logo: "/static/logo.png"}
+ pleroma_fe: %{background: "/images/city.jpg", logo: "/static/logo.svg"}
} = fe_configs
end
end
diff --git a/test/pleroma/web/twitter_api/twitter_api_test.exs b/test/pleroma/web/twitter_api/twitter_api_test.exs
index 8b6465b72..5586a9a13 100644
--- a/test/pleroma/web/twitter_api/twitter_api_test.exs
+++ b/test/pleroma/web/twitter_api/twitter_api_test.exs
@@ -80,13 +80,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
end
test "it sends an admin email if :account_approval_required is specified in instance config" do
- admin = insert(:user, is_admin: true)
- setting = Pleroma.Config.get([:instance, :account_approval_required])
+ clear_config([:instance, :account_approval_required], true)
- unless setting do
- Pleroma.Config.put([:instance, :account_approval_required], true)
- on_exit(fn -> Pleroma.Config.put([:instance, :account_approval_required], setting) end)
- end
+ admin = insert(:user, is_admin: true)
data = %{
:username => "lain",
@@ -103,15 +99,24 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
assert user.approval_pending
- email = Pleroma.Emails.AdminEmail.new_unapproved_registration(admin, user)
+ user_email = Pleroma.Emails.UserEmail.approval_pending_email(user)
+ admin_email = Pleroma.Emails.AdminEmail.new_unapproved_registration(admin, user)
notify_email = Pleroma.Config.get([:instance, :notify_email])
instance_name = Pleroma.Config.get([:instance, :name])
+ # User approval email
+ Swoosh.TestAssertions.assert_email_sent(
+ from: {instance_name, notify_email},
+ to: {user.name, user.email},
+ html_body: user_email.html_body
+ )
+
+ # Admin email
Swoosh.TestAssertions.assert_email_sent(
from: {instance_name, notify_email},
to: {admin.name, admin.email},
- html_body: email.html_body
+ html_body: admin_email.html_body
)
end
diff --git a/test/pleroma/web/web_finger_test.exs b/test/pleroma/web/web_finger_test.exs
index 3c9122b14..cdb84ae1e 100644
--- a/test/pleroma/web/web_finger_test.exs
+++ b/test/pleroma/web/web_finger_test.exs
@@ -56,12 +56,13 @@ defmodule Pleroma.Web.WebFingerTest do
{:ok, _data} = WebFinger.finger(user)
end
- test "returns the ActivityPub actor URI for an ActivityPub user with the ld+json mimetype" do
+ test "returns the ActivityPub actor URI and subscribe address for an ActivityPub user with the ld+json mimetype" do
user = "kaniini@gerzilla.de"
{:ok, data} = WebFinger.finger(user)
assert data["ap_id"] == "https://gerzilla.de/channel/kaniini"
+ assert data["subscribe_address"] == "https://gerzilla.de/follow?f=&url={uri}"
end
test "it work for AP-only user" do
diff --git a/test/pleroma/workers/cron/new_users_digest_worker_test.exs b/test/pleroma/workers/cron/new_users_digest_worker_test.exs
index c89dec93c..e00ed6745 100644
--- a/test/pleroma/workers/cron/new_users_digest_worker_test.exs
+++ b/test/pleroma/workers/cron/new_users_digest_worker_test.exs
@@ -28,7 +28,7 @@ defmodule Pleroma.Workers.Cron.NewUsersDigestWorkerTest do
assert email.html_body =~ user.nickname
assert email.html_body =~ user2.nickname
assert email.html_body =~ "cofe"
- assert email.html_body =~ "#{Pleroma.Web.Endpoint.url()}/static/logo.png"
+ assert email.html_body =~ "#{Pleroma.Web.Endpoint.url()}/static/logo.svg"
end
test "it doesn't fail when admin has no email" do