Avoid using actor id from config cache
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
c0d8b2d39a
commit
a18c4daf4c
@ -4,9 +4,9 @@ defmodule Mobilizon.GraphQL.Resolvers.Event.Utils do
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
alias Mobilizon.Actors.Actor
|
alias Mobilizon.Actors.Actor
|
||||||
alias Mobilizon.{Config, Events}
|
alias Mobilizon.Events
|
||||||
alias Mobilizon.Events.Event
|
alias Mobilizon.Events.Event
|
||||||
alias Mobilizon.Federation.ActivityPub.Permission
|
alias Mobilizon.Federation.ActivityPub.{Permission, Relay}
|
||||||
import Mobilizon.Service.Guards, only: [is_valid_string: 1]
|
import Mobilizon.Service.Guards, only: [is_valid_string: 1]
|
||||||
|
|
||||||
@spec can_event_be_updated_by?(Event.t(), Actor.t()) ::
|
@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{local: true}), do: true
|
||||||
|
|
||||||
def check_event_access?(%Event{url: url}) do
|
def check_event_access?(%Event{url: url}) do
|
||||||
relay_actor_id = Config.relay_actor_id()
|
relay_actor = Relay.get_actor()
|
||||||
Events.check_if_event_has_instance_follow(url, relay_actor_id)
|
Events.check_if_event_has_instance_follow(url, relay_actor.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -322,8 +322,6 @@ defmodule Mobilizon.Config do
|
|||||||
|
|
||||||
@spec anonymous_actor_id :: integer
|
@spec anonymous_actor_id :: integer
|
||||||
def anonymous_actor_id, do: get_cached_value(:anonymous_actor_id)
|
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
|
@spec admin_settings :: map
|
||||||
def admin_settings, do: get_cached_value(:admin_config)
|
def admin_settings, do: get_cached_value(:admin_config)
|
||||||
|
|
||||||
@ -401,16 +399,6 @@ defmodule Mobilizon.Config do
|
|||||||
end
|
end
|
||||||
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
|
defp create_cache(:admin_config) do
|
||||||
data = %{
|
data = %{
|
||||||
instance_description: instance_description(),
|
instance_description: instance_description(),
|
||||||
|
@ -28,6 +28,7 @@ defmodule Mobilizon.Events do
|
|||||||
Track
|
Track
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alias Mobilizon.Federation.ActivityPub.Relay
|
||||||
alias Mobilizon.Service.Export.Cachable
|
alias Mobilizon.Service.Export.Cachable
|
||||||
alias Mobilizon.Service.Workers.BuildSearch
|
alias Mobilizon.Service.Workers.BuildSearch
|
||||||
alias Mobilizon.Service.Workers.EventDelayedNotificationWorker
|
alias Mobilizon.Service.Workers.EventDelayedNotificationWorker
|
||||||
@ -1676,7 +1677,7 @@ defmodule Mobilizon.Events do
|
|||||||
@spec filter_local_or_from_followed_instances_events(Ecto.Queryable.t()) ::
|
@spec filter_local_or_from_followed_instances_events(Ecto.Queryable.t()) ::
|
||||||
Ecto.Query.t()
|
Ecto.Query.t()
|
||||||
defp filter_local_or_from_followed_instances_events(query) do
|
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
|
query
|
||||||
|> join(:left, [q], s in Share, on: s.uri == q.url)
|
|> join(:left, [q], s in Share, on: s.uri == q.url)
|
||||||
|
Loading…
Reference in New Issue
Block a user