mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-08-12 16:25:32 -04:00
config: Make additional Homeserver requests for the search endpoint optional.
This commit is contained in:
parent
a6a62434e0
commit
83f62b0378
4 changed files with 25 additions and 2 deletions
|
@ -51,6 +51,21 @@ This option configures if a proxy instance should use the OS keyring to store
|
||||||
its own access tokens. The access tokens are required for the daemon to resume
|
its own access tokens. The access tokens are required for the daemon to resume
|
||||||
operation. If this is set to "No", access tokens are stored in the pantalaimon
|
operation. If this is set to "No", access tokens are stored in the pantalaimon
|
||||||
database in plaintext. Defaults to "Yes".
|
database in plaintext. Defaults to "Yes".
|
||||||
|
.It Cm SearchRequests
|
||||||
|
This option configures if the proxy should make additional HTTP requests to the
|
||||||
|
server when clients use the search API endpoint. Some data that is required to
|
||||||
|
fill out a complete search response is only available on the Homeserver (e.g.
|
||||||
|
start/end tokens for the event context or room state at a particular point in
|
||||||
|
time).
|
||||||
|
|
||||||
|
If this option is set to "On"
|
||||||
|
.Nm pantalaimon
|
||||||
|
will make additional HTTP requests to fetch the unavailable data from the
|
||||||
|
Homeserver, note that this will make the search much slower. If this is set to
|
||||||
|
"Off"
|
||||||
|
.Nm pantalaimon
|
||||||
|
will not make any additional HTTP requests and will leave some data fields in
|
||||||
|
the search response empty. Defaults to "Off".
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
Aditional to the homeserver section a special section with the name
|
Aditional to the homeserver section a special section with the name
|
||||||
|
|
|
@ -114,6 +114,7 @@ class PanClient(AsyncClient):
|
||||||
self,
|
self,
|
||||||
server_name,
|
server_name,
|
||||||
pan_store,
|
pan_store,
|
||||||
|
pan_conf,
|
||||||
homeserver,
|
homeserver,
|
||||||
queue=None,
|
queue=None,
|
||||||
user_id="",
|
user_id="",
|
||||||
|
@ -136,6 +137,7 @@ class PanClient(AsyncClient):
|
||||||
|
|
||||||
self.server_name = server_name
|
self.server_name = server_name
|
||||||
self.pan_store = pan_store
|
self.pan_store = pan_store
|
||||||
|
self.pan_conf = pan_conf
|
||||||
self.index = IndexStore(self.user_id, index_dir)
|
self.index = IndexStore(self.user_id, index_dir)
|
||||||
self.task = None
|
self.task = None
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
|
@ -745,7 +747,7 @@ class PanClient(AsyncClient):
|
||||||
after_limit=after_limit
|
after_limit=after_limit
|
||||||
)
|
)
|
||||||
|
|
||||||
if event_context or include_state:
|
if (event_context or include_state) and self.pan_conf.search_requests:
|
||||||
for event_dict in response_dict["results"]:
|
for event_dict in response_dict["results"]:
|
||||||
await add_context(
|
await add_context(
|
||||||
event_dict,
|
event_dict,
|
||||||
|
|
|
@ -34,6 +34,7 @@ class PanConfigParser(configparser.ConfigParser):
|
||||||
"LogLevel": "warnig",
|
"LogLevel": "warnig",
|
||||||
"Notifications": "on",
|
"Notifications": "on",
|
||||||
"UseKeyring": "yes",
|
"UseKeyring": "yes",
|
||||||
|
"SearchRequests": "off",
|
||||||
},
|
},
|
||||||
converters={
|
converters={
|
||||||
"address": parse_address,
|
"address": parse_address,
|
||||||
|
@ -112,6 +113,7 @@ class ServerConfig:
|
||||||
ssl = attr.ib(type=bool, default=True)
|
ssl = attr.ib(type=bool, default=True)
|
||||||
ignore_verification = attr.ib(type=bool, default=False)
|
ignore_verification = attr.ib(type=bool, default=False)
|
||||||
keyring = attr.ib(type=bool, default=True)
|
keyring = attr.ib(type=bool, default=True)
|
||||||
|
search_requests = attr.ib(type=bool, default=False)
|
||||||
|
|
||||||
|
|
||||||
@attr.s
|
@attr.s
|
||||||
|
@ -168,6 +170,7 @@ class PanConfig:
|
||||||
ignore_verification = section.getboolean("IgnoreVerification")
|
ignore_verification = section.getboolean("IgnoreVerification")
|
||||||
keyring = section.getboolean("UseKeyring")
|
keyring = section.getboolean("UseKeyring")
|
||||||
proxy = section.geturl("Proxy")
|
proxy = section.geturl("Proxy")
|
||||||
|
search_requests = section.getboolean("SearchRequests")
|
||||||
|
|
||||||
listen_tuple = (listen_address, listen_port)
|
listen_tuple = (listen_address, listen_port)
|
||||||
|
|
||||||
|
@ -185,7 +188,8 @@ class PanConfig:
|
||||||
proxy,
|
proxy,
|
||||||
ssl,
|
ssl,
|
||||||
ignore_verification,
|
ignore_verification,
|
||||||
keyring
|
keyring,
|
||||||
|
search_requests
|
||||||
)
|
)
|
||||||
|
|
||||||
self.servers[section_name] = server_conf
|
self.servers[section_name] = server_conf
|
||||||
|
|
|
@ -100,6 +100,7 @@ class ProxyDaemon:
|
||||||
pan_client = PanClient(
|
pan_client = PanClient(
|
||||||
self.name,
|
self.name,
|
||||||
self.store,
|
self.store,
|
||||||
|
self.conf,
|
||||||
self.homeserver_url,
|
self.homeserver_url,
|
||||||
self.send_queue,
|
self.send_queue,
|
||||||
user_id,
|
user_id,
|
||||||
|
@ -518,6 +519,7 @@ class ProxyDaemon:
|
||||||
pan_client = PanClient(
|
pan_client = PanClient(
|
||||||
self.name,
|
self.name,
|
||||||
self.store,
|
self.store,
|
||||||
|
self.conf,
|
||||||
self.homeserver_url,
|
self.homeserver_url,
|
||||||
self.send_queue,
|
self.send_queue,
|
||||||
user_id,
|
user_id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue