kopia lustrzana https://github.com/tsileo/little-boxes
Remove old/un-needed stuff
rodzic
d637d0bed0
commit
49f5caf6f5
|
@ -748,24 +748,6 @@ class Delete(BaseActivity):
|
|||
ALLOWED_OBJECT_TYPES = CREATE_TYPES + ACTOR_TYPES + [ActivityType.TOMBSTONE]
|
||||
OBJECT_REQUIRED = True
|
||||
|
||||
def _get_actual_object(self) -> BaseActivity:
|
||||
if BACKEND is None:
|
||||
raise UninitializedBackendError
|
||||
|
||||
# XXX(tsileo): overrides get_object instead?
|
||||
obj = self.get_object()
|
||||
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
|
||||
better_obj = BACKEND.fetch_iri(obj.id)
|
||||
if better_obj:
|
||||
return parse_activity(better_obj)
|
||||
return obj
|
||||
|
||||
def _recipients(self) -> List[str]:
|
||||
recipients = []
|
||||
for field in ["to", "cc"]:
|
||||
|
@ -808,15 +790,6 @@ class Create(BaseActivity):
|
|||
|
||||
return False
|
||||
|
||||
def _set_id(self, uri: str, obj_id: str) -> None:
|
||||
if BACKEND is None:
|
||||
raise UninitializedBackendError
|
||||
|
||||
# FIXME(tsileo): add a BACKEND.note_activity_url, and pass the actor to both
|
||||
self._data["object"]["id"] = uri + "/activity"
|
||||
if "url" not in self._data["object"]:
|
||||
self._data["object"]["url"] = BACKEND.note_url(obj_id)
|
||||
|
||||
def _init(self) -> None:
|
||||
obj = self.get_object()
|
||||
if not obj.attributedTo:
|
||||
|
|
|
@ -24,6 +24,11 @@ if typing.TYPE_CHECKING:
|
|||
|
||||
|
||||
class Backend(abc.ABC):
|
||||
|
||||
@abc.abstractmethod
|
||||
def base_url(self) -> str:
|
||||
pass # pragma: no cover
|
||||
|
||||
def debug_mode(self) -> bool:
|
||||
"""Should be overidded to return `True` in order to enable the debug mode."""
|
||||
return False
|
||||
|
@ -66,10 +71,6 @@ class Backend(abc.ABC):
|
|||
) -> bool:
|
||||
return activity.get_actor().id == as_actor.id
|
||||
|
||||
@abc.abstractmethod
|
||||
def base_url(self) -> str:
|
||||
pass # pragma: no cover
|
||||
|
||||
def fetch_iri(self, iri: str, **kwargs) -> "ap.ObjectType": # pragma: no cover
|
||||
if not iri.startswith("http"):
|
||||
raise NotAnActivityError(f"{iri} is not a valid IRI")
|
||||
|
@ -115,11 +116,3 @@ class Backend(abc.ABC):
|
|||
raise NotAnActivityError(f"{iri} is not JSON")
|
||||
|
||||
return out
|
||||
|
||||
@abc.abstractmethod
|
||||
def activity_url(self, obj_id: str) -> str:
|
||||
pass # pragma: no cover
|
||||
|
||||
@abc.abstractmethod
|
||||
def note_url(self, obj_id: str) -> str:
|
||||
pass # pragma: no cover
|
||||
|
|
Ładowanie…
Reference in New Issue