mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2026-03-21 22:56:47 +00:00
fix: processing page auto-redirect after file upload completes
Three fixes for the processing page not redirecting when status becomes "ended": - Add useWebSockets to processing page so it receives STATUS events - Remove OAuth2PasswordBearer from auth_none — broke WebSocket endpoints (500) - Reconnect stale Redis in ws_manager when Celery worker reuses dead event loop
This commit is contained in:
@@ -1,11 +1,5 @@
|
|||||||
from typing import Annotated
|
|
||||||
|
|
||||||
from fastapi import Depends
|
|
||||||
from fastapi.security import OAuth2PasswordBearer
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token", auto_error=False)
|
|
||||||
|
|
||||||
|
|
||||||
class UserInfo(BaseModel):
|
class UserInfo(BaseModel):
|
||||||
sub: str
|
sub: str
|
||||||
@@ -15,13 +9,13 @@ class AccessTokenInfo(BaseModel):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def authenticated(token: Annotated[str, Depends(oauth2_scheme)]):
|
def authenticated():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def current_user(token: Annotated[str, Depends(oauth2_scheme)]):
|
def current_user():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def current_user_optional(token: Annotated[str, Depends(oauth2_scheme)]):
|
def current_user_optional():
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -48,7 +48,15 @@ class RedisPubSubManager:
|
|||||||
if not self.redis_connection:
|
if not self.redis_connection:
|
||||||
await self.connect()
|
await self.connect()
|
||||||
message = json.dumps(message)
|
message = json.dumps(message)
|
||||||
await self.redis_connection.publish(room_id, message)
|
try:
|
||||||
|
await self.redis_connection.publish(room_id, message)
|
||||||
|
except RuntimeError:
|
||||||
|
# Celery workers run each task in a new event loop (asyncio.run),
|
||||||
|
# which closes the previous loop. Cached Redis connection is dead.
|
||||||
|
# Reconnect on the current loop and retry.
|
||||||
|
self.redis_connection = None
|
||||||
|
await self.connect()
|
||||||
|
await self.redis_connection.publish(room_id, message)
|
||||||
|
|
||||||
async def subscribe(self, room_id: str) -> redis.Redis:
|
async def subscribe(self, room_id: str) -> redis.Redis:
|
||||||
await self.pubsub.subscribe(room_id)
|
await self.pubsub.subscribe(room_id)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useTranscriptGet } from "../../../../lib/apiHooks";
|
import { useTranscriptGet } from "../../../../lib/apiHooks";
|
||||||
import { parseNonEmptyString } from "../../../../lib/utils";
|
import { parseNonEmptyString } from "../../../../lib/utils";
|
||||||
|
import { useWebSockets } from "../../useWebSockets";
|
||||||
|
|
||||||
type TranscriptProcessing = {
|
type TranscriptProcessing = {
|
||||||
params: Promise<{
|
params: Promise<{
|
||||||
@@ -24,6 +25,7 @@ export default function TranscriptProcessing(details: TranscriptProcessing) {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const transcript = useTranscriptGet(transcriptId);
|
const transcript = useTranscriptGet(transcriptId);
|
||||||
|
useWebSockets(transcriptId);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const status = transcript.data?.status;
|
const status = transcript.data?.status;
|
||||||
|
|||||||
Reference in New Issue
Block a user