Route invitation recipients only to mail delivery
This commit is contained in:
parent
bf03b3e82a
commit
6962ad63b4
3 changed files with 14 additions and 1 deletions
|
|
@ -39,7 +39,13 @@ class HTTPOutboxDeliveryAdapter:
|
||||||
}
|
}
|
||||||
if self.mail_url and event.event_type in _MAIL_EVENTS:
|
if self.mail_url and event.event_type in _MAIL_EVENTS:
|
||||||
self._post(self.mail_url, envelope)
|
self._post(self.mail_url, envelope)
|
||||||
self._post(self.event_url, envelope)
|
event_envelope = dict(envelope)
|
||||||
|
event_data = dict(envelope["data"])
|
||||||
|
if "primary_email" in event_data:
|
||||||
|
event_data["recipient_present"] = True
|
||||||
|
del event_data["primary_email"]
|
||||||
|
event_envelope["data"] = event_data
|
||||||
|
self._post(self.event_url, event_envelope)
|
||||||
|
|
||||||
def _post(self, url: str, envelope: dict[str, object]) -> None:
|
def _post(self, url: str, envelope: dict[str, object]) -> None:
|
||||||
with urlopen(
|
with urlopen(
|
||||||
|
|
|
||||||
|
|
@ -2516,6 +2516,7 @@ class UserEngineService:
|
||||||
"family_scope_id": family_scope_id,
|
"family_scope_id": family_scope_id,
|
||||||
"application_id": application_id,
|
"application_id": application_id,
|
||||||
"role": role,
|
"role": role,
|
||||||
|
"primary_email": invitation.primary_email,
|
||||||
},
|
},
|
||||||
application_id=application_id,
|
application_id=application_id,
|
||||||
)
|
)
|
||||||
|
|
@ -2574,6 +2575,7 @@ class UserEngineService:
|
||||||
"invitation_id": updated.invitation_id,
|
"invitation_id": updated.invitation_id,
|
||||||
"user_id": updated.user_id,
|
"user_id": updated.user_id,
|
||||||
"resend_count": updated.resend_count,
|
"resend_count": updated.resend_count,
|
||||||
|
"primary_email": updated.primary_email,
|
||||||
},
|
},
|
||||||
application_id=updated.application_id,
|
application_id=updated.application_id,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,11 @@ class PlatformAdapterTests(unittest.TestCase):
|
||||||
["http://mail", "http://events"])
|
["http://mail", "http://events"])
|
||||||
for item in call.call_args_list:
|
for item in call.call_args_list:
|
||||||
self.assertEqual(item.args[0].get_header("Idempotency-key"), "evt-1")
|
self.assertEqual(item.args[0].get_header("Idempotency-key"), "evt-1")
|
||||||
|
mail_payload = json.loads(call.call_args_list[0].args[0].data)
|
||||||
|
event_payload = json.loads(call.call_args_list[1].args[0].data)
|
||||||
|
self.assertEqual(mail_payload["data"]["primary_email"], "person@example.test")
|
||||||
|
self.assertNotIn("primary_email", event_payload["data"])
|
||||||
|
self.assertTrue(event_payload["data"]["recipient_present"])
|
||||||
|
|
||||||
def test_non_mail_event_only_calls_event_lane(self):
|
def test_non_mail_event_only_calls_event_lane(self):
|
||||||
adapter = HTTPOutboxDeliveryAdapter(
|
adapter = HTTPOutboxDeliveryAdapter(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue