Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Remove unnecessary JSON whitespace stored for groups
Browse files Browse the repository at this point in the history
  • Loading branch information
auscompgeek committed Jul 22, 2020
1 parent c6ceb38 commit 4c5a0d5
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions synapse/storage/data_stores/main/group_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

from typing import List, Tuple

from canonicaljson import json

from twisted.internet import defer

from synapse.api.errors import SynapseError
from synapse.storage._base import SQLBaseStore, db_to_json
from synapse.util import json_encoder

# The category ID for the "default" category. We don't store as null in the
# database to avoid the fun of null != null
Expand Down Expand Up @@ -750,7 +749,7 @@ def upsert_group_category(self, group_id, category_id, profile, is_public):
if profile is None:
insertion_values["profile"] = "{}"
else:
update_values["profile"] = json.dumps(profile)
update_values["profile"] = json_encoder.encode(profile)

if is_public is None:
insertion_values["is_public"] = True
Expand Down Expand Up @@ -781,7 +780,7 @@ def upsert_group_role(self, group_id, role_id, profile, is_public):
if profile is None:
insertion_values["profile"] = "{}"
else:
update_values["profile"] = json.dumps(profile)
update_values["profile"] = json_encoder.encode(profile)

if is_public is None:
insertion_values["is_public"] = True
Expand Down Expand Up @@ -1005,7 +1004,7 @@ def _add_user_to_group_txn(txn):
"group_id": group_id,
"user_id": user_id,
"valid_until_ms": remote_attestation["valid_until_ms"],
"attestation_json": json.dumps(remote_attestation),
"attestation_json": json_encoder.encode(remote_attestation),
},
)

Expand Down Expand Up @@ -1129,7 +1128,7 @@ def _register_user_group_membership_txn(txn, next_id):
"is_admin": is_admin,
"membership": membership,
"is_publicised": is_publicised,
"content": json.dumps(content),
"content": json_encoder.encode(content),
},
)

Expand All @@ -1141,7 +1140,7 @@ def _register_user_group_membership_txn(txn, next_id):
"group_id": group_id,
"user_id": user_id,
"type": "membership",
"content": json.dumps(
"content": json_encoder.encode(
{"membership": membership, "content": content}
),
},
Expand Down Expand Up @@ -1169,7 +1168,7 @@ def _register_user_group_membership_txn(txn, next_id):
"group_id": group_id,
"user_id": user_id,
"valid_until_ms": remote_attestation["valid_until_ms"],
"attestation_json": json.dumps(remote_attestation),
"attestation_json": json_encoder.encode(remote_attestation),
},
)
else:
Expand Down Expand Up @@ -1238,7 +1237,7 @@ def update_remote_attestion(self, group_id, user_id, attestation):
keyvalues={"group_id": group_id, "user_id": user_id},
updatevalues={
"valid_until_ms": attestation["valid_until_ms"],
"attestation_json": json.dumps(attestation),
"attestation_json": json_encoder.encode(attestation),
},
desc="update_remote_attestion",
)
Expand Down

0 comments on commit 4c5a0d5

Please sign in to comment.