def update_thread(slug_or_id): json_data = request.get_json() thread = Thread.get_by_slug_or_id(slug_or_id) if not thread: return json_response({'message': 'Thread not found'}, 404) thread = Thread.update_thread(thread['id'], json_data, thread) thread['created'] = format_time(thread['created']) return json_response(thread, 200)
def get_thread_messages(slug_or_id): sort = request.args.get('sort') since = request.args.get('since') limit = request.args.get('limit') desc = request.args.get('desc') thread = Thread.get_by_slug_or_id(slug_or_id) posts = [] if not thread: return json_response({'message': 'Thread not found'}, 404) if sort == "flat" or sort is None: posts = Thread.get_posts_flat_sorted(thread['id'], since, limit, desc) elif sort == "tree": posts = Thread.get_posts_tree_sorted(thread['id'], since, limit, desc) elif sort == "parent_tree": posts = Thread.get_posts_parent_tree_sorter(thread['id'], since, limit, desc) for post in posts: post['created'] = format_time(post['created']) return json_response(posts, 200)
def get_thread_details(slug_or_id): thread = Thread.get_by_slug_or_id(slug_or_id) if thread: thread['created'] = format_time(thread['created']) return json_response(thread, 200) return json_response({'message': 'thread not found'}, 404)