replace user_id with sender
parent
97c7c34f6f
commit
c5eabe3143
|
@ -119,7 +119,7 @@ class SynapseEvent(JsonEncodedObject):
|
||||||
|
|
||||||
def get_pdu_json(self, time_now=None):
|
def get_pdu_json(self, time_now=None):
|
||||||
pdu_json = self.get_full_dict()
|
pdu_json = self.get_full_dict()
|
||||||
pdu_json.pop("destination", None)
|
pdu_json.pop("destinations", None)
|
||||||
pdu_json.pop("outlier", None)
|
pdu_json.pop("outlier", None)
|
||||||
pdu_json.pop("replaces_state", None)
|
pdu_json.pop("replaces_state", None)
|
||||||
pdu_json.pop("redacted", None)
|
pdu_json.pop("redacted", None)
|
||||||
|
@ -132,6 +132,8 @@ class SynapseEvent(JsonEncodedObject):
|
||||||
age = time_now - pdu_json["age_ts"]
|
age = time_now - pdu_json["age_ts"]
|
||||||
pdu_json.setdefault("unsigned", {})["age"] = int(age)
|
pdu_json.setdefault("unsigned", {})["age"] = int(age)
|
||||||
del pdu_json["age_ts"]
|
del pdu_json["age_ts"]
|
||||||
|
user_id = pdu_json.pop("user_id")
|
||||||
|
pdu_json["sender"] = user_id
|
||||||
return pdu_json
|
return pdu_json
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -582,6 +582,9 @@ class ReplicationLayer(object):
|
||||||
#TODO: Check we have all the PDU keys here
|
#TODO: Check we have all the PDU keys here
|
||||||
pdu_json.setdefault("hashes", {})
|
pdu_json.setdefault("hashes", {})
|
||||||
pdu_json.setdefault("signatures", {})
|
pdu_json.setdefault("signatures", {})
|
||||||
|
sender = pdu_json.pop("sender", None)
|
||||||
|
if sender is not None:
|
||||||
|
pdu_json["user_id"] = sender
|
||||||
state_hash = pdu_json.get("unsigned", {}).pop("state_hash", None)
|
state_hash = pdu_json.get("unsigned", {}).pop("state_hash", None)
|
||||||
if state_hash is not None:
|
if state_hash is not None:
|
||||||
pdu_json["state_hash"] = state_hash
|
pdu_json["state_hash"] = state_hash
|
||||||
|
|
|
@ -100,6 +100,7 @@ class FederationTestCase(unittest.TestCase):
|
||||||
make_pdu(
|
make_pdu(
|
||||||
event_id="the-pdu-id",
|
event_id="the-pdu-id",
|
||||||
origin="red",
|
origin="red",
|
||||||
|
user_id="@a:red",
|
||||||
room_id="my-context",
|
room_id="my-context",
|
||||||
type="m.topic",
|
type="m.topic",
|
||||||
origin_server_ts=123456789000,
|
origin_server_ts=123456789000,
|
||||||
|
@ -145,6 +146,7 @@ class FederationTestCase(unittest.TestCase):
|
||||||
make_pdu(
|
make_pdu(
|
||||||
event_id="abc123def456",
|
event_id="abc123def456",
|
||||||
origin="red",
|
origin="red",
|
||||||
|
user_id="@a:red",
|
||||||
room_id="my-context",
|
room_id="my-context",
|
||||||
type="m.text",
|
type="m.text",
|
||||||
origin_server_ts=123456789001,
|
origin_server_ts=123456789001,
|
||||||
|
@ -172,6 +174,7 @@ class FederationTestCase(unittest.TestCase):
|
||||||
pdu = SynapseEvent(
|
pdu = SynapseEvent(
|
||||||
event_id="abc123def456",
|
event_id="abc123def456",
|
||||||
origin="red",
|
origin="red",
|
||||||
|
user_id="@a:red",
|
||||||
room_id="my-context",
|
room_id="my-context",
|
||||||
type="m.text",
|
type="m.text",
|
||||||
origin_server_ts=123456789001,
|
origin_server_ts=123456789001,
|
||||||
|
|
|
@ -81,8 +81,9 @@ class FederationTestCase(unittest.TestCase):
|
||||||
content={"msgtype": u"fooo"},
|
content={"msgtype": u"fooo"},
|
||||||
origin_server_ts=0,
|
origin_server_ts=0,
|
||||||
event_id="$a:b",
|
event_id="$a:b",
|
||||||
|
user_id="@a:b",
|
||||||
origin="b",
|
origin="b",
|
||||||
hashes={"sha256":"PvbCLWrTBxnBsSO7/cJ76072ySTCgI/XGadESRAe02M"},
|
hashes={"sha256":"AcLrgtUIqqwaGoHhrEvYG1YLDIsVPYJdSRGhkp3jJp8"},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.datastore.persist_event.return_value = defer.succeed(None)
|
self.datastore.persist_event.return_value = defer.succeed(None)
|
||||||
|
|
Loading…
Reference in New Issue