Merge branch 'feature/1482-activity_pub_transactions' into 'develop'

ActivityPub actions & side-effects in transaction

Closes #1482

See merge request pleroma/pleroma!2089
This commit is contained in:
Haelwenn 2020-03-02 07:58:01 +00:00
commit 764a50f8a6
8 changed files with 392 additions and 64 deletions

View file

@ -749,9 +749,18 @@ defmodule Pleroma.User do
Cachex.del(:user_cache, "nickname:#{user.nickname}")
end
@spec get_cached_by_ap_id(String.t()) :: User.t() | nil
def get_cached_by_ap_id(ap_id) do
key = "ap_id:#{ap_id}"
Cachex.fetch!(:user_cache, key, fn _ -> get_by_ap_id(ap_id) end)
with {:ok, nil} <- Cachex.get(:user_cache, key),
user when not is_nil(user) <- get_by_ap_id(ap_id),
{:ok, true} <- Cachex.put(:user_cache, key, user) do
user
else
{:ok, user} -> user
nil -> nil
end
end
def get_cached_by_id(id) do