From cb3258c863f7485551eb28474d60f12547019d34 Mon Sep 17 00:00:00 2001 From: lain Date: Fri, 7 Jun 2019 17:31:21 +0200 Subject: [PATCH 1/4] Emoji: Use full path to check if a file is a directory. --- lib/pleroma/emoji.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex index de7fcc1ce..b77b26f7f 100644 --- a/lib/pleroma/emoji.ex +++ b/lib/pleroma/emoji.ex @@ -98,7 +98,9 @@ defmodule Pleroma.Emoji do Logger.error("Could not access the custom emoji directory #{emoji_dir_path}: #{e}") {:ok, results} -> - grouped = Enum.group_by(results, &File.dir?/1) + grouped = + Enum.group_by(results, fn file -> File.dir?(Path.join(emoji_dir_path, file)) end) + packs = grouped[true] || [] files = grouped[false] || [] From d020f68e87decca850904b76c9053a4de024be8d Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 7 Jun 2019 20:40:38 +0300 Subject: [PATCH 2/4] Transmogrifier: Do not crash if inReplyTo does not exist and can't be fetched --- lib/pleroma/web/activity_pub/transmogrifier.ex | 2 +- test/web/activity_pub/transmogrifier_test.exs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index ff031a16e..3bb8b40b5 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -339,7 +339,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do def fix_type(%{"inReplyTo" => reply_id} = object) when is_binary(reply_id) do reply = Object.normalize(reply_id) - if reply.data["type"] == "Question" and object["name"] do + if reply && (reply.data["type"] == "Question" and object["name"]) do Map.put(object, "type", "Answer") else object diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 28971ae45..26e8d60fe 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -60,6 +60,22 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do assert returned_object.data["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873" end + test "it does not crash if the object in inReplyTo can't be fetched" do + data = + File.read!("test/fixtures/mastodon-post-activity.json") + |> Poison.decode!() + + object = + data["object"] + |> Map.put("inReplyTo", "https://nonexistent.space/whatever") + + data = + data + |> Map.put("object", object) + + {:ok, _returned_activity} = Transmogrifier.handle_incoming(data) + end + test "it works for incoming notices" do data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!() From dffc9f060adf43a4faaa5790dc8a01b3d7cb5e34 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Fri, 7 Jun 2019 20:48:25 +0300 Subject: [PATCH 3/4] replace missing mock with a 404 --- test/web/activity_pub/transmogrifier_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 26e8d60fe..cc1781403 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -67,7 +67,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do object = data["object"] - |> Map.put("inReplyTo", "https://nonexistent.space/whatever") + |> Map.put("inReplyTo", "https://404.site/whatever") data = data From 4f5149c93be8d0abffca2aa74984b03d8e27739d Mon Sep 17 00:00:00 2001 From: rinpatch Date: Sat, 8 Jun 2019 18:02:57 +0300 Subject: [PATCH 4/4] Set default loglevel to `warn` in prod It's rare that info logs are needed to debug the issue, so I would suggest setting them to warn in prod by default to make finding the relevant parts easier and potentially even decrease cpu usage on bigger instances Closes #962 --- CHANGELOG.md | 1 + config/prod.exs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf2232b09..510ad7ff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Federation: Expand the audience of delete activities to all recipients of the deleted object - Federation: Removed `inReplyToStatusId` from objects - Configuration: Dedupe enabled by default +- Configuration: Default log level in `prod` environment is now set to `warn` - Configuration: Added `extra_cookie_attrs` for setting non-standard cookie attributes. Defaults to ["SameSite=Lax"] so that remote follows work. - Timelines: Messages involving people you have blocked will be excluded from the timeline in all cases instead of just repeats. - Admin API: Move the user related API to `api/pleroma/admin/users` diff --git a/config/prod.exs b/config/prod.exs index d0cfd1ac2..1179cf3b0 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -18,7 +18,7 @@ config :pleroma, Pleroma.Web.Endpoint, protocol: "http" # Do not print debug messages in production -config :logger, level: :info +config :logger, level: :warn # ## SSL Support #