diff --git a/synapse/appservice/api.py b/synapse/appservice/api.py
index 73be7ff3d4..a0ea958af6 100644
--- a/synapse/appservice/api.py
+++ b/synapse/appservice/api.py
@@ -19,6 +19,11 @@ from prometheus_client import Counter
from synapse.api.constants import EventTypes, Membership, ThirdPartyEntityKind
from synapse.api.errors import CodeMessageException
+from synapse.appservice import (
+ ApplicationService,
+ TransactionOneTimeKeyCounts,
+ TransactionUnusedFallbackKeys,
+)
from synapse.events import EventBase
from synapse.events.utils import serialize_event
from synapse.http.client import SimpleHttpClient
@@ -26,7 +31,6 @@ from synapse.types import JsonDict, ThirdPartyInstanceID
from synapse.util.caches.response_cache import ResponseCache
if TYPE_CHECKING:
- from synapse.appservice import ApplicationService
from synapse.server import HomeServer
logger = logging.getLogger(__name__)
@@ -219,6 +223,8 @@ class ApplicationServiceApi(SimpleHttpClient):
events: List[EventBase],
ephemeral: List[JsonDict],
to_device_messages: List[JsonDict],
+ one_time_key_counts: TransactionOneTimeKeyCounts,
+ unused_fallback_keys: TransactionUnusedFallbackKeys,
txn_id: Optional[int] = None,
) -> bool:
"""
@@ -252,7 +258,7 @@ class ApplicationServiceApi(SimpleHttpClient):
uri = service.url + ("/transactions/%s" % urllib.parse.quote(str(txn_id)))
# Never send ephemeral events to appservices that do not support it
- body: Dict[str, List[JsonDict]] = {"events": serialized_events}
+ body: JsonDict = {"events": serialized_events}
if service.supports_ephemeral:
body.update(
{
@@ -262,6 +268,16 @@ class ApplicationServiceApi(SimpleHttpClient):
}
)
+ if service.msc3202_transaction_extensions:
+ if one_time_key_counts:
+ body[
+ "org.matrix.msc3202.device_one_time_key_counts"
+ ] = one_time_key_counts
+ if unused_fallback_keys:
+ body[
+ "org.matrix.msc3202.device_unused_fallback_keys"
+ ] = unused_fallback_keys
+
try:
await self.put_json(
uri=uri,
|