Avoid using actor id from config cache

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
chapril
Thomas Citharel 7 months ago
parent c0d8b2d39a
commit a18c4daf4c
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
  1. 8
      lib/graphql/resolvers/event/utils.ex
  2. 12
      lib/mobilizon/config.ex
  3. 3
      lib/mobilizon/events/events.ex

@ -4,9 +4,9 @@ defmodule Mobilizon.GraphQL.Resolvers.Event.Utils do
"""
alias Mobilizon.Actors.Actor
alias Mobilizon.{Config, Events}
alias Mobilizon.Events
alias Mobilizon.Events.Event
alias Mobilizon.Federation.ActivityPub.Permission
alias Mobilizon.Federation.ActivityPub.{Permission, Relay}
import Mobilizon.Service.Guards, only: [is_valid_string: 1]
@spec can_event_be_updated_by?(Event.t(), Actor.t()) ::
@ -43,7 +43,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event.Utils do
def check_event_access?(%Event{local: true}), do: true
def check_event_access?(%Event{url: url}) do
relay_actor_id = Config.relay_actor_id()
Events.check_if_event_has_instance_follow(url, relay_actor_id)
relay_actor = Relay.get_actor()
Events.check_if_event_has_instance_follow(url, relay_actor.id)
end
end

@ -322,8 +322,6 @@ defmodule Mobilizon.Config do
@spec anonymous_actor_id :: integer
def anonymous_actor_id, do: get_cached_value(:anonymous_actor_id)
@spec relay_actor_id :: integer
def relay_actor_id, do: get_cached_value(:relay_actor_id)
@spec admin_settings :: map
def admin_settings, do: get_cached_value(:admin_config)
@ -401,16 +399,6 @@ defmodule Mobilizon.Config do
end
end
defp create_cache(:relay_actor_id) do
case Actors.get_or_create_internal_actor("relay") do
{:ok, %{id: actor_id}} ->
{:ok, actor_id}
{:error, err} ->
{:error, err}
end
end
defp create_cache(:admin_config) do
data = %{
instance_description: instance_description(),

@ -28,6 +28,7 @@ defmodule Mobilizon.Events do
Track
}
alias Mobilizon.Federation.ActivityPub.Relay
alias Mobilizon.Service.Export.Cachable
alias Mobilizon.Service.Workers.BuildSearch
alias Mobilizon.Service.Workers.EventDelayedNotificationWorker
@ -1676,7 +1677,7 @@ defmodule Mobilizon.Events do
@spec filter_local_or_from_followed_instances_events(Ecto.Queryable.t()) ::
Ecto.Query.t()
defp filter_local_or_from_followed_instances_events(query) do
follower_actor_id = Mobilizon.Config.relay_actor_id()
%Actor{id: follower_actor_id} = Relay.get_actor()
query
|> join(:left, [q], s in Share, on: s.uri == q.url)

Loading…
Cancel
Save