Fix a migration wiping user info of users that don't have any mutes
And introduce safe_jsonb_set
This commit is contained in:
parent
c00797d08e
commit
a1c4a5d7cf
6 changed files with 31 additions and 9 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue