From 4a1b749582d00bb9c24a12a46d756b0e1dca72d3 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Wed, 12 Jun 2019 16:36:28 +0100 Subject: Lint --- synapse/rest/client/v1/profile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/synapse/rest/client/v1/profile.py b/synapse/rest/client/v1/profile.py index 202a9f21ad..064bcddaeb 100644 --- a/synapse/rest/client/v1/profile.py +++ b/synapse/rest/client/v1/profile.py @@ -22,7 +22,6 @@ from synapse.http.servlet import RestServlet, parse_json_object_from_request from synapse.rest.client.v2_alpha._base import client_patterns from synapse.types import UserID - logger = logging.getLogger(__name__) -- cgit 1.4.1 From 5283f653165a5479558926286cd25c6c4319abf2 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Wed, 12 Jun 2019 16:38:00 +0100 Subject: Fix bogus changelog --- changelog.d/5083.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/5083.feature b/changelog.d/5083.feature index f6014c6b43..2ffdd37eef 100644 --- a/changelog.d/5083.feature +++ b/changelog.d/5083.feature @@ -1 +1 @@ -Adds auth_profile_reqs option to require access_token to GET /profile endpoints on CS API +Adds auth_profile_reqs option to require access_token to GET /profile endpoints on CS API. -- cgit 1.4.1 From 26a27e06b960e30e2f4f0a5054ffdacc848150c9 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Thu, 13 Jun 2019 15:57:55 +0100 Subject: Create the index in a background update --- synapse/storage/profile.py | 15 +++++++++++++-- .../delta/54/profile_replication_status_index.sql | 16 ---------------- .../delta/55/profile_replication_status_index.sql | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 18 deletions(-) delete mode 100644 synapse/storage/schema/delta/54/profile_replication_status_index.sql create mode 100644 synapse/storage/schema/delta/55/profile_replication_status_index.sql diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index 04908cbc35..919b1f1641 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -19,12 +19,12 @@ from twisted.internet import defer from synapse.api.errors import StoreError from synapse.storage.roommember import ProfileInfo -from ._base import SQLBaseStore +from . import background_updates BATCH_SIZE = 100 -class ProfileWorkerStore(SQLBaseStore): +class ProfileWorkerStore(background_updates.BackgroundUpdateStore): @defer.inlineCallbacks def get_profileinfo(self, user_localpart): try: @@ -166,6 +166,17 @@ class ProfileWorkerStore(SQLBaseStore): class ProfileStore(ProfileWorkerStore): + def __init__(self, db_conn, hs): + + super(ProfileStore, self).__init__(db_conn, hs) + + self.register_background_index_update( + "profile_replication_status_host_index", + index_name="profile_replication_status_idx", + table="profile_replication_status", + columns=["host"], + ) + def add_remote_profile_cache(self, user_id, displayname, avatar_url): """Ensure we are caching the remote user's profiles. diff --git a/synapse/storage/schema/delta/54/profile_replication_status_index.sql b/synapse/storage/schema/delta/54/profile_replication_status_index.sql deleted file mode 100644 index 7c20cb5a44..0000000000 --- a/synapse/storage/schema/delta/54/profile_replication_status_index.sql +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2019 New Vector Ltd - * - * 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. - */ - -CREATE UNIQUE INDEX profile_replication_status_idx ON profile_replication_status(host); diff --git a/synapse/storage/schema/delta/55/profile_replication_status_index.sql b/synapse/storage/schema/delta/55/profile_replication_status_index.sql new file mode 100644 index 0000000000..18a0f7e10c --- /dev/null +++ b/synapse/storage/schema/delta/55/profile_replication_status_index.sql @@ -0,0 +1,17 @@ +/* Copyright 2019 New Vector Ltd + * + * 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. + */ + +INSERT INTO background_updates (update_name, progress_json) VALUES + ('profile_replication_status_host_index', '{}'); -- cgit 1.4.1 From 27cd0b3037b439337a54de370a52be671ff4198d Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Thu, 13 Jun 2019 17:40:14 +0100 Subject: Fix snafu --- synapse/storage/profile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index 919b1f1641..23c4c31669 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -19,12 +19,13 @@ from twisted.internet import defer from synapse.api.errors import StoreError from synapse.storage.roommember import ProfileInfo +from ._base import SQLBaseStore from . import background_updates BATCH_SIZE = 100 -class ProfileWorkerStore(background_updates.BackgroundUpdateStore): +class ProfileWorkerStore(SQLBaseStore): @defer.inlineCallbacks def get_profileinfo(self, user_localpart): try: @@ -165,7 +166,7 @@ class ProfileWorkerStore(background_updates.BackgroundUpdateStore): ) -class ProfileStore(ProfileWorkerStore): +class ProfileStore(ProfileWorkerStore, background_updates.BackgroundUpdateStore): def __init__(self, db_conn, hs): super(ProfileStore, self).__init__(db_conn, hs) -- cgit 1.4.1 From 996cf15d4250535398df351621eb03ee29446c9c Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Thu, 13 Jun 2019 17:41:13 +0100 Subject: Lint --- synapse/storage/profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/storage/profile.py b/synapse/storage/profile.py index 23c4c31669..f60263502b 100644 --- a/synapse/storage/profile.py +++ b/synapse/storage/profile.py @@ -19,8 +19,8 @@ from twisted.internet import defer from synapse.api.errors import StoreError from synapse.storage.roommember import ProfileInfo -from ._base import SQLBaseStore from . import background_updates +from ._base import SQLBaseStore BATCH_SIZE = 100 -- cgit 1.4.1