| ... |
... |
@@ -17,7 +17,6 @@ |
|
17
|
17
|
from typing import Any
|
|
18
|
18
|
from typing import NamedTuple
|
|
19
|
19
|
from typing import Optional
|
|
20
|
|
-from typing import Union
|
|
21
|
20
|
|
|
22
|
21
|
import json
|
|
23
|
22
|
import time
|
| ... |
... |
@@ -101,7 +100,7 @@ def __init__(self): |
|
101
|
100
|
CACHE_SQL_STATEMENT)
|
|
102
|
101
|
|
|
103
|
102
|
self._entity_caps_cache: dict[tuple[str, str], DiscoInfo] = {}
|
|
104
|
|
- self._disco_info_cache: dict[Union[JID, str], DiscoInfo] = {}
|
|
|
103
|
+ self._disco_info_cache: dict[JID, DiscoInfo] = {}
|
|
105
|
104
|
self._muc_cache: dict[JID, dict[str, Any]] = defaultdict(dict)
|
|
106
|
105
|
self._contact_cache: dict[JID, dict[str, Any]] = defaultdict(dict)
|
|
107
|
106
|
|
| ... |
... |
@@ -181,7 +180,7 @@ def _clean_caps_table(self) -> None: |
|
181
|
180
|
@timeit
|
|
182
|
181
|
def _fill_disco_info_cache(self) -> None:
|
|
183
|
182
|
sql = '''SELECT disco_info as "disco_info [disco_info]",
|
|
184
|
|
- jid, last_seen FROM
|
|
|
183
|
+ jid as "jid [jid]", last_seen FROM
|
|
185
|
184
|
last_seen_disco_info'''
|
|
186
|
185
|
rows = self._con.execute(sql).fetchall()
|
|
187
|
186
|
for row in rows:
|
| ... |
... |
@@ -190,7 +189,7 @@ def _fill_disco_info_cache(self) -> None: |
|
190
|
189
|
log.info('%d DiscoInfo entries loaded', len(rows))
|
|
191
|
190
|
|
|
192
|
191
|
def get_last_disco_info(self,
|
|
193
|
|
- jid: Union[str, JID],
|
|
|
192
|
+ jid: JID,
|
|
194
|
193
|
max_age: int = 0) -> Optional[DiscoInfo]:
|
|
195
|
194
|
"""
|
|
196
|
195
|
Get last disco info from jid
|
| ... |
... |
@@ -210,7 +209,7 @@ def get_last_disco_info(self, |
|
210
|
209
|
|
|
211
|
210
|
@timeit
|
|
212
|
211
|
def set_last_disco_info(self,
|
|
213
|
|
- jid: Union[str, JID],
|
|
|
212
|
+ jid: JID,
|
|
214
|
213
|
disco_info: DiscoInfo,
|
|
215
|
214
|
cache_only: bool = False) -> None:
|
|
216
|
215
|
"""
|