Add support for forwarding activities
This commit is contained in:
parent
9594cd3108
commit
8fbb48f671
7 changed files with 171 additions and 8 deletions
|
@ -321,9 +321,14 @@ class OutgoingActivity(Base):
|
|||
created_at = Column(DateTime(timezone=True), nullable=False, default=now)
|
||||
|
||||
recipient = Column(String, nullable=False)
|
||||
outbox_object_id = Column(Integer, ForeignKey("outbox.id"), nullable=False)
|
||||
|
||||
outbox_object_id = Column(Integer, ForeignKey("outbox.id"), nullable=True)
|
||||
outbox_object = relationship(OutboxObject, uselist=False)
|
||||
|
||||
# Can also reference an inbox object if it needds to be forwarded
|
||||
inbox_object_id = Column(Integer, ForeignKey("inbox.id"), nullable=True)
|
||||
inbox_object = relationship(InboxObject, uselist=False)
|
||||
|
||||
tries = Column(Integer, nullable=False, default=0)
|
||||
next_try = Column(DateTime(timezone=True), nullable=True, default=now)
|
||||
|
||||
|
@ -335,6 +340,15 @@ class OutgoingActivity(Base):
|
|||
is_errored = Column(Boolean, nullable=False, default=False)
|
||||
error = Column(String, nullable=True)
|
||||
|
||||
@property
|
||||
def anybox_object(self) -> OutboxObject | InboxObject:
|
||||
if self.outbox_object_id:
|
||||
return self.outbox_object # type: ignore
|
||||
elif self.inbox_object_id:
|
||||
return self.inbox_object # type: ignore
|
||||
else:
|
||||
raise ValueError("Should never happen")
|
||||
|
||||
|
||||
class TaggedOutboxObject(Base):
|
||||
__tablename__ = "tagged_outbox_object"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue