Skip to content

Commit

Permalink
Merge develop 2024-09-04 (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
kphrx authored Sep 4, 2024
2 parents a4b5800 + fbcfbde commit 56b3d24
Show file tree
Hide file tree
Showing 168 changed files with 2,656 additions and 1,479 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ pleroma.iml

archive-*
.gitlab-ci-local

# Test files should be named *.exs
test/pleroma/**/*.ex
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ variables: &global_variables
DB_HOST: postgres
DB_PORT: "5432"
MIX_ENV: test
GIT_STRATEGY: fetch

workflow:
rules:
Expand Down Expand Up @@ -133,7 +134,7 @@ unit-testing-1.13.4-otp-25:
script: &testing_script
- mix ecto.create
- mix ecto.migrate
- mix pleroma.test_runner --cover --preload-modules
- mix test --cover --preload-modules
coverage: '/^Line total: ([^ ]*%)$/'
artifacts:
reports:
Expand Down
1 change: 1 addition & 0 deletions changelog.d/bugfix-truncate-remote-user-fields.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Truncate remote user fields, avoids them getting rejected
Empty file added changelog.d/ci-git-fetch.skip
Empty file.
Empty file added changelog.d/commonapi.skip
Empty file.
1 change: 1 addition & 0 deletions changelog.d/deprecate-subscribe.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate `/api/v1/pleroma/accounts/:id/subscribe`/`unsubscribe`
Empty file added changelog.d/docs-fix.skip
Empty file.
1 change: 1 addition & 0 deletions changelog.d/drop-unwanted.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Restrict incoming activities from unknown actors to a subset that does not imply a previous relationship and early rejection of unrecognized activity types.
Empty file.
1 change: 1 addition & 0 deletions changelog.d/follow-request.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed malformed follow requests that cause them to appear stuck pending due to the recipient being unable to process them.
1 change: 1 addition & 0 deletions changelog.d/follow-validator.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve the FollowValidator to successfully incoming activities with an errant cc field.
1 change: 1 addition & 0 deletions changelog.d/get-statuses-param.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support `id` param in `GET /api/v1/statuses`
1 change: 1 addition & 0 deletions changelog.d/identity-proofs.remove
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove stub for /api/v1/accounts/:id/identity_proofs (deprecated by Mastodon 3.5.0)
1 change: 1 addition & 0 deletions changelog.d/mailgun.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Swoosh email adapter for Mailgun was missing a new dependency on :multipart
Empty file added changelog.d/mogrify.skip
Empty file.
Empty file added changelog.d/mrf-cleanup.skip
Empty file.
1 change: 1 addition & 0 deletions changelog.d/mrf-fodirectreply.add
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added MRF.FODirectReply which changes replies to followers-only posts to be direct.
1 change: 1 addition & 0 deletions changelog.d/mrf-quietreply.add
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added MRF.QuietReply which prevents replies to public posts from being published to the timelines
1 change: 1 addition & 0 deletions changelog.d/notifications-marker.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix 'Setting a marker should mark notifications as read'
1 change: 1 addition & 0 deletions changelog.d/oban-recevier-improvements.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ReceiverWorker will cancel processing jobs instead of retrying if the user cannot be fetched due to 403, 404, or 410 errors or if the account is disabled locally.
1 change: 1 addition & 0 deletions changelog.d/publisher-reachability.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Address case where instance reachability status couldn't be updated
1 change: 1 addition & 0 deletions changelog.d/remote-object-fetcher.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remote Fetcher Worker recognizes more permanent failure errors
1 change: 1 addition & 0 deletions changelog.d/rich-media-no-heads.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rich Media preview fetching will skip making an HTTP HEAD request to check a URL for allowed content type and length if the Tesla adapter is Gun or Finch
1 change: 1 addition & 0 deletions changelog.d/scrubbers-allow-mention-hashtag.add
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scrubbers/default: Allow "mention hashtag" classes used by Mastodon
1 change: 1 addition & 0 deletions changelog.d/stream-follow-relationships-count.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
StreamerView: Do not leak follows count if hidden
Empty file.
Empty file added changelog.d/todo-cleanup.skip
Empty file.
1 change: 1 addition & 0 deletions changelog.d/update-oban.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update Oban to 2.18
Empty file added changelog.d/user-factory.skip
Empty file.
1 change: 1 addition & 0 deletions changelog.d/user-imports.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Imports of blocks, mutes, and follows would retry repeatedly due to incorrect error handling and all work executed in a single job
1 change: 1 addition & 0 deletions changelog.d/workerhelper.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Worker configuration is no longer available. This only affects custom max_retries values for a couple Oban queues.
7 changes: 0 additions & 7 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,6 @@ config :pleroma, Oban,
{"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker}
]

config :pleroma, :workers,
retries: [
federator_incoming: 5,
federator_outgoing: 5,
search_indexing: 2
]

config :pleroma, Pleroma.Formatter,
class: false,
rel: "ugc",
Expand Down
17 changes: 0 additions & 17 deletions config/description.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2013,23 +2013,6 @@ config :pleroma, :config_description, [
}
]
},
%{
group: :pleroma,
key: :workers,
type: :group,
description: "Includes custom worker options not interpretable directly by `Oban`",
children: [
%{
key: :retries,
type: {:keyword, :integer},
description: "Max retry attempts for failed jobs, per `Oban` queue",
suggestions: [
federator_incoming: 5,
federator_outgoing: 5
]
}
]
},
%{
group: :pleroma,
key: Pleroma.Web.Metadata,
Expand Down
31 changes: 17 additions & 14 deletions docs/development/API/admin_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ Response:
* On success: URL of the unfollowed relay

```json
{"https://example.com/relay"}
"https://example.com/relay"
```

## `POST /api/v1/pleroma/admin/users/invite_token`
Expand Down Expand Up @@ -1193,20 +1193,23 @@ Loads json generated from `config/descriptions.exs`.
- Response:

```json
[
{
"id": 1234,
"data": {
"actor": {
"id": 1,
"nickname": "lain"
{
"items": [
{
"id": 1234,
"data": {
"actor": {
"id": 1,
"nickname": "lain"
},
"action": "relay_follow"
},
"action": "relay_follow"
},
"time": 1502812026, // timestamp
"message": "[2017-08-15 15:47:06] @nick0 followed relay: https://example.org/relay" // log message
}
]
"time": 1502812026, // timestamp
"message": "[2017-08-15 15:47:06] @nick0 followed relay: https://example.org/relay" // log message
}
],
"total": 1
}
```

## `POST /api/v1/pleroma/admin/reload_emoji`
Expand Down
6 changes: 0 additions & 6 deletions docs/development/API/differences_in_mastoapi_responses.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,6 @@ Pleroma is generally compatible with the Mastodon 2.7.2 API, but some newer feat

- `GET /api/v1/trends`: Returns an empty array, `[]`

### Identity proofs

*Added in Mastodon 2.8.0*

- `GET /api/v1/identity_proofs`: Returns an empty array, `[]`

### Featured tags

*Added in Mastodon 3.0.0*
Expand Down
6 changes: 6 additions & 0 deletions docs/development/API/pleroma_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ See [Admin-API](admin_api.md)

## `/api/v1/pleroma/accounts/:id/subscribe`
### Subscribe to receive notifications for all statuses posted by a user

Deprecated. `notify` parameter in `POST /api/v1/accounts/:id/follow` should be used instead.

* Method `POST`
* Authentication: required
* Params:
Expand All @@ -171,6 +174,9 @@ See [Admin-API](admin_api.md)

## `/api/v1/pleroma/accounts/:id/unsubscribe`
### Unsubscribe to stop receiving notifications from user statuses

Deprecated. `notify` parameter in `POST /api/v1/accounts/:id/follow` should be used instead.

* Method `POST`
* Authentication: required
* Params:
Expand Down
10 changes: 6 additions & 4 deletions lib/mix/tasks/pleroma/database.ex
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,12 @@ defmodule Mix.Tasks.Pleroma.Database do
|> DateTime.from_naive!("Etc/UTC")
|> Timex.shift(days: days)

Pleroma.Workers.PurgeExpiredActivity.enqueue(%{
activity_id: activity.id,
expires_at: expires_at
})
Pleroma.Workers.PurgeExpiredActivity.enqueue(
%{
activity_id: activity.id
},
scheduled_at: expires_at
)
end)
end)
|> Stream.run()
Expand Down
25 changes: 0 additions & 25 deletions lib/mix/tasks/pleroma/test_runner.ex

This file was deleted.

30 changes: 30 additions & 0 deletions lib/pleroma/constants.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,36 @@ defmodule Pleroma.Constants do
]
)

const(activity_types,
do: [
"Create",
"Update",
"Delete",
"Follow",
"Accept",
"Reject",
"Add",
"Remove",
"Like",
"Announce",
"Undo",
"Flag",
"EmojiReact"
]
)

const(allowed_activity_types_from_strangers,
do: [
"Block",
"Create",
"Flag",
"Follow",
"Like",
"EmojiReact",
"Announce"
]
)

# basic regex, just there to weed out potential mistakes
# https://datatracker.ietf.org/doc/html/rfc2045#section-5.1
const(mime_regex,
Expand Down
3 changes: 2 additions & 1 deletion lib/pleroma/emails/mailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ defmodule Pleroma.Emails.Mailer do
|> :erlang.term_to_binary()
|> Base.encode64()

MailerWorker.enqueue("email", %{"encoded_email" => encoded_email, "config" => config})
MailerWorker.new(%{"op" => "email", "encoded_email" => encoded_email, "config" => config})
|> Oban.insert()
end

@doc "callback to perform send email from queue"
Expand Down
11 changes: 7 additions & 4 deletions lib/pleroma/filter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ defmodule Pleroma.Filter do
defp maybe_add_expires_at(changeset, _), do: changeset

defp maybe_add_expiration_job(%{expires_at: %NaiveDateTime{} = expires_at} = filter) do
Pleroma.Workers.PurgeExpiredFilter.enqueue(%{
filter_id: filter.id,
expires_at: DateTime.from_naive!(expires_at, "Etc/UTC")
})
Pleroma.Workers.PurgeExpiredFilter.new(
%{
filter_id: filter.id
},
scheduled_at: DateTime.from_naive!(expires_at, "Etc/UTC")
)
|> Oban.insert()
end

defp maybe_add_expiration_job(_), do: {:ok, nil}
Expand Down
10 changes: 10 additions & 0 deletions lib/pleroma/http/adapter_helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ defmodule Pleroma.HTTP.AdapterHelper do
case adapter() do
Tesla.Adapter.Gun -> AdapterHelper.Gun
Tesla.Adapter.Hackney -> AdapterHelper.Hackney
{Tesla.Adapter.Finch, _} -> AdapterHelper.Finch
_ -> AdapterHelper.Default
end
end
Expand Down Expand Up @@ -118,4 +119,13 @@ defmodule Pleroma.HTTP.AdapterHelper do
host_charlist
end
end

@spec can_stream? :: bool()
def can_stream? do
case Application.get_env(:tesla, :adapter) do
Tesla.Adapter.Gun -> true
{Tesla.Adapter.Finch, _} -> true
_ -> false
end
end
end
33 changes: 33 additions & 0 deletions lib/pleroma/http/adapter_helper/finch.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.HTTP.AdapterHelper.Finch do
@behaviour Pleroma.HTTP.AdapterHelper

alias Pleroma.Config
alias Pleroma.HTTP.AdapterHelper

@spec options(keyword(), URI.t()) :: keyword()
def options(incoming_opts \\ [], %URI{} = _uri) do
proxy =
[:http, :proxy_url]
|> Config.get()
|> AdapterHelper.format_proxy()

config_opts = Config.get([:http, :adapter], [])

config_opts
|> Keyword.merge(incoming_opts)
|> AdapterHelper.maybe_add_proxy(proxy)
|> maybe_stream()
end

# Finch uses [response: :stream]
defp maybe_stream(opts) do
case Keyword.pop(opts, :stream, nil) do
{true, opts} -> Keyword.put(opts, :response, :stream)
{_, opts} -> opts
end
end
end
9 changes: 9 additions & 0 deletions lib/pleroma/http/adapter_helper/gun.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ defmodule Pleroma.HTTP.AdapterHelper.Gun do
|> AdapterHelper.maybe_add_proxy(proxy)
|> Keyword.merge(incoming_opts)
|> put_timeout()
|> maybe_stream()
end

defp add_scheme_opts(opts, %{scheme: "http"}), do: opts
Expand All @@ -47,6 +48,14 @@ defmodule Pleroma.HTTP.AdapterHelper.Gun do
Keyword.put(opts, :timeout, recv_timeout)
end

# Gun uses [body_as: :stream]
defp maybe_stream(opts) do
case Keyword.pop(opts, :stream, nil) do
{true, opts} -> Keyword.put(opts, :body_as, :stream)
{_, opts} -> opts
end
end

@spec pool_timeout(pool()) :: non_neg_integer()
def pool_timeout(pool) do
default = Config.get([:pools, :default, :recv_timeout], 5_000)
Expand Down
3 changes: 2 additions & 1 deletion lib/pleroma/instances/instance.ex
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ defmodule Pleroma.Instances.Instance do
all of those users' activities and notifications.
"""
def delete_users_and_activities(host) when is_binary(host) do
DeleteWorker.enqueue("delete_instance", %{"host" => host})
DeleteWorker.new(%{"op" => "delete_instance", "host" => host})
|> Oban.insert()
end

def perform(:delete_instance, host) when is_binary(host) do
Expand Down
Loading

0 comments on commit 56b3d24

Please sign in to comment.