Fix for dropping posts/notifs in WS when mix task is executed
authorAlexander Strizhakov <alex.strizhakov@gmail.com>
Sat, 12 Dec 2020 14:30:08 +0000 (17:30 +0300)
committerMark Felder <feld@FreeBSD.org>
Mon, 14 Dec 2020 17:02:32 +0000 (11:02 -0600)
- 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)

15 files changed:
CHANGELOG.md
config/config.exs
config/description.exs
docs/administration/CLI_tasks/email.md
lib/mix/pleroma.ex
lib/mix/tasks/pleroma/database.ex
lib/pleroma/emails/user_email.ex
lib/pleroma/web/feed/feed_view.ex
lib/pleroma/web/templates/email/digest.html.eex
mix.exs
priv/static/images/logo.png [new file with mode: 0644]
test/mix/tasks/pleroma/database_test.exs
test/pleroma/web/feed/tag_controller_test.exs
test/pleroma/web/preload/providers/instance_test.exs
test/pleroma/workers/cron/new_users_digest_worker_test.exs

index 07d0c63c15c7d5d08ca13acdc592f9013e9bcc84..fb337e10ccef60591aebdafcee3b43e6f47faf19 100644 (file)
@@ -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
 </details>
 
 ### 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.
 
index c7ac0d22c28293b8b55c6caa4af8c2b233efb8cd..98c87a4f9f07fe5925f637162804fe42a7f58f4d 100644 (file)
@@ -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",
index f4b8768da5c0b6b4bdc076f683a56af9d0278e25..a916a0711f5559c8248a30b2dc48847de6f209b7 100644 (file)
@@ -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,
index d9aa0e71ba1b433cebb716f51d8ec379916af3f8..2bb57bea4db8bf5eb97c176c2a993a1e4e00dbb2 100644 (file)
@@ -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
     ```
index 7575f0ef847a7b414d6d9cec97d5c50c029d1033..a33a9951c48fb4eae4a2fc19b757acbb223f7a1b 100644 (file)
@@ -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)
 
index a01c36ece30754ada443c22dffc5e3d29b9f73cf..22151ce08e4d6fef4c42c23f04490d15837656d3 100644 (file)
@@ -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
index 806a61fd226f85b2e168bfcdf873322911df2c53..e6829b8621a15f85675451a7854237caeb2795ae 100644 (file)
@@ -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
 
index 56c024617c9cb948083ed8d8413659a0da0f6e7b..30e0a2a55b69228b470ed0a35a8111ff80c6149e 100644 (file)
@@ -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}"
index 860df5f9c82d91c6eb90d08672afe9b250d49da7..60eceff221d665ea37cdb3c78f0db8fa304331b3 100644 (file)
                                                                                        <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/mix.exs b/mix.exs
index c948b0b02e30df09b14ef2b8d59dd3d97fbe4a3e..fb5b380f4ba356ea6e47a05752370111b3180f65 100644 (file)
--- 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 (file)
index 0000000..7744b1a
Binary files /dev/null and b/priv/static/images/logo.png differ
index a4bd41922b67f8d7d3a725968708c3edb92211ae..cf28576b5317bde98c053242a5d677ccaed410b5 100644 (file)
@@ -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)
 
index e4084b0e554424b94956c80ff0cbd7c0abaa1cd1..b4abcf6f2394d02fe66ad7d6cef215e8db807522 100644 (file)
@@ -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...',
index 8493f2a94a76b3f7cbe61d32292f160c8ad03949..6033899b05d88f2b33691e93f4f82da7a969e647 100644 (file)
@@ -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
index 129534cb1695df351c576492fdac738a1ac27fe5..75c9aa4a30ab7ae1a36908e765ccd6ffd43263f1 100644 (file)
@@ -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