Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into fork
Browse files Browse the repository at this point in the history
Signed-off-by: marcin mikołajczak <[email protected]>
  • Loading branch information
mkljczk committed Aug 14, 2024
2 parents e9cea96 + 5174c29 commit 0a4fece
Show file tree
Hide file tree
Showing 117 changed files with 1,179 additions and 724 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ pleroma.iml

archive-*
.gitlab-ci-local

# Test files should be named *.exs
test/pleroma/**/*.ex
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,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
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.
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/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/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/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/user-factory.skip
Empty file.
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 @@ -611,13 +611,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 @@ -2059,23 +2059,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
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 @@ -564,12 +564,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.

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 @@ -133,10 +133,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
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
13 changes: 8 additions & 5 deletions lib/pleroma/mfa/token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ defmodule Pleroma.MFA.Token do
@spec create(User.t(), Authorization.t() | nil) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
def create(user, authorization \\ nil) do
with {:ok, token} <- do_create(user, authorization) do
Pleroma.Workers.PurgeExpiredToken.enqueue(%{
token_id: token.id,
valid_until: DateTime.from_naive!(token.valid_until, "Etc/UTC"),
mod: __MODULE__
})
Pleroma.Workers.PurgeExpiredToken.new(
%{
token_id: token.id,
mod: __MODULE__
},
scheduled_at: DateTime.from_naive!(token.valid_until, "Etc/UTC")
)
|> Oban.insert()

{:ok, token}
end
Expand Down
3 changes: 2 additions & 1 deletion lib/pleroma/object.ex
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ defmodule Pleroma.Object do
@spec cleanup_attachments(boolean(), Object.t()) ::
{:ok, Oban.Job.t() | nil}
def cleanup_attachments(true, %Object{} = object) do
AttachmentsCleanupWorker.enqueue("cleanup_attachments", %{"object" => object})
AttachmentsCleanupWorker.new(%{"op" => "cleanup_attachments", "object" => object})
|> Oban.insert()
end

def cleanup_attachments(_, _), do: {:ok, nil}
Expand Down
6 changes: 4 additions & 2 deletions lib/pleroma/search.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ defmodule Pleroma.Search do
alias Pleroma.Workers.SearchIndexingWorker

def add_to_index(%Pleroma.Activity{id: activity_id}) do
SearchIndexingWorker.enqueue("add_to_index", %{"activity" => activity_id})
SearchIndexingWorker.new(%{"op" => "add_to_index", "activity" => activity_id})
|> Oban.insert()
end

def remove_from_index(%Pleroma.Object{id: object_id}) do
SearchIndexingWorker.enqueue("remove_from_index", %{"object" => object_id})
SearchIndexingWorker.new(%{"op" => "remove_from_index", "object" => object_id})
|> Oban.insert()
end

def search(query, options) do
Expand Down
19 changes: 12 additions & 7 deletions lib/pleroma/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,8 @@ defmodule Pleroma.User do
end

def force_password_reset_async(user) do
BackgroundWorker.enqueue("force_password_reset", %{"user_id" => user.id})
BackgroundWorker.new(%{"op" => "force_password_reset", "user_id" => user.id})
|> Oban.insert()
end

@spec force_password_reset(User.t()) :: {:ok, User.t()} | {:error, Ecto.Changeset.t()}
Expand Down Expand Up @@ -1255,7 +1256,8 @@ defmodule Pleroma.User do
def update_and_set_cache(changeset) do
with {:ok, user} <- Repo.update(changeset, stale_error_field: :id) do
if get_change(changeset, :raw_fields) do
BackgroundWorker.enqueue("verify_fields_links", %{"user_id" => user.id})
BackgroundWorker.new(%{"op" => "verify_fields_links", "user_id" => user.id})
|> Oban.insert()
end

set_cache(user)
Expand Down Expand Up @@ -1633,11 +1635,11 @@ defmodule Pleroma.User do
)) ||
{:ok, nil} do
if duration > 0 do
Pleroma.Workers.MuteExpireWorker.enqueue(
"unmute_user",
%{"muter_id" => muter.id, "mutee_id" => mutee.id},
Pleroma.Workers.MuteExpireWorker.new(
%{"op" => "unmute_user", "muter_id" => muter.id, "mutee_id" => mutee.id},
scheduled_at: expires_at
)
|> Oban.insert()
end

@cachex.del(:user_cache, "muted_users_ap_ids:#{muter.ap_id}")
Expand Down Expand Up @@ -1880,7 +1882,8 @@ defmodule Pleroma.User do
defp maybe_filter_on_ap_id(query, _ap_ids), do: query

def set_activation_async(user, status \\ true) do
BackgroundWorker.enqueue("user_activation", %{"user_id" => user.id, "status" => status})
BackgroundWorker.new(%{"op" => "user_activation", "user_id" => user.id, "status" => status})
|> Oban.insert()
end

@spec set_activation([User.t()], boolean()) :: {:ok, User.t()} | {:error, Ecto.Changeset.t()}
Expand Down Expand Up @@ -2033,7 +2036,9 @@ defmodule Pleroma.User do
def delete(%User{} = user) do
# Purge the user immediately
purge(user)
DeleteWorker.enqueue("delete_user", %{"user_id" => user.id})

DeleteWorker.new(%{"op" => "delete_user", "user_id" => user.id})
|> Oban.insert()
end

# *Actually* delete the user from the DB
Expand Down
30 changes: 18 additions & 12 deletions lib/pleroma/user/import.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,29 @@ defmodule Pleroma.User.Import do
end

def blocks_import(%User{} = blocker, [_ | _] = identifiers) do
BackgroundWorker.enqueue(
"blocks_import",
%{"user_id" => blocker.id, "identifiers" => identifiers}
)
BackgroundWorker.new(%{
"op" => "blocks_import",
"user_id" => blocker.id,
"identifiers" => identifiers
})
|> Oban.insert()
end

def follow_import(%User{} = follower, [_ | _] = identifiers) do
BackgroundWorker.enqueue(
"follow_import",
%{"user_id" => follower.id, "identifiers" => identifiers}
)
BackgroundWorker.new(%{
"op" => "follow_import",
"user_id" => follower.id,
"identifiers" => identifiers
})
|> Oban.insert()
end

def mutes_import(%User{} = user, [_ | _] = identifiers) do
BackgroundWorker.enqueue(
"mutes_import",
%{"user_id" => user.id, "identifiers" => identifiers}
)
BackgroundWorker.new(%{
"op" => "mutes_import",
"user_id" => user.id,
"identifiers" => identifiers
})
|> Oban.insert()
end
end
18 changes: 12 additions & 6 deletions lib/pleroma/web/activity_pub/activity_pub.ex
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
%{data: %{"expires_at" => %DateTime{} = expires_at}} = activity
) do
with {:ok, _job} <-
Pleroma.Workers.PurgeExpiredActivity.enqueue(%{
activity_id: activity.id,
expires_at: expires_at
}) do
Pleroma.Workers.PurgeExpiredActivity.enqueue(
%{
activity_id: activity.id
},
scheduled_at: expires_at
) do
{:ok, activity}
end
end
Expand Down Expand Up @@ -467,10 +469,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
_ <- notify_and_stream(activity) do
maybe_federate(activity)

BackgroundWorker.enqueue("move_following", %{
BackgroundWorker.new(%{
"op" => "move_following",
"origin_id" => origin.id,
"target_id" => target.id
})
|> Oban.insert()

User.update_last_move_at(origin)

Expand Down Expand Up @@ -1882,10 +1886,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
# enqueue a task to fetch all pinned objects
Enum.each(pins, fn {ap_id, _} ->
if is_nil(Object.get_cached_by_ap_id(ap_id)) do
Pleroma.Workers.RemoteFetcherWorker.enqueue("fetch_remote", %{
Pleroma.Workers.RemoteFetcherWorker.new(%{
"op" => "fetch_remote",
"id" => ap_id,
"depth" => 1
})
|> Oban.insert()
end
end)
end
Expand Down
Loading

0 comments on commit 0a4fece

Please sign in to comment.