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 broke
with stricter send validation added in 0.19.0.
merge-requests/159/merge
Jason Robinson 2020-01-12 00:56:46 +02:00
rodzic dd55916978
commit 6bc85a3bfa
2 zmienionych plików z 10 dodań i 4 usunięć

Wyświetl plik

@ -19,6 +19,10 @@
* Ensure Pixelfed, Kroeg and Kibou instances that emulate the Mastodon API don't get identified as Mastodon instances. * Ensure Pixelfed, Kroeg and Kibou instances that emulate the Mastodon API don't get identified as Mastodon instances.
* 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
broke with stricter send validation added in 0.19.0.
## [0.19.0] - 2019-12-15 ## [0.19.0] - 2019-12-15
### Added ### Added

Wyświetl plik

@ -148,9 +148,11 @@ class TargetIDMixin(BaseEntity):
target_handle = "" target_handle = ""
target_guid = "" target_guid = ""
def __init__(self, *args, **kwargs): def validate(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs) super().validate(*args, **kwargs)
self._required += ["target_id"] # Ensure one of the target attributes is filled at least
if not self.target_id and not self.target_handle and not self.target_guid:
raise ValueError("Must give one of the target attributes for TargetIDMixin.")
class RootTargetIDMixin(BaseEntity): class RootTargetIDMixin(BaseEntity):