Fix some edge case crashes of `handle_send` when there are Diaspora protocol receivers

merge-requests/159/merge
Jason Robinson 2020-01-12 23:33:49 +02:00
rodzic 6bc85a3bfa
commit 4c665e8743
2 zmienionych plików z 9 dodań i 5 usunięć

Wyświetl plik

@ -21,7 +21,9 @@
* Loosen validation of `TargetIDMixin`, it now requires one of the target attributes * Loosen validation of `TargetIDMixin`, it now requires one of the target attributes
to be set, not just `target_id`. This fixes follows over the Diaspora protocol which to be set, not just `target_id`. This fixes follows over the Diaspora protocol which
broke with stricter send validation added in 0.19.0. broke with stricter send validation added in 0.19.0.
* Fix some edge case crashes of `handle_send` when there are Diaspora protocol receivers.
## [0.19.0] - 2019-12-15 ## [0.19.0] - 2019-12-15

Wyświetl plik

@ -184,22 +184,24 @@ def handle_send(
if skip_ready_payload["diaspora"]: if skip_ready_payload["diaspora"]:
continue continue
if public_key: if public_key:
raise ValueError("handle_send - Diaspora recipient cannot be public and use encrypted delivery") logger.warning("handle_send - Diaspora recipient cannot be public and use encrypted delivery")
continue
if not ready_payloads[protocol]["payload"]: if not ready_payloads[protocol]["payload"]:
try: try:
# noinspection PyTypeChecker # noinspection PyTypeChecker
ready_payloads[protocol]["payload"] = handle_create_payload( ready_payloads[protocol]["payload"] = handle_create_payload(
entity, author_user, protocol, parent_user=parent_user, entity, author_user, protocol, parent_user=parent_user,
) )
except ValueError as ex: except Exception as ex:
# No point continuing for this protocol # No point continuing for this protocol
skip_ready_payload["diaspora"] = True skip_ready_payload["diaspora"] = True
logger.warning("handle_send - skipping diaspora due to failure to generate payload: %s", ex) logger.warning("handle_send - skipping diaspora due to failure to generate payload: %s", ex)
ready_payloads["diaspora"]["urls"].add(endpoint) ready_payloads["diaspora"]["urls"].add(endpoint)
else: else:
if not public_key: if not public_key:
raise ValueError("handle_send - Diaspora recipient cannot be private without a public key for " logger.warning("handle_send - Diaspora recipient cannot be private without a public key for "
"encrypted delivery") "encrypted delivery")
continue
# Private payload # Private payload
try: try:
payload = handle_create_payload( payload = handle_create_payload(