Prefix event transaction_id keys with reverse DNS

Respect the Matrix spec by using
"io.github.mirukana.mirage.transaction_id" instead of
"mirage.transaction_id".
This commit is contained in:
miruka 2020-09-22 21:22:38 -04:00
parent 2313673993
commit 0e3821a592
2 changed files with 5 additions and 4 deletions

View File

@ -14,4 +14,5 @@ documentation in the following modules first:
__app_name__ = "mirage" __app_name__ = "mirage"
__display_name__ = "Mirage" __display_name__ = "Mirage"
__reverse_dns__ = "io.github.mirukana.mirage"
__version__ = "0.6.4" __version__ = "0.6.4"

View File

@ -34,7 +34,7 @@ import nio
from nio.crypto import AsyncDataT as UploadData from nio.crypto import AsyncDataT as UploadData
from nio.crypto import async_generator_from_data from nio.crypto import async_generator_from_data
from . import __app_name__, __display_name__, utils from . import __display_name__, __reverse_dns__, utils
from .errors import ( from .errors import (
BadMimeType, InvalidUserId, InvalidUserInContext, MatrixBadGateway, BadMimeType, InvalidUserId, InvalidUserInContext, MatrixBadGateway,
MatrixError, MatrixForbidden, MatrixInvalidAccessToken, MatrixNotFound, MatrixError, MatrixForbidden, MatrixInvalidAccessToken, MatrixNotFound,
@ -612,7 +612,7 @@ class MatrixClient(nio.AsyncClient):
# to the sender so our other accounts wouldn't be able to replace # to the sender so our other accounts wouldn't be able to replace
# local echoes by real messages. # local echoes by real messages.
tx_id = uuid4() tx_id = uuid4()
content[f"{__app_name__}.transaction_id"] = str(tx_id) content[f"{__reverse_dns__}.transaction_id"] = str(tx_id)
mentions = HTML.mentions_in_html(echo_body) mentions = HTML.mentions_in_html(echo_body)
await self._local_echo( await self._local_echo(
@ -781,7 +781,7 @@ class MatrixClient(nio.AsyncClient):
thumb_info: Optional[MatrixImageInfo] = None thumb_info: Optional[MatrixImageInfo] = None
content: dict = { content: dict = {
f"{__app_name__}.transaction_id": str(transaction_id), f"{__reverse_dns__}.transaction_id": str(transaction_id),
"body": path.name, "body": path.name,
"info": { "info": {
@ -2168,7 +2168,7 @@ class MatrixClient(nio.AsyncClient):
model = self.models[self.user_id, room.room_id, "events"] model = self.models[self.user_id, room.room_id, "events"]
tx_id = ev.source.get("content", {}).get( tx_id = ev.source.get("content", {}).get(
f"{__app_name__}.transaction_id", f"{__reverse_dns__}.transaction_id",
) )
from_us = ev.sender in self.backend.clients from_us = ev.sender in self.backend.clients