summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-10-18 11:49:27 +0000
committerrinpatch <rinpatch@sdf.org>2019-10-18 11:49:27 +0000
commitdeee9f31968c48fb15b4d6b93254d28232e54a69 (patch)
treed53c7d132a53d2b510c5ac6403fb7cbdb1cf79d6 /lib
parentc00797d08ef3e6c57250c9f013b6f912292b031b (diff)
parent41c47639e3eae5d5e2840e9a9bb51cd99660af91 (diff)
downloadpleroma-deee9f31968c48fb15b4d6b93254d28232e54a69.tar.gz
pleroma-deee9f31968c48fb15b4d6b93254d28232e54a69.zip
Merge branch 'bugfix/jsonb-set-fuckup' into 'release/1.1.1'
Fix a migration wiping user info of users that don't have any mutes See merge request pleroma/pleroma!1856
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
-rw-r--r--lib/pleroma/web/activity_pub/utils.ex2
4 files changed, 8 insertions, 8 deletions
diff --git a/lib/mix/tasks/pleroma/database.ex b/lib/mix/tasks/pleroma/database.ex
index bcc2052d6..ab7529e08 100644
--- a/lib/mix/tasks/pleroma/database.ex
+++ b/lib/mix/tasks/pleroma/database.ex
@@ -54,7 +54,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
)
@@ -152,7 +152,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 3fa407931..bf37b28a7 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 617f160e0..f0912fb10 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -718,7 +718,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
)
@@ -739,7 +739,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
)
@@ -812,7 +812,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
)
diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex
index 39a532db3..f22cc2367 100644
--- a/lib/pleroma/web/activity_pub/utils.ex
+++ b/lib/pleroma/web/activity_pub/utils.ex
@@ -349,7 +349,7 @@ defmodule Pleroma.Web.ActivityPub.Utils do
try do
Ecto.Adapters.SQL.query!(
Repo,
- "UPDATE activities SET data = jsonb_set(data, '{state}', $1) WHERE data->>'type' = 'Follow' AND data->>'actor' = $2 AND data->>'object' = $3 AND data->>'state' = 'pending'",
+ "UPDATE activities SET data = safe_jsonb_set(data, '{state}', $1) WHERE data->>'type' = 'Follow' AND data->>'actor' = $2 AND data->>'object' = $3 AND data->>'state' = 'pending'",
[state, actor, object]
)