pyfedi/app/shared/tasks/__init__.py
2024-11-02 23:56:56 +00:00

30 lines
977 B
Python

from app.shared.tasks.follows import join_community, leave_community
from app.shared.tasks.likes import vote_for_post, vote_for_reply
from app.shared.tasks.notes import make_reply, edit_reply
from app.shared.tasks.deletes import delete_reply, restore_reply
from app.shared.tasks.flags import report_reply
from flask import current_app
def task_selector(task_key, send_async=True, **kwargs):
tasks = {
'join_community': join_community,
'leave_community': leave_community,
'vote_for_post': vote_for_post,
'vote_for_reply': vote_for_reply,
'make_reply': make_reply,
'edit_reply': edit_reply,
'delete_reply': delete_reply,
'restore_reply': restore_reply,
'report_reply': report_reply
}
if current_app.debug:
send_async = False
if send_async:
tasks[task_key].delay(send_async=send_async, **kwargs)
else:
return tasks[task_key](send_async=send_async, **kwargs)