Fix follower count setting.
authorlain <lain@soykaf.club>
Sun, 18 Nov 2018 17:24:16 +0000 (18:24 +0100)
committerlain <lain@soykaf.club>
Sun, 18 Nov 2018 17:24:16 +0000 (18:24 +0100)
lib/pleroma/user.ex
lib/pleroma/user/info.ex

index b33ebb565120966535e088601461f0701b2c540f..5603d1f5f24f232dd0614c315d416fe1f883b577 100644 (file)
@@ -454,11 +454,13 @@ defmodule Pleroma.User do
 
     follower_count = Repo.one(follower_count_query)
 
-    new_info = Map.put(user.info, "follower_count", follower_count)
+    info_cng = user.info
+    |> User.Info.set_follower_count(follower_count)
 
-    cs = info_changeset(user, %{info: new_info})
+    cng = change(user)
+    |> put_embed(:info, info_cng)
 
-    update_and_set_cache(cs)
+    update_and_set_cache(cng)
   end
 
   def get_users_from_set_query(ap_ids, false) do
index 465a14d9141c361ad521f686392e6bcd673a3f24..49b52d5daf4ad41859f7166da3d6ff54541d6f27 100644 (file)
@@ -32,4 +32,12 @@ defmodule Pleroma.User.Info do
     |> cast(params, [:note_count])
     |> validate_required([:note_count])
   end
+
+  def set_follower_count(info, number) do
+    params = %{follower_count: Enum.max([0, number])}
+
+    info
+    |> cast(params, [:follower_count])
+    |> validate_required([:follower_count])
+  end
 end