mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:16:07 -04:00
Only fetch thread participation for events with threads. (#12228)
We fetch the thread summary in two phases: 1. The summary that is shared by all users (count of messages and latest event). 2. Whether the requesting user has participated in the thread. There's no use in attempting step 2 for events which did not return a summary from step 1.
This commit is contained in:
parent
2177e356bc
commit
80e0e1f35e
4 changed files with 289 additions and 245 deletions
|
@ -54,13 +54,18 @@ from twisted.internet.interfaces import (
|
|||
ITransport,
|
||||
)
|
||||
from twisted.python.failure import Failure
|
||||
from twisted.test.proto_helpers import AccumulatingProtocol, MemoryReactorClock
|
||||
from twisted.test.proto_helpers import (
|
||||
AccumulatingProtocol,
|
||||
MemoryReactor,
|
||||
MemoryReactorClock,
|
||||
)
|
||||
from twisted.web.http_headers import Headers
|
||||
from twisted.web.resource import IResource
|
||||
from twisted.web.server import Request, Site
|
||||
|
||||
from synapse.config.database import DatabaseConnectionConfig
|
||||
from synapse.http.site import SynapseRequest
|
||||
from synapse.logging.context import ContextResourceUsage
|
||||
from synapse.server import HomeServer
|
||||
from synapse.storage import DataStore
|
||||
from synapse.storage.engines import PostgresEngine, create_engine
|
||||
|
@ -88,18 +93,19 @@ class TimedOutException(Exception):
|
|||
"""
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(auto_attribs=True)
|
||||
class FakeChannel:
|
||||
"""
|
||||
A fake Twisted Web Channel (the part that interfaces with the
|
||||
wire).
|
||||
"""
|
||||
|
||||
site = attr.ib(type=Union[Site, "FakeSite"])
|
||||
_reactor = attr.ib()
|
||||
result = attr.ib(type=dict, default=attr.Factory(dict))
|
||||
_ip = attr.ib(type=str, default="127.0.0.1")
|
||||
site: Union[Site, "FakeSite"]
|
||||
_reactor: MemoryReactor
|
||||
result: dict = attr.Factory(dict)
|
||||
_ip: str = "127.0.0.1"
|
||||
_producer: Optional[Union[IPullProducer, IPushProducer]] = None
|
||||
resource_usage: Optional[ContextResourceUsage] = None
|
||||
|
||||
@property
|
||||
def json_body(self):
|
||||
|
@ -168,6 +174,8 @@ class FakeChannel:
|
|||
|
||||
def requestDone(self, _self):
|
||||
self.result["done"] = True
|
||||
if isinstance(_self, SynapseRequest):
|
||||
self.resource_usage = _self.logcontext.get_resource_usage()
|
||||
|
||||
def getPeer(self):
|
||||
# We give an address so that getClientIP returns a non null entry,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue