aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-10-18 14:11:30 +0300
committerrinpatch <rinpatch@sdf.org>2019-10-18 15:22:07 +0300
commit39e996528c1e7551675c0d0f140dcfa01e671004 (patch)
tree43c5c7a77cdf1dd5b14246896948b306c70f5500 /lib
parent724f611b0edf3d7fd819ee748df2f6b00d211fa2 (diff)
downloadpleroma-39e996528c1e7551675c0d0f140dcfa01e671004.tar.gz
Fix a migration wiping user info of users that don't have any mutes
And introduce safe_jsonb_set
Diffstat (limited to 'lib')
-rw-r--r--lib/mix/tasks/pleroma/database.ex4
-rw-r--r--lib/pleroma/object.ex4
-rw-r--r--lib/pleroma/user.ex6
3 files changed, 7 insertions, 7 deletions
diff --git a/lib/mix/tasks/pleroma/database.ex b/lib/mix/tasks/pleroma/database.ex
index cfd9eeada..8a827ca80 100644
--- a/lib/mix/tasks/pleroma/database.ex
+++ b/lib/mix/tasks/pleroma/database.ex
@@ -28,7 +28,7 @@ defmodule Mix.Tasks.Pleroma.Database do
Logger.info("Removing embedded objects")
Repo.query!(
- "update activities set data = jsonb_set(data, '{object}'::text[], data->'object'->'id') where data->'object'->>'id' is not null;",
+ "update activities set data = safe_jsonb_set(data, '{object}'::text[], data->'object'->'id') where data->'object'->>'id' is not null;",
[],
timeout: :infinity
)
@@ -126,7 +126,7 @@ defmodule Mix.Tasks.Pleroma.Database do
set: [
data:
fragment(
- "jsonb_set(?, '{likes}', '[]'::jsonb, true)",
+ "safe_jsonb_set(?, '{likes}', '[]'::jsonb, true)",
object.data
)
]
diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex
index cdfbacb0e..d9b41d710 100644
--- a/lib/pleroma/object.ex
+++ b/lib/pleroma/object.ex
@@ -181,7 +181,7 @@ defmodule Pleroma.Object do
data:
fragment(
"""
- jsonb_set(?, '{repliesCount}',
+ safe_jsonb_set(?, '{repliesCount}',
(coalesce((?->>'repliesCount')::int, 0) + 1)::varchar::jsonb, true)
""",
o.data,
@@ -204,7 +204,7 @@ defmodule Pleroma.Object do
data:
fragment(
"""
- jsonb_set(?, '{repliesCount}',
+ safe_jsonb_set(?, '{repliesCount}',
(greatest(0, (?->>'repliesCount')::int - 1))::varchar::jsonb, true)
""",
o.data,
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index 917bcf2ef..d0d3e1f9a 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -727,7 +727,7 @@ defmodule Pleroma.User do
set: [
info:
fragment(
- "jsonb_set(?, '{note_count}', ((?->>'note_count')::int + 1)::varchar::jsonb, true)",
+ "safe_jsonb_set(?, '{note_count}', ((?->>'note_count')::int + 1)::varchar::jsonb, true)",
u.info,
u.info
)
@@ -748,7 +748,7 @@ defmodule Pleroma.User do
set: [
info:
fragment(
- "jsonb_set(?, '{note_count}', (greatest(0, (?->>'note_count')::int - 1))::varchar::jsonb, true)",
+ "safe_jsonb_set(?, '{note_count}', (greatest(0, (?->>'note_count')::int - 1))::varchar::jsonb, true)",
u.info,
u.info
)
@@ -818,7 +818,7 @@ defmodule Pleroma.User do
set: [
info:
fragment(
- "jsonb_set(?, '{follower_count}', ?::varchar::jsonb, true)",
+ "safe_jsonb_set(?, '{follower_count}', ?::varchar::jsonb, true)",
u.info,
s.count
)