diff --git a/anonstream/routes/core.py b/anonstream/routes/core.py index 00ef969..a3dfc14 100644 --- a/anonstream/routes/core.py +++ b/anonstream/routes/core.py @@ -17,7 +17,7 @@ STATIC_DIRECTORY = current_app.root_path / 'static' @current_app.route('/') @with_user_from(request) -async def home(user): +async def home(timestamp, user): return await render_template( 'home.html', csp=generate_csp(), @@ -26,7 +26,7 @@ async def home(user): @current_app.route('/stream.mp4') @with_user_from(request) -async def stream(user): +async def stream(timestamp, user): if not is_online(): return abort(404) @@ -59,7 +59,7 @@ async def login(): @current_app.route('/captcha.jpg') @with_user_from(request) -async def captcha(user): +async def captcha(timestamp, user): digest = request.args.get('digest', '') image = get_captcha_image(digest) if image is None: @@ -70,5 +70,5 @@ async def captcha(user): @current_app.route('/static/') @with_user_from(request) @clean_cache_headers -async def static(user, filename): +async def static(timestamp, user, filename): return await send_from_directory(STATIC_DIRECTORY, filename) diff --git a/anonstream/routes/nojs.py b/anonstream/routes/nojs.py index 1635e69..c0f7cd8 100644 --- a/anonstream/routes/nojs.py +++ b/anonstream/routes/nojs.py @@ -19,7 +19,7 @@ USERS_BY_TOKEN = current_app.users_by_token @current_app.route('/stream.html') @with_user_from(request) -async def nojs_stream(user): +async def nojs_stream(timestamp, user): return await render_template( 'nojs_stream.html', csp=generate_csp(), @@ -29,7 +29,7 @@ async def nojs_stream(user): @current_app.route('/info.html') @with_user_from(request) -async def nojs_info(user): +async def nojs_info(timestamp, user): update_presence(user) uptime, viewership = get_stream_uptime_and_viewership() return await render_template( @@ -45,7 +45,7 @@ async def nojs_info(user): @current_app.route('/chat/messages.html') @with_user_from(request) -async def nojs_chat_messages(user): +async def nojs_chat_messages(timestamp, user): reading(user) return await render_template_with_etag( 'nojs_chat_messages.html', @@ -60,12 +60,12 @@ async def nojs_chat_messages(user): @current_app.route('/chat/messages') @with_user_from(request) -async def nojs_chat_messages_redirect(user): +async def nojs_chat_messages_redirect(timestamp, user): return redirect(url_for('nojs_chat_messages', token=user['token'], _anchor='end')) @current_app.route('/chat/users.html') @with_user_from(request) -async def nojs_chat_users(user): +async def nojs_chat_users(timestamp, user): users_by_presence = get_users_by_presence() return await render_template_with_etag( 'nojs_chat_users.html', @@ -80,7 +80,7 @@ async def nojs_chat_users(user): @current_app.route('/chat/form.html') @with_user_from(request) -async def nojs_chat_form(user): +async def nojs_chat_form(timestamp, user): state_id = request.args.get('state', type=int) state = pop_state(user, state_id) prefer_chat_form = request.args.get('landing') != 'appearance' @@ -100,7 +100,7 @@ async def nojs_chat_form(user): @current_app.post('/chat/form') @with_user_from(request) -async def nojs_chat_form_redirect(user): +async def nojs_chat_form_redirect(timestamp, user): comment = (await request.form).get('comment', '') if comment: state_id = add_state( @@ -113,7 +113,7 @@ async def nojs_chat_form_redirect(user): @current_app.post('/chat/message') @with_user_from(request) -async def nojs_submit_message(user): +async def nojs_submit_message(timestamp, user): form = await request.form comment = form.get('comment', '') @@ -160,7 +160,7 @@ async def nojs_submit_message(user): @current_app.post('/chat/appearance') @with_user_from(request) -async def nojs_submit_appearance(user): +async def nojs_submit_appearance(timestamp, user): form = await request.form # Collect form data diff --git a/anonstream/routes/websocket.py b/anonstream/routes/websocket.py index ab4927a..f342b0d 100644 --- a/anonstream/routes/websocket.py +++ b/anonstream/routes/websocket.py @@ -13,10 +13,10 @@ from anonstream.routes.wrappers import with_user_from @current_app.websocket('/live') @with_user_from(websocket) -async def live(user): +async def live(timestamp, user): queue = asyncio.Queue() user['websockets'][queue] = -inf - reading(user) + reading(user, timestamp=timestamp) producer = websocket_outbound(queue, user) consumer = websocket_inbound(queue, user) diff --git a/anonstream/routes/wrappers.py b/anonstream/routes/wrappers.py index 4fd4ff6..a3e21cd 100644 --- a/anonstream/routes/wrappers.py +++ b/anonstream/routes/wrappers.py @@ -104,7 +104,7 @@ def with_user_from(context): USERS_UPDATE_BUFFER.add(token) # Set cookie - response = await f(user, *args, **kwargs) + response = await f(timestamp, user, *args, **kwargs) if context.cookies.get('token') != token: response = await make_response(response) response.headers['Set-Cookie'] = f'token={token}; path=/'