Tweak the Delete side effect

pull/1/head
Thomas Sileo 2018-06-18 20:47:41 +02:00
rodzic c430c5e775
commit 83c2f8b99c
1 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -818,7 +818,10 @@ class Delete(BaseActivity):
# FIXME(tsileo): overrides get_object instead?
obj = self.get_object()
if obj.id.startswith(BACKEND.base_url()) and obj.ACTIVITY_TYPE == ActivityType.TOMBSTONE:
if (
obj.id.startswith(BACKEND.base_url())
and obj.ACTIVITY_TYPE == ActivityType.TOMBSTONE
):
obj = parse_activity(BACKEND.fetch_iri(obj.id))
if obj.ACTIVITY_TYPE == ActivityType.TOMBSTONE:
# If we already received it, we may be able to get a copy
@ -833,11 +836,13 @@ class Delete(BaseActivity):
def _pre_process_from_inbox(self, as_actor: "Person") -> None:
"""Ensures a Delete activity comes from the same actor as the deleted activity."""
obj = self._get_actual_object()
actor = self.get_actor()
pass
# FIXME(tsileo): this should be done by the backend I think
# obj = self._get_actual_object()
# actor = self.get_actor()
if obj.ACTIVITY_TYPE != ActivityType.TOMBSTONE and actor.id != obj.get_actor().id:
raise BadActivityError(f"{actor!r} cannot delete {obj!r}")
# if obj.ACTIVITY_TYPE != ActivityType.TOMBSTONE and actor.id != obj.get_actor().id:
# raise BadActivityError(f"{actor!r} cannot delete {obj!r}")
def _process_from_inbox(self, as_actor: "Person") -> None:
if BACKEND is None:
@ -1028,10 +1033,7 @@ class Note(BaseActivity):
actor=as_actor.id,
object=self.id,
to=[AS_PUBLIC],
cc=[
as_actor.followers,
self.attributedTo,
],
cc=[as_actor.followers, self.attributedTo],
published=datetime.utcnow().replace(microsecond=0).isoformat() + "Z",
)