diff options
-rw-r--r-- | config/config.exs | 3 | ||||
-rw-r--r-- | docs/config.md | 1 | ||||
-rw-r--r-- | installation/pleroma.service | 18 | ||||
-rw-r--r-- | lib/pleroma/stats.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/user.ex | 11 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/views/object_view.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/common_api/common_api.ex | 9 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 1 | ||||
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 7 |
9 files changed, 40 insertions, 14 deletions
diff --git a/config/config.exs b/config/config.exs index 1c55807b7..d30b0aad0 100644 --- a/config/config.exs +++ b/config/config.exs @@ -139,7 +139,8 @@ config :pleroma, :instance, finmoji_enabled: true, mrf_transparency: true, autofollowed_nicknames: [], - max_pinned_statuses: 1 + max_pinned_statuses: 1, + no_attachment_links: false config :pleroma, :markup, # XXX - unfortunately, inline images must be enabled by default right now, because diff --git a/docs/config.md b/docs/config.md index e3738271b..6bf7b9ea7 100644 --- a/docs/config.md +++ b/docs/config.md @@ -95,6 +95,7 @@ config :pleroma, Pleroma.Mailer, older software for theses nicknames. * `max_pinned_statuses`: The maximum number of pinned statuses. `0` will disable the feature. * `autofollowed_nicknames`: Set to nicknames of (local) users that every new user should automatically follow. +* `no_attachment_links`: Set to true to disable automatically adding attachment link text to statuses ## :logger * `backends`: `:console` is used to send logs to stdout, `{ExSyslogger, :ex_syslogger}` to log to syslog diff --git a/installation/pleroma.service b/installation/pleroma.service index f1ed56cb3..72090bbc7 100644 --- a/installation/pleroma.service +++ b/installation/pleroma.service @@ -3,15 +3,23 @@ Description=Pleroma social network After=network.target postgresql.service [Service] -User=pleroma -WorkingDirectory=/home/pleroma/pleroma -Environment="HOME=/home/pleroma" -Environment="MIX_ENV=prod" -ExecStart=/usr/local/bin/mix phx.server ExecReload=/bin/kill $MAINPID KillMode=process Restart=on-failure +; Name of the user that runs the Pleroma service. +User=pleroma +; Declares that Pleroma runs in production mode. +Environment="MIX_ENV=prod" + +; Make sure that all paths fit your installation. +; Path to the home directory of the user running the Pleroma service. +Environment="HOME=/home/pleroma" +; Path to the folder containing the Pleroma installation. +WorkingDirectory=/home/pleroma/pleroma +; Path to the Mix binary. +ExecStart=/usr/bin/mix phx.server + ; Some security directives. ; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops. PrivateTmp=true diff --git a/lib/pleroma/stats.ex b/lib/pleroma/stats.ex index 65a6d58b5..b3566ceb6 100644 --- a/lib/pleroma/stats.ex +++ b/lib/pleroma/stats.ex @@ -46,7 +46,7 @@ defmodule Pleroma.Stats do from(u in User.local_user_query(), select: fragment("sum((?->>'note_count')::int)", u.info)) status_count = Repo.one(status_query) - user_count = Repo.aggregate(User.local_user_query(), :count, :id) + user_count = Repo.aggregate(User.active_local_user_query(), :count, :id) Agent.update(__MODULE__, fn _ -> {peers, %{domain_count: domain_count, status_count: status_count, user_count: user_count}} diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 2dc3c8d56..1db1c53cb 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -795,7 +795,7 @@ defmodule Pleroma.User do update_and_set_cache(cng) end - def local_user_query() do + def local_user_query do from( u in User, where: u.local == true, @@ -803,7 +803,14 @@ defmodule Pleroma.User do ) end - def moderator_user_query() do + def active_local_user_query do + from( + u in local_user_query(), + where: fragment("?->'deactivated' @> 'false'", u.info) + ) + end + + def moderator_user_query do from( u in User, where: u.local == true, diff --git a/lib/pleroma/web/activity_pub/views/object_view.ex b/lib/pleroma/web/activity_pub/views/object_view.ex index 193042056..394d82fbc 100644 --- a/lib/pleroma/web/activity_pub/views/object_view.ex +++ b/lib/pleroma/web/activity_pub/views/object_view.ex @@ -46,7 +46,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectView do "id" => "#{ap_id}/likes", "type" => "OrderedCollection", "totalItems" => length(likes), - "first" => collection(likes, "#{ap_id}/followers", 1) + "first" => collection(likes, "#{ap_id}/likes", 1) } |> Map.merge(Pleroma.Web.ActivityPub.Utils.make_json_ld_header()) end diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index 2902905fd..504670439 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -103,7 +103,14 @@ defmodule Pleroma.Web.CommonAPI do attachments, tags, get_content_type(data["content_type"]), - Enum.member?([true, "true"], data["no_attachment_links"]) + Enum.member?( + [true, "true"], + Map.get( + data, + "no_attachment_links", + Pleroma.Config.get([:instance, :no_attachment_links], false) + ) + ) ), context <- make_context(inReplyTo), cw <- data["spoiler_text"], diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index a8fe9d708..daad89185 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -341,7 +341,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do params = params |> Map.put("in_reply_to_status_id", params["in_reply_to_id"]) - |> Map.put("no_attachment_links", true) idempotency_key = case get_req_header(conn, "idempotency-key") do diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index c83bb5bc8..dd84052a3 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -1473,8 +1473,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do end test "get instance information", %{conn: conn} do - insert(:user, %{local: true}) user = insert(:user, %{local: true}) + + user2 = insert(:user, %{local: true}) + {:ok, _user2} = User.deactivate(user2, !user2.info.deactivated) + insert(:user, %{local: false, nickname: "u@peer1.com"}) insert(:user, %{local: false, nickname: "u@peer2.com"}) @@ -1489,7 +1492,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do stats = result["stats"] assert stats - assert stats["user_count"] == 2 + assert stats["user_count"] == 1 assert stats["status_count"] == 1 assert stats["domain_count"] == 2 end |