mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-23 05:24:06 -04:00
Convert appservice, group server, profile and more databases to async (#8066)
This commit is contained in:
parent
9d1e4942ab
commit
a3a59bab7b
9 changed files with 91 additions and 116 deletions
|
@ -13,18 +13,15 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from twisted.internet import defer
|
||||
|
||||
from synapse.api.errors import StoreError
|
||||
from synapse.storage._base import SQLBaseStore
|
||||
from synapse.storage.databases.main.roommember import ProfileInfo
|
||||
|
||||
|
||||
class ProfileWorkerStore(SQLBaseStore):
|
||||
@defer.inlineCallbacks
|
||||
def get_profileinfo(self, user_localpart):
|
||||
async def get_profileinfo(self, user_localpart):
|
||||
try:
|
||||
profile = yield self.db_pool.simple_select_one(
|
||||
profile = await self.db_pool.simple_select_one(
|
||||
table="profiles",
|
||||
keyvalues={"user_id": user_localpart},
|
||||
retcols=("displayname", "avatar_url"),
|
||||
|
@ -118,14 +115,13 @@ class ProfileStore(ProfileWorkerStore):
|
|||
desc="update_remote_profile_cache",
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def maybe_delete_remote_profile_cache(self, user_id):
|
||||
async def maybe_delete_remote_profile_cache(self, user_id):
|
||||
"""Check if we still care about the remote user's profile, and if we
|
||||
don't then remove their profile from the cache
|
||||
"""
|
||||
subscribed = yield self.is_subscribed_remote_profile_for_user(user_id)
|
||||
subscribed = await self.is_subscribed_remote_profile_for_user(user_id)
|
||||
if not subscribed:
|
||||
yield self.db_pool.simple_delete(
|
||||
await self.db_pool.simple_delete(
|
||||
table="remote_profile_cache",
|
||||
keyvalues={"user_id": user_id},
|
||||
desc="delete_remote_profile_cache",
|
||||
|
@ -151,11 +147,10 @@ class ProfileStore(ProfileWorkerStore):
|
|||
_get_remote_profile_cache_entries_that_expire_txn,
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def is_subscribed_remote_profile_for_user(self, user_id):
|
||||
async def is_subscribed_remote_profile_for_user(self, user_id):
|
||||
"""Check whether we are interested in a remote user's profile.
|
||||
"""
|
||||
res = yield self.db_pool.simple_select_one_onecol(
|
||||
res = await self.db_pool.simple_select_one_onecol(
|
||||
table="group_users",
|
||||
keyvalues={"user_id": user_id},
|
||||
retcol="user_id",
|
||||
|
@ -166,7 +161,7 @@ class ProfileStore(ProfileWorkerStore):
|
|||
if res:
|
||||
return True
|
||||
|
||||
res = yield self.db_pool.simple_select_one_onecol(
|
||||
res = await self.db_pool.simple_select_one_onecol(
|
||||
table="group_invites",
|
||||
keyvalues={"user_id": user_id},
|
||||
retcol="user_id",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue