mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 00:53:52 +01:00
Merge branch 'erikj/fix_sqlite_7' of github.com:matrix-org/synapse into release-v1.7.0
This commit is contained in:
commit
d21577bdcb
8 changed files with 51 additions and 14 deletions
1
changelog.d/6497.bugfix
Normal file
1
changelog.d/6497.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix error message when setting your profile's avatar URL mentioning displaynames, and prevent NoneType avatar_urls.
|
1
changelog.d/6499.bugfix
Normal file
1
changelog.d/6499.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix support for SQLite 3.7.
|
|
@ -103,11 +103,16 @@ class ProfileAvatarURLRestServlet(RestServlet):
|
||||||
|
|
||||||
content = parse_json_object_from_request(request)
|
content = parse_json_object_from_request(request)
|
||||||
try:
|
try:
|
||||||
new_name = content["avatar_url"]
|
new_avatar_url = content.get("avatar_url")
|
||||||
except Exception:
|
except Exception:
|
||||||
return 400, "Unable to parse name"
|
return 400, "Unable to parse avatar_url"
|
||||||
|
|
||||||
await self.profile_handler.set_avatar_url(user, requester, new_name, is_admin)
|
if new_avatar_url is None:
|
||||||
|
return 400, "Missing required key: avatar_url"
|
||||||
|
|
||||||
|
await self.profile_handler.set_avatar_url(
|
||||||
|
user, requester, new_avatar_url, is_admin
|
||||||
|
)
|
||||||
|
|
||||||
return 200, {}
|
return 200, {}
|
||||||
|
|
||||||
|
|
|
@ -1039,20 +1039,25 @@ class EventsStore(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
async def _censor_redactions(self):
|
||||||
def _censor_redactions(self):
|
|
||||||
"""Censors all redactions older than the configured period that haven't
|
"""Censors all redactions older than the configured period that haven't
|
||||||
been censored yet.
|
been censored yet.
|
||||||
|
|
||||||
By censor we mean update the event_json table with the redacted event.
|
By censor we mean update the event_json table with the redacted event.
|
||||||
|
|
||||||
Returns:
|
|
||||||
Deferred
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.hs.config.redaction_retention_period is None:
|
if self.hs.config.redaction_retention_period is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not (
|
||||||
|
await self.db.updates.has_completed_background_update(
|
||||||
|
"redactions_have_censored_ts_idx"
|
||||||
|
)
|
||||||
|
):
|
||||||
|
# We don't want to run this until the appropriate index has been
|
||||||
|
# created.
|
||||||
|
return
|
||||||
|
|
||||||
before_ts = self._clock.time_msec() - self.hs.config.redaction_retention_period
|
before_ts = self._clock.time_msec() - self.hs.config.redaction_retention_period
|
||||||
|
|
||||||
# We fetch all redactions that:
|
# We fetch all redactions that:
|
||||||
|
@ -1074,15 +1079,15 @@ class EventsStore(
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
"""
|
"""
|
||||||
|
|
||||||
rows = yield self.db.execute(
|
rows = await self.db.execute(
|
||||||
"_censor_redactions_fetch", None, sql, before_ts, 100
|
"_censor_redactions_fetch", None, sql, before_ts, 100
|
||||||
)
|
)
|
||||||
|
|
||||||
updates = []
|
updates = []
|
||||||
|
|
||||||
for redaction_id, event_id in rows:
|
for redaction_id, event_id in rows:
|
||||||
redaction_event = yield self.get_event(redaction_id, allow_none=True)
|
redaction_event = await self.get_event(redaction_id, allow_none=True)
|
||||||
original_event = yield self.get_event(
|
original_event = await self.get_event(
|
||||||
event_id, allow_rejected=True, allow_none=True
|
event_id, allow_rejected=True, allow_none=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1115,7 +1120,7 @@ class EventsStore(
|
||||||
updatevalues={"have_censored": True},
|
updatevalues={"have_censored": True},
|
||||||
)
|
)
|
||||||
|
|
||||||
yield self.db.runInteraction("_update_censor_txn", _update_censor_txn)
|
await self.db.runInteraction("_update_censor_txn", _update_censor_txn)
|
||||||
|
|
||||||
def _censor_event_txn(self, txn, event_id, pruned_json):
|
def _censor_event_txn(self, txn, event_id, pruned_json):
|
||||||
"""Censor an event by replacing its JSON in the event_json table with the
|
"""Censor an event by replacing its JSON in the event_json table with the
|
||||||
|
|
|
@ -90,6 +90,14 @@ class EventsBackgroundUpdatesStore(SQLBaseStore):
|
||||||
"event_store_labels", self._event_store_labels
|
"event_store_labels", self._event_store_labels
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.db.updates.register_background_index_update(
|
||||||
|
"redactions_have_censored_ts_idx",
|
||||||
|
index_name="redactions_have_censored_ts",
|
||||||
|
table="redactions",
|
||||||
|
columns=["received_ts"],
|
||||||
|
where_clause="NOT have_censored",
|
||||||
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _background_reindex_fields_sender(self, progress, batch_size):
|
def _background_reindex_fields_sender(self, progress, batch_size):
|
||||||
target_min_stream_id = progress["target_min_stream_id_inclusive"]
|
target_min_stream_id = progress["target_min_stream_id_inclusive"]
|
||||||
|
|
|
@ -14,4 +14,3 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ALTER TABLE redactions ADD COLUMN have_censored BOOL NOT NULL DEFAULT false;
|
ALTER TABLE redactions ADD COLUMN have_censored BOOL NOT NULL DEFAULT false;
|
||||||
CREATE INDEX redactions_have_censored ON redactions(event_id) WHERE not have_censored;
|
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ALTER TABLE redactions ADD COLUMN received_ts BIGINT;
|
ALTER TABLE redactions ADD COLUMN received_ts BIGINT;
|
||||||
CREATE INDEX redactions_have_censored_ts ON redactions(received_ts) WHERE not have_censored;
|
|
||||||
|
|
||||||
INSERT INTO background_updates (update_name, progress_json) VALUES
|
INSERT INTO background_updates (update_name, progress_json) VALUES
|
||||||
('redactions_received_ts', '{}');
|
('redactions_received_ts', '{}');
|
||||||
|
|
||||||
|
INSERT INTO background_updates (update_name, progress_json) VALUES
|
||||||
|
('redactions_have_censored_ts_idx', '{}');
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
/* Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
DROP INDEX IF EXISTS redactions_have_censored;
|
Loading…
Reference in a new issue