diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 10b50de58..8b55d1737 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -9,6 +9,12 @@ from .const import * def send_notification(vid, user, text, db=None): + # for when working outside request context + if isinstance(user, int): + uid = user + else: + uid = user.id + if not db: db = g.db @@ -34,7 +40,7 @@ def send_notification(vid, user, text, db=None): db.add(new_aux) notif = Notification(comment_id=new_comment.id, - user_id=user.id) + user_id=uid) db.add(notif) diff --git a/files/routes/posts.py b/files/routes/posts.py index 4fea9fb89..92d3a94f8 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -887,7 +887,7 @@ def submit_post(v): post_url = upload_video(file) new_post.url = post_url new_post.processing = True - gevent.spawn(check_processing_thread, v, new_post, post_url, g.db) + gevent.spawn(check_processing_thread, v.id, new_post, post_url, g.db) except UploadException as e: if request.headers.get("Authorization"): return { @@ -909,7 +909,7 @@ def submit_post(v): post_url = upload_video(file) new_post.url = post_url new_post.processing = True - gevent.spawn(check_processing_thread, v, new_post, post_url, g.db) + gevent.spawn(check_processing_thread, v.id, new_post, post_url, g.db) except UploadException as e: if request.headers.get("Authorization"): return {