aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mix/tasks/rm_user.ex2
-rw-r--r--lib/pleroma/application.ex30
-rw-r--r--lib/pleroma/object.ex6
-rw-r--r--lib/pleroma/user.ex3
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex2
5 files changed, 30 insertions, 13 deletions
diff --git a/lib/mix/tasks/rm_user.ex b/lib/mix/tasks/rm_user.ex
index 27521b745..b7c922d6c 100644
--- a/lib/mix/tasks/rm_user.ex
+++ b/lib/mix/tasks/rm_user.ex
@@ -7,7 +7,7 @@ defmodule Mix.Tasks.RmUser do
Mix.Task.run("app.start")
with %User{local: true} = user <- User.get_by_nickname(nickname) do
- User.delete(user)
+ {:ok, _} = User.delete(user)
end
end
end
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index a89728471..a6b921b45 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -16,14 +16,30 @@ defmodule Pleroma.Application do
supervisor(Pleroma.Web.Endpoint, []),
# Start your own worker by calling: Pleroma.Worker.start_link(arg1, arg2, arg3)
# worker(Pleroma.Worker, [arg1, arg2, arg3]),
- worker(Cachex, [
- :user_cache,
+ worker(
+ Cachex,
[
- default_ttl: 25000,
- ttl_interval: 1000,
- limit: 2500
- ]
- ]),
+ :user_cache,
+ [
+ default_ttl: 25000,
+ ttl_interval: 1000,
+ limit: 2500
+ ]
+ ],
+ id: :cachex_user
+ ),
+ worker(
+ Cachex,
+ [
+ :object_cache,
+ [
+ default_ttl: 25000,
+ ttl_interval: 1000,
+ limit: 2500
+ ]
+ ],
+ id: :cachex_object
+ ),
worker(
Cachex,
[
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex
index 8f96fd8fb..067ecfaf4 100644
--- a/lib/pleroma/object.ex
+++ b/lib/pleroma/object.ex
@@ -37,7 +37,7 @@ defmodule Pleroma.Object do
else
key = "object:#{ap_id}"
- Cachex.fetch!(:user_cache, key, fn _ ->
+ Cachex.fetch!(:object_cache, key, fn _ ->
object = get_by_ap_id(ap_id)
if object do
@@ -56,8 +56,8 @@ defmodule Pleroma.Object do
def delete(%Object{data: %{"id" => id}} = object) do
with Repo.delete(object),
Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)),
- {:ok, true} <- Cachex.del(:user_cache, "object:#{id}") do
- :ok
+ {:ok, true} <- Cachex.del(:object_cache, "object:#{id}") do
+ {:ok, object}
end
end
end
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index bb5b91c61..b2f59ab6b 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -295,6 +295,7 @@ defmodule Pleroma.User do
def invalidate_cache(user) do
Cachex.del(:user_cache, "ap_id:#{user.ap_id}")
Cachex.del(:user_cache, "nickname:#{user.nickname}")
+ Cachex.del(:user_cache, "user_info:#{user.id}")
end
def get_cached_by_ap_id(ap_id) do
@@ -656,7 +657,7 @@ defmodule Pleroma.User do
end
end)
- :ok
+ {:ok, user}
end
def html_filter_policy(%User{info: %{"no_rich_text" => true}}) do
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 48ae36ebd..32c14995f 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -273,7 +273,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
"to" => [user.follower_address, "https://www.w3.org/ns/activitystreams#Public"]
}
- with Object.delete(object),
+ with {:ok, _} <- Object.delete(object),
{:ok, activity} <- insert(data, local),
:ok <- maybe_federate(activity),
{:ok, _actor} <- User.decrease_note_count(user) do