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

Remove uses of events.content #3060

Merged
merged 1 commit into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions synapse/storage/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,8 @@ def _get_media_mxcs_in_room_txn(self, txn, room_id):

while next_token:
sql = """
SELECT stream_ordering, content FROM events
SELECT stream_ordering, json FROM events
JOIN event_json USING (event_id)
WHERE room_id = ?
AND stream_ordering < ?
AND contains_url = ? AND outlier = ?
Expand All @@ -606,8 +607,8 @@ def _get_media_mxcs_in_room_txn(self, txn, room_id):
next_token = None
for stream_ordering, content_json in txn:
next_token = stream_ordering
content = json.loads(content_json)

event_json = json.loads(content_json)
content = event_json["content"]
content_url = content.get("url")
thumbnail_url = content.get("info", {}).get("thumbnail_url")

Expand Down
6 changes: 4 additions & 2 deletions synapse/storage/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,9 @@ def _background_add_membership_profile(self, progress, batch_size):

def add_membership_profile_txn(txn):
sql = ("""
SELECT stream_ordering, event_id, events.room_id, content
SELECT stream_ordering, event_id, events.room_id, event_json.json
FROM events
INNER JOIN event_json USING (event_id)
INNER JOIN room_memberships USING (event_id)
WHERE ? <= stream_ordering AND stream_ordering < ?
AND type = 'm.room.member'
Expand All @@ -667,7 +668,8 @@ def add_membership_profile_txn(txn):
event_id = row["event_id"]
room_id = row["room_id"]
try:
content = json.loads(row["content"])
event_json = json.loads(row["json"])
content = event_json['content']
except Exception:
continue

Expand Down
6 changes: 4 additions & 2 deletions synapse/storage/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ def _background_reindex_search(self, progress, batch_size):

def reindex_search_txn(txn):
sql = (
"SELECT stream_ordering, event_id, room_id, type, content, "
"SELECT stream_ordering, event_id, room_id, type, json, "
" origin_server_ts FROM events"
" JOIN event_json USING (event_id)"
" WHERE ? <= stream_ordering AND stream_ordering < ?"
" AND (%s)"
" ORDER BY stream_ordering DESC"
Expand Down Expand Up @@ -104,7 +105,8 @@ def reindex_search_txn(txn):
stream_ordering = row["stream_ordering"]
origin_server_ts = row["origin_server_ts"]
try:
content = json.loads(row["content"])
event_json = json.loads(row["json"])
content = event_json["content"]
except Exception:
continue

Expand Down