From cebe3c7deff87ba24f43efcf50499c45d3b3e3f9 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Sat, 12 Dec 2020 17:30:08 +0300 Subject: [PATCH 1/2] 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) --- CHANGELOG.md | 4 ++-- config/config.exs | 6 +++--- config/description.exs | 4 ++-- docs/administration/CLI_tasks/email.md | 7 +++---- lib/mix/pleroma.ex | 16 ++++++++++++++-- lib/mix/tasks/pleroma/database.ex | 12 +++++++++--- lib/pleroma/emails/user_email.ex | 4 ++-- lib/pleroma/web/feed/feed_view.ex | 2 +- lib/pleroma/web/templates/email/digest.html.eex | 2 +- mix.exs | 2 +- priv/static/images/logo.png | Bin 0 -> 1304 bytes test/mix/tasks/pleroma/database_test.exs | 3 ++- test/pleroma/web/feed/tag_controller_test.exs | 2 +- test/pleroma/web/preload/providers/instance_test.exs | 2 +- .../workers/cron/new_users_digest_worker_test.exs | 2 +- 15 files changed, 43 insertions(+), 25 deletions(-) create mode 100644 priv/static/images/logo.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 07d0c63c1..fb337e10c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - 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 +- Streaming API: Add follow relationships updates ### Fixed @@ -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). - 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 c7ac0d22c..98c87a4f9 100644 --- a/config/config.exs +++ b/config/config.exs @@ -306,7 +306,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, @@ -343,8 +343,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", diff --git a/config/description.exs b/config/description.exs index f4b8768da..a916a0711 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, 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 ] ``` - -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/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/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex index 806a61fd2..e6829b862 100644 --- a/lib/pleroma/emails/user_email.ex +++ b/lib/pleroma/emails/user_email.ex @@ -151,7 +151,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 +162,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/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 @@
Image diff --git a/mix.exs b/mix.exs index c948b0b02..fb5b380f4 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"), diff --git a/priv/static/images/logo.png b/priv/static/images/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..7744b1acc313c5a146410cc5a56d99629022c637 GIT binary patch literal 1304 zcmeAS@N?(olHy`uVBq!ia0vp^zd)FS4M=vpiLwP!EX7WqAsj$Z!;#Vf4nJ zu$zG}W8o(6ETEudiEBhjaDG}zd16s2LwR|*US?i)adKios$PCk`s{Z$Qb2>Idb&7< zRLpsMcYk+GsKoJy-_NK;GHVO+WTgrkn%&CUJL3$`#~G}SkdwYB5?_T#i+135d93Qpk@18S>>&My13c81F zc|PxI)c#q1%cn=rwRd5U;y;mOHrsdF>0edXufFZDFp;|Z>x9Oxb;r2spWW-|_|3KV zTG6s87W)?2eqS@C$V{napOaJk=ASinB^x95TrVw+va!F|apC%lOG~|vi*?(l3qFl_ zt^366*LVMi`z`AK{b@d(`rXr|W6radeQL93x1V=AV!XE8q2yq_8O-06q&P-12EG>MT9I`?JRw@c59u6-iG+dyE#LLC*QT!583ol!5J(j%I zoTvA~%eg^GtG~7_6tuDp(c2zpVB)mAJgYZ9Dj%$BY00}6+GPvAGW=Nn>28YAzinT; z78bfMPv5mYN?$^$yrgRJwI4V4MDt53ExgQb-{+S4 z`^w7a>$k}ng*Yu=n!5JmxrNT`^KC0XJ-NR2IM2-c7k}Dc4LY@c>osk`((O||Jp@{^ z@aqbmmUFVpE`JPOYrY{$?k;fTvwxe_{wcex<@)XOO8*IP&fRS( z8`!_yYR|PB-5d+oPjD|ME2_Q(Sl+2Rc!6W?y_KeN`Fj&HTKxF0Dz6m>1^>cL*TGV9 zt3F@jZgYF_<-!ZE*R0OUCBL5C`u8tCev6zTFiOI`I{C}W%EW-d4Ae7OI`;b9OxvW6 z7Qg;0*Oy&>slPUyXX1sI%~FB)X8?0g6u+dFe&mv^dxIWb{aEoS@U^0|T8Y%k@NC`p z`FV0R)z#I%zhBF4^LwGaZR^&p5jtY)P39DQuG0_jsx?*$` rEuQZ;$KvDPRqOc4% 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/workers/cron/new_users_digest_worker_test.exs b/test/pleroma/workers/cron/new_users_digest_worker_test.exs index 129534cb1..75c9aa4a3 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 From c37f78d1c87b0554b29213ab77f484747fa48f88 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Sun, 13 Dec 2020 15:47:43 +0300 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb337e10c..230888bbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,14 +17,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 +34,14 @@ 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. ### 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.
API Changes