refactor: remove some outdated todos and legacy fallbacks

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2024-01-04 12:55:47 +01:00
parent f7585cfc75
commit 428537df1f
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
7 changed files with 9 additions and 26 deletions

View file

@ -1163,14 +1163,10 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
end end
end end
# Before 1.0.4 the object of a "Remove" activity was an actor's URL
# instead of the member's URL.
# TODO: Remove in 1.2
@spec get_remove_object(map() | String.t()) :: {:ok, integer()} @spec get_remove_object(map() | String.t()) :: {:ok, integer()}
defp get_remove_object(object) do defp get_remove_object(object) do
case object |> Utils.get_url() |> ActivityPub.fetch_object_from_url() do case object |> Utils.get_url() |> ActivityPub.fetch_object_from_url() do
{:ok, %Member{actor: %Actor{id: person_id}}} -> {:ok, person_id} {:ok, %Member{actor: %Actor{id: person_id}}} -> {:ok, person_id}
{:ok, %Actor{id: person_id}} -> {:ok, person_id}
_ -> {:error, :remove_object_not_found} _ -> {:error, :remove_object_not_found}
end end
end end

View file

@ -76,14 +76,13 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Actor do
def as_to_model_data(_), do: {:error, :actor_not_allowed_type} def as_to_model_data(_), do: {:error, :actor_not_allowed_type}
defp add_endpoints_to_model(actor, data) do defp add_endpoints_to_model(actor, data) do
# TODO: Remove fallbacks in 3.0
endpoints = %{ endpoints = %{
members_url: get_in(data, ["endpoints", "members"]) || data["members"], members_url: get_in(data, ["endpoints", "members"]),
resources_url: get_in(data, ["endpoints", "resources"]) || data["resources"], resources_url: get_in(data, ["endpoints", "resources"]),
todos_url: get_in(data, ["endpoints", "todos"]) || data["todos"], todos_url: get_in(data, ["endpoints", "todos"]),
events_url: get_in(data, ["endpoints", "events"]) || data["events"], events_url: get_in(data, ["endpoints", "events"]),
posts_url: get_in(data, ["endpoints", "posts"]) || data["posts"], posts_url: get_in(data, ["endpoints", "posts"]),
discussions_url: get_in(data, ["endpoints", "discussions"]) || data["discussions"], discussions_url: get_in(data, ["endpoints", "discussions"]),
shared_inbox_url: data["endpoints"]["sharedInbox"] shared_inbox_url: data["endpoints"]["sharedInbox"]
} }

View file

@ -77,7 +77,7 @@ defmodule Mobilizon.Discussions do
|> join(:left, [c], r in Comment, on: r.origin_comment_id == c.id) |> join(:left, [c], r in Comment, on: r.origin_comment_id == c.id)
|> where([c, _], is_nil(c.in_reply_to_comment_id)) |> where([c, _], is_nil(c.in_reply_to_comment_id))
|> where([c], c.visibility in ^@public_visibility) |> where([c], c.visibility in ^@public_visibility)
# TODO: This was added because we don't want to count deleted comments in total_replies. # This was added because we don't want to count deleted comments in total_replies.
# However, it also excludes all top-level comments with deleted replies from being selected # However, it also excludes all top-level comments with deleted replies from being selected
# |> where([_, r], is_nil(r.deleted_at)) # |> where([_, r], is_nil(r.deleted_at))
|> group_by([c], c.id) |> group_by([c], c.id)

View file

@ -11,9 +11,7 @@ defmodule Mobilizon.Service.RichMedia.Parser do
max_body: 2_000_000, max_body: 2_000_000,
timeout: 10_000, timeout: 10_000,
recv_timeout: 20_000, recv_timeout: 20_000,
follow_redirect: true, follow_redirect: true
# TODO: Remove me once Hackney/HTTPoison fixes their issue with TLS1.3 and OTP 23
ssl: [{:versions, [:"tlsv1.2"]}]
] ]
alias Mobilizon.Config alias Mobilizon.Config

View file

@ -87,8 +87,6 @@ defmodule Mobilizon.Web.Email.Group do
end end
end end
# TODO : def send_confirmation_to_inviter()
@member_roles [:administrator, :moderator, :member] @member_roles [:administrator, :moderator, :member]
@spec send_group_suspension_notification(Member.t()) :: :ok @spec send_group_suspension_notification(Member.t()) :: :ok
def send_group_suspension_notification(%Member{actor: %Actor{user_id: nil}}), do: :ok def send_group_suspension_notification(%Member{actor: %Actor{user_id: nil}}), do: :ok

View file

@ -124,6 +124,4 @@ defmodule Mobilizon.Web.Email.Member do
:ok :ok
end end
end end
# TODO : def send_confirmation_to_inviter()
end end

View file

@ -71,13 +71,7 @@ defmodule Mobilizon.Web.MediaProxy do
@compile {:no_warn_undefined, {:crypto, :mac, 4}} @compile {:no_warn_undefined, {:crypto, :mac, 4}}
@compile {:no_warn_undefined, {:crypto, :hmac, 3}} @compile {:no_warn_undefined, {:crypto, :hmac, 3}}
defp sha_hmac(key, url) do defp sha_hmac(key, url) do
# :crypto.hmac was removed in OTP24, but :crypto.mac was added in OTP 22.1 :crypto.mac(:hmac, :sha, key, url)
# TODO: Remove me when we don't support OTP 21/22 anymore
if function_exported?(:crypto, :mac, 4) do
:crypto.mac(:hmac, :sha, key, url)
else
:crypto.hmac(:sha, key, url)
end
end end
@spec filename(String.t()) :: String.t() | nil @spec filename(String.t()) :: String.t() | nil