only json serializable objects can be passed to celery tasks (not SQLAlchemy models) #181

This commit is contained in:
rimu 2024-06-01 19:52:17 +12:00
parent 86e86f9e72
commit 0a1ea7d0e3
3 changed files with 7 additions and 6 deletions

View file

@ -1339,7 +1339,7 @@ def user_inbox(actor):
activity_log.result = 'success'
db.session.commit()
if post_being_replied_to.author.is_local():
inform_followers_of_post_update(post_being_replied_to, user.instance_id)
inform_followers_of_post_update(post_being_replied_to.id, user.instance_id)
except VerificationError:
activity_log.result = 'failure'

View file

@ -2557,15 +2557,16 @@ def resolve_remote_post_from_search(uri: str) -> Union[Post, None]:
# This would need for posts to have things like a 'Replies' collection and a 'Likes' collection, so these can be downloaded when the post updates
# Using collecions like this (as PeerTube does) circumvents the problem of not having a remote user's private key.
# The problem of what to do for remote user's activity on a remote user's post in a local community still exists (can't Announce it, can't inform of post update)
def inform_followers_of_post_update(post: Post, sending_instance_id: int):
def inform_followers_of_post_update(post_id: int, sending_instance_id: int):
if current_app.debug:
inform_followers_of_post_update_task(post, sending_instance_id)
inform_followers_of_post_update_task(post_id, sending_instance_id)
else:
inform_followers_of_post_update_task.delay(post, sending_instance_id)
inform_followers_of_post_update_task.delay(post_id, sending_instance_id)
@celery.task
def inform_followers_of_post_update_task(post: Post, sending_instance_id: int):
def inform_followers_of_post_update_task(post_id: int, sending_instance_id: int):
post = Post.query.get(post_id)
page_json = post_to_page(post)
page_json['updated'] = ap_datetime(utcnow())
update_json = {

View file

@ -582,7 +582,7 @@ def poll_vote(post_id):
poll_votes = PollChoice.query.join(PollChoiceVote, PollChoiceVote.choice_id == PollChoice.id).filter(PollChoiceVote.post_id == post.id, PollChoiceVote.user_id == current_user.id).all()
for pv in poll_votes:
if post.author.is_local():
inform_followers_of_post_update(post, 1)
inform_followers_of_post_update(post.id, 1)
else:
pollvote_json = {
'@context': default_context(),