Fix for dropping posts/notifs in WS when mix task is executed

- start oban in mix tasks with empty queues, plugins and crontab
- fix for update_users_following_followers_counts
- fix for removed logo.png
- typo in resend confirmation emails mix task docs
- fix for uploads mix task (start Majic.Pool)
- fix for creating user mix task (start :fast_html app)
This commit is contained in:
Alexander Strizhakov 2020-12-12 17:30:08 +03:00 committed by Mark Felder
parent f687befb93
commit cebe3c7def
15 changed files with 43 additions and 25 deletions

View file

@ -105,7 +105,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). - 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 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 - Mix task option for force-unfollowing relays
- App metrics: ability to restrict access to specified IP whitelist. - App metrics: ability to restrict access to specified IP whitelist.

View file

@ -306,7 +306,7 @@ config :pleroma, :frontend_configurations,
hideSitename: false, hideSitename: false,
hideUserStats: false, hideUserStats: false,
loginMethod: "password", loginMethod: "password",
logo: "/static/logo.png", logo: "/static/logo.svg",
logoMargin: ".1em", logoMargin: ".1em",
logoMask: true, logoMask: true,
minimalScopesMode: false, minimalScopesMode: false,
@ -343,8 +343,8 @@ config :pleroma, :assets,
config :pleroma, :manifest, config :pleroma, :manifest,
icons: [ icons: [
%{ %{
src: "/static/logo.png", src: "/static/logo.svg",
type: "image/png" type: "image/svg+xml"
} }
], ],
theme_color: "#282c37", theme_color: "#282c37",

View file

@ -1254,7 +1254,7 @@ config :pleroma, :config_description, [
hideSitename: false, hideSitename: false,
hideUserStats: false, hideUserStats: false,
loginMethod: "password", loginMethod: "password",
logo: "/static/logo.png", logo: "/static/logo.svg",
logoMargin: ".1em", logoMargin: ".1em",
logoMask: true, logoMask: true,
minimalScopesMode: false, minimalScopesMode: false,
@ -1340,7 +1340,7 @@ config :pleroma, :config_description, [
key: :logo, key: :logo,
type: {:string, :image}, type: {:string, :image},
description: "URL of the logo, defaults to Pleroma's logo", description: "URL of the logo, defaults to Pleroma's logo",
suggestions: ["/static/logo.png"] suggestions: ["/static/logo.svg"]
}, },
%{ %{
key: :logoMargin, key: :logoMargin,

View file

@ -16,7 +16,6 @@
mix pleroma.email test [--to <destination email address>] mix pleroma.email test [--to <destination email address>]
``` ```
Example: Example:
=== "OTP" === "OTP"
@ -36,11 +35,11 @@ Example:
=== "OTP" === "OTP"
```sh ```sh
./bin/pleroma_ctl email send_confirmation_mails ./bin/pleroma_ctl email resend_confirmation_emails
``` ```
=== "From Source" === "From Source"
```sh ```sh
mix pleroma.email send_confirmation_mails mix pleroma.email resend_confirmation_emails
``` ```

View file

@ -12,7 +12,8 @@ defmodule Mix.Pleroma do
:cachex, :cachex,
:flake_id, :flake_id,
:swoosh, :swoosh,
:timex :timex,
:fast_html
] ]
@cachex_children ["object", "user", "scrubber", "web_resp"] @cachex_children ["object", "user", "scrubber", "web_resp"]
@doc "Common functions to be reused in mix tasks" @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) Enum.each(apps, &Application.ensure_all_started/1)
oban_config = [
crontab: [],
repo: Pleroma.Repo,
log: false,
queues: [],
plugins: []
]
children = children =
[ [
Pleroma.Repo, Pleroma.Repo,
Pleroma.Emoji,
{Pleroma.Config.TransferTask, false}, {Pleroma.Config.TransferTask, false},
Pleroma.Web.Endpoint, 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) http_children(adapter)

View file

@ -48,9 +48,15 @@ defmodule Mix.Tasks.Pleroma.Database do
def run(["update_users_following_followers_counts"]) do def run(["update_users_following_followers_counts"]) do
start_pleroma() start_pleroma()
User Repo.transaction(
|> Repo.all() fn ->
|> Enum.each(&User.update_follower_count/1) from(u in User, select: u)
|> Repo.stream()
|> Stream.each(&User.update_follower_count/1)
|> Stream.run()
end,
timeout: :infinity
)
end end
def run(["prune_objects" | args]) do def run(["prune_objects" | args]) do

View file

@ -151,7 +151,7 @@ defmodule Pleroma.Emails.UserEmail do
logo_path = logo_path =
if is_nil(logo) do 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 else
Path.join(Config.get([:instance, :static_dir]), logo) Path.join(Config.get([:instance, :static_dir]), logo)
end end
@ -162,7 +162,7 @@ defmodule Pleroma.Emails.UserEmail do
|> subject("Your digest from #{instance_name()}") |> subject("Your digest from #{instance_name()}")
|> put_layout(false) |> put_layout(false)
|> render_body("digest.html", html_data) |> 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
end end

View file

@ -51,7 +51,7 @@ defmodule Pleroma.Web.Feed.FeedView do
def feed_logo do def feed_logo do
case Pleroma.Config.get([:feed, :logo]) do case Pleroma.Config.get([:feed, :logo]) do
nil -> nil ->
"#{Pleroma.Web.base_url()}/static/logo.png" "#{Pleroma.Web.base_url()}/static/logo.svg"
logo -> logo ->
"#{Pleroma.Web.base_url()}#{logo}" "#{Pleroma.Web.base_url()}#{logo}"

View file

@ -126,7 +126,7 @@
<div align="center" class="img-container center" <div align="center" class="img-container center"
style="padding-right: 0px;padding-left: 0px;"> 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 <!--[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;" style="text-decoration: none; -ms-interpolation-mode: bicubic; border: 0; height: 80px; width: auto; max-height: 80px; display: block;"
title="Image" height="80" /> title="Image" height="80" />
<!--[if mso]></td></tr></table><![endif]--> <!--[if mso]></td></tr></table><![endif]-->

View file

@ -22,7 +22,7 @@ defmodule Pleroma.Mixfile do
docs: [ docs: [
source_url_pattern: source_url_pattern:
"https://git.pleroma.social/pleroma/pleroma/blob/develop/%{path}#L%{line}", "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"), extras: ["README.md", "CHANGELOG.md"] ++ Path.wildcard("docs/**/*.md"),
groups_for_extras: [ groups_for_extras: [
"Installation manuals": Path.wildcard("docs/installation/*.md"), "Installation manuals": Path.wildcard("docs/installation/*.md"),

BIN
priv/static/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -87,7 +87,8 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
assert user.follower_count == 3 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) user = User.get_by_id(user.id)

View file

@ -131,7 +131,7 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
'#{Pleroma.Web.base_url()}/tags/pleromaart.rss' '#{Pleroma.Web.base_url()}/tags/pleromaart.rss'
assert xpath(xml, ~x"//channel/webfeeds:logo/text()") == 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) == [ assert xpath(xml, ~x"//channel/item/title/text()"l) == [
'42 This is :moominmamm...', '42 This is :moominmamm...',

View file

@ -50,7 +50,7 @@ defmodule Pleroma.Web.Preload.Providers.InstanceTest do
"/api/pleroma/frontend_configurations" => fe_configs "/api/pleroma/frontend_configurations" => fe_configs
} do } do
assert %{ assert %{
pleroma_fe: %{background: "/images/city.jpg", logo: "/static/logo.png"} pleroma_fe: %{background: "/images/city.jpg", logo: "/static/logo.svg"}
} = fe_configs } = fe_configs
end end
end end

View file

@ -28,7 +28,7 @@ defmodule Pleroma.Workers.Cron.NewUsersDigestWorkerTest do
assert email.html_body =~ user.nickname assert email.html_body =~ user.nickname
assert email.html_body =~ user2.nickname assert email.html_body =~ user2.nickname
assert email.html_body =~ "cofe" 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 end
test "it doesn't fail when admin has no email" do test "it doesn't fail when admin has no email" do