New version of black, new whitespace
This commit is contained in:
@ -9,13 +9,13 @@ from .ordered_collection import CollectionItem
|
||||
|
||||
@dataclass(init=False)
|
||||
class Verb(ActivityObject):
|
||||
"""generic fields for activities """
|
||||
"""generic fields for activities"""
|
||||
|
||||
actor: str
|
||||
object: ActivityObject
|
||||
|
||||
def action(self):
|
||||
""" usually we just want to update and save """
|
||||
"""usually we just want to update and save"""
|
||||
# self.object may return None if the object is invalid in an expected way
|
||||
# ie, Question type
|
||||
if self.object:
|
||||
@ -24,7 +24,7 @@ class Verb(ActivityObject):
|
||||
|
||||
@dataclass(init=False)
|
||||
class Create(Verb):
|
||||
""" Create activity """
|
||||
"""Create activity"""
|
||||
|
||||
to: List[str]
|
||||
cc: List[str] = field(default_factory=lambda: [])
|
||||
@ -34,14 +34,14 @@ class Create(Verb):
|
||||
|
||||
@dataclass(init=False)
|
||||
class Delete(Verb):
|
||||
""" Create activity """
|
||||
"""Create activity"""
|
||||
|
||||
to: List[str]
|
||||
cc: List[str] = field(default_factory=lambda: [])
|
||||
type: str = "Delete"
|
||||
|
||||
def action(self):
|
||||
""" find and delete the activity object """
|
||||
"""find and delete the activity object"""
|
||||
if not self.object:
|
||||
return
|
||||
|
||||
@ -59,25 +59,25 @@ class Delete(Verb):
|
||||
|
||||
@dataclass(init=False)
|
||||
class Update(Verb):
|
||||
""" Update activity """
|
||||
"""Update activity"""
|
||||
|
||||
to: List[str]
|
||||
type: str = "Update"
|
||||
|
||||
def action(self):
|
||||
""" update a model instance from the dataclass """
|
||||
"""update a model instance from the dataclass"""
|
||||
if self.object:
|
||||
self.object.to_model(allow_create=False)
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
class Undo(Verb):
|
||||
""" Undo an activity """
|
||||
"""Undo an activity"""
|
||||
|
||||
type: str = "Undo"
|
||||
|
||||
def action(self):
|
||||
""" find and remove the activity object """
|
||||
"""find and remove the activity object"""
|
||||
if isinstance(self.object, str):
|
||||
# it may be that sometihng should be done with these, but idk what
|
||||
# this seems just to be coming from pleroma
|
||||
@ -103,64 +103,64 @@ class Undo(Verb):
|
||||
|
||||
@dataclass(init=False)
|
||||
class Follow(Verb):
|
||||
""" Follow activity """
|
||||
"""Follow activity"""
|
||||
|
||||
object: str
|
||||
type: str = "Follow"
|
||||
|
||||
def action(self):
|
||||
""" relationship save """
|
||||
"""relationship save"""
|
||||
self.to_model()
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
class Block(Verb):
|
||||
""" Block activity """
|
||||
"""Block activity"""
|
||||
|
||||
object: str
|
||||
type: str = "Block"
|
||||
|
||||
def action(self):
|
||||
""" relationship save """
|
||||
"""relationship save"""
|
||||
self.to_model()
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
class Accept(Verb):
|
||||
""" Accept activity """
|
||||
"""Accept activity"""
|
||||
|
||||
object: Follow
|
||||
type: str = "Accept"
|
||||
|
||||
def action(self):
|
||||
""" find and remove the activity object """
|
||||
"""find and remove the activity object"""
|
||||
obj = self.object.to_model(save=False, allow_create=False)
|
||||
obj.accept()
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
class Reject(Verb):
|
||||
""" Reject activity """
|
||||
"""Reject activity"""
|
||||
|
||||
object: Follow
|
||||
type: str = "Reject"
|
||||
|
||||
def action(self):
|
||||
""" find and remove the activity object """
|
||||
"""find and remove the activity object"""
|
||||
obj = self.object.to_model(save=False, allow_create=False)
|
||||
obj.reject()
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
class Add(Verb):
|
||||
"""Add activity """
|
||||
"""Add activity"""
|
||||
|
||||
target: ActivityObject
|
||||
object: CollectionItem
|
||||
type: str = "Add"
|
||||
|
||||
def action(self):
|
||||
""" figure out the target to assign the item to a collection """
|
||||
"""figure out the target to assign the item to a collection"""
|
||||
target = resolve_remote_id(self.target)
|
||||
item = self.object.to_model(save=False)
|
||||
setattr(item, item.collection_field, target)
|
||||
@ -169,12 +169,12 @@ class Add(Verb):
|
||||
|
||||
@dataclass(init=False)
|
||||
class Remove(Add):
|
||||
"""Remove activity """
|
||||
"""Remove activity"""
|
||||
|
||||
type: str = "Remove"
|
||||
|
||||
def action(self):
|
||||
""" find and remove the activity object """
|
||||
"""find and remove the activity object"""
|
||||
obj = self.object.to_model(save=False, allow_create=False)
|
||||
if obj:
|
||||
obj.delete()
|
||||
@ -182,19 +182,19 @@ class Remove(Add):
|
||||
|
||||
@dataclass(init=False)
|
||||
class Like(Verb):
|
||||
""" a user faving an object """
|
||||
"""a user faving an object"""
|
||||
|
||||
object: str
|
||||
type: str = "Like"
|
||||
|
||||
def action(self):
|
||||
""" like """
|
||||
"""like"""
|
||||
self.to_model()
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
class Announce(Verb):
|
||||
""" boosting a status """
|
||||
"""boosting a status"""
|
||||
|
||||
published: str
|
||||
to: List[str] = field(default_factory=lambda: [])
|
||||
@ -203,5 +203,5 @@ class Announce(Verb):
|
||||
type: str = "Announce"
|
||||
|
||||
def action(self):
|
||||
""" boost """
|
||||
"""boost"""
|
||||
self.to_model()
|
||||
|
Reference in New Issue
Block a user