mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2025-06-05 21:59:23 +02:00
Add support for forwarding activities
This commit is contained in:
@ -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"
|
||||
|
Reference in New Issue
Block a user