I'm developing odoo17 enterprise  project and we need to add online/offline/last_activity functionality with websockets, development  happening in dockerized environment, and we need to add online/offline/last_activity functionality with websockets to user sessions, before responsing truely realize and analyze all what you have, check every bit, check for missing parts(imports, variables), no comments in code, document what you did with filenames and short descriptions, be aware of the project is in prod, we cannot fail, double check your response, then double check double checked response and then give me result. now i will provide you some of my code:
session_router: 
from fastapi import APIRouter, HTTPException, Depends
from typing import Annotated
from odoo.api import Environment

from ..dependencies import odoo_env, get_partner_with_session, get_partner_with_session_id
from odoo.addons.base.models.res_partner import Partner
from odoo.addons.fastapi_addon.utils.redis_session import redis_session_manager
from odoo.addons.fastapi_addon.schemas.user_session_schema import (
    SessionSchema,
    SessionResponse,
)
from datetime import datetime

router = APIRouter(tags=['User Session'])

@router.get("/sessions", response_model=SessionResponse)
async def get_sessions(
    env: Annotated[Environment, Depends(odoo_env)],
    partner: Annotated[Partner, Depends(get_partner_with_session)],
    current_session_id: str = Depends(get_partner_with_session_id)
):
    user_id = partner.id
    session_ids = redis_session_manager.redis.smembers(f"user_sessions:{user_id}")

    current_session_data = redis_session_manager.get_session(current_session_id)
    if not current_session_data:
        raise HTTPException(status_code=404, detail="Current session not found")


    response = SessionResponse(
        current_session=SessionSchema(
            session_id=current_session_id,
            app_version=current_session_data.get('app_version'),
            device_name=current_session_data['device_name'],
            location=current_session_data.get('location'),
            last_activity=current_session_data.get('last_activity'),
            is_ios=current_session_data.get('is_ios') or False
        ),
        other_sessions=[]
    )

    for session_id in session_ids:
        if session_id != current_session_id:
            session_data = redis_session_manager.get_session(session_id)
            if session_data:
                session_info = SessionSchema(
                    session_id=session_id,
                    app_version=session_data.get('app_version'),
                    device_name=session_data['device_name'],
                    location=session_data.get('location'),
                    last_activity=session_data.get('last_activity'),
                    is_ios=session_data.get('is_ios') or False
                )
                response.other_sessions.append(session_info)

    return response


@router.get("/session/{session_id}", response_model=SessionSchema)
async def get_session_detail(
        session_id: str,
        env: Annotated[Environment, Depends(odoo_env)],
        partner: Annotated[Partner, Depends(get_partner_with_session)]
):
    user_id = partner.id
    user_sessions = redis_session_manager.redis.smembers(f"user_sessions:{user_id}")

    if session_id not in user_sessions:
        raise HTTPException(status_code=404, detail="Session not found")

    session_data = redis_session_manager.get_session(session_id)
    if not session_data:
        raise HTTPException(status_code=404, detail="Session data not found")

    session_detail = SessionSchema(
        session_id=session_id,
        app_version=session_data.get('app_version'),
        device_name=session_data['device_name'],
        location=session_data.get('location'),
        last_activity=session_data.get('last_activity'),
        is_ios=session_data.get('is_ios') or False
    )

    return session_detail


@router.delete("/logout/all-except-current", status_code=204)
async def logout_all_except_current(
        env: Annotated[Environment, Depends(odoo_env)],
        partner: Annotated[Partner, Depends(get_partner_with_session)],
        current_session_id: str = Depends(get_partner_with_session_id)
):
    user_id = partner.id
    user_sessions = redis_session_manager.redis.smembers(f"user_sessions:{user_id}")

    for session_id in user_sessions:
        if session_id != current_session_id:
            redis_session_manager.end_session(session_id)

    return None


@router.delete("/logout/current", status_code=204)
async def logout_current_session(
        env: Annotated[Environment, Depends(odoo_env)],
        partner: Annotated[Partner, Depends(get_partner_with_session)],
        current_session_id: str = Depends(get_partner_with_session_id)
):
    redis_session_manager.end_session(current_session_id)
    return None


@router.delete("/logout/{session_id}", status_code=204)
async def logout_from_session(
        session_id: str,
        env: Annotated[Environment, Depends(odoo_env)],
        partner: Annotated[Partner, Depends(get_partner_with_session)],
        current_session_id: str = Depends(get_partner_with_session_id)
):
    user_id = partner.id
    user_sessions = redis_session_manager.redis.smembers(f"user_sessions:{user_id}")

    if session_id not in user_sessions:
        raise HTTPException(status_code=404, detail="Session not found")

    if session_id == current_session_id:
        raise HTTPException(status_code=400, detail="Cannot logout from current session using this endpoint")

    redis_session_manager.end_session(session_id)
    return None

session_schema:
from pydantic import BaseModel
from typing import List


class SessionSchema(BaseModel):
    session_id: str
    app_version: str | None
    device_name: str | None
    location: str | None
    last_activity: str | None
    is_ios: bool | None

class SessionResponse(BaseModel):
    current_session: SessionSchema
    other_sessions: List[SessionSchema]

redis_session_manager:

import redis
from datetime import datetime, timezone
import json
import uuid
import asyncio

class IntegratedAuthSessionManager:
    def __init__(self, redis_url):
        self.redis = redis.Redis(host=redis_url, port=6379, decode_responses=True)
        self.cleanup_interval = 60  # Run cleanup every 60 seconds

    async def start_cleanup_task(self):
        while True:
            await self.cleanup_expired_sessions()
            await asyncio.sleep(self.cleanup_interval)

    async def cleanup_expired_sessions(self):
        current_time = datetime.now(timezone.utc).isoformat()
        for key in self.redis.scan_iter("session:*"):
            session_data = self.redis.get(key)
            if session_data:
                session = json.loads(session_data)
                if session['expires_at'] <= current_time:
                    self.end_session(key.decode('utf-8').split(':')[1])

    def create_session(self, user_data):
        user_id = user_data['user_id']
        session_id = str(uuid.uuid4())

        session_data = {
            'user_id': user_id,
            'device_name': user_data['device_name'],
            'device_id': user_data['device_id'],
            'expires_at': user_data['expires_at'].isoformat(),
            'app_version': user_data.get('app_version'),
            'location': user_data.get('location'),
            'last_activity': datetime.now(timezone.utc).isoformat(),
            'device_unique_name': user_data.get('device_unique_name'),
            'is_ios': user_data.get('is_ios'),
        }

        # Store the session data with expiration
        self.redis.setex(f"session:{session_id}", int(user_data['expires_at'].timestamp()) - int(datetime.now(timezone.utc).timestamp()), json.dumps(session_data))

        # Add this session to the user's set of active sessions
        self.redis.sadd(f"user_sessions:{user_id}", session_id)

        return session_id

    def get_session(self, session_id):
        session_data = self.redis.get(f"session:{session_id}")
        if not session_data:
            return None

        session = json.loads(session_data)

        # Check if the session has expired
        current_time = datetime.now(timezone.utc).isoformat()
        if current_time > session['expires_at']:
            self.end_session(session_id)
            return None

        return session

    def end_session(self, session_id):
        session_data = self.redis.get(f"session:{session_id}")
        if session_data:
            session = json.loads(session_data)
            user_id = session['user_id']
            self.redis.delete(f"session:{session_id}")
            self.redis.srem(f"user_sessions:{user_id}", session_id)

    def update_last_activity(self, session_id):
        session_data = self.get_session(session_id)
        if session_data:
            session_data['last_activity'] = datetime.now(timezone.utc).isoformat()
            self.redis.set(f"session:{session_id}", json.dumps(session_data))

    def update_session(self, session_id, user_data):
        session_data = self.get_session(session_id)
        if session_data:
            session_data.update(user_data)
            self.redis.set(f"session:{session_id}", json.dumps(session_data))


    def get_sessions_by_user_and_device(self, user_id, device_id):
        """
        Retrieve all active sessions for a specific user and device.
        """
        # Get all session IDs associated with the user
        session_ids = self.redis.smembers(f"user_sessions:{user_id}")
        active_sessions = []

        # Iterate over all session IDs and filter by device_id
        for session_id in session_ids:
            session_data = self.get_session(session_id)
            if session_data:
                # Check if the session belongs to the given device_id
                if session_data.get('device_id') == device_id:
                    active_sessions.append(session_id)

        return active_sessions


redis_session_manager = IntegratedAuthSessionManager("redis")
user.device:
from odoo import models, fields


class UserDevice(models.Model):
    _name = 'user.device'
    _description = 'User Devices'

    partner_id = fields.Many2one('res.partner', string='User')
    device_name = fields.Char(string='Device Name')
    app_version = fields.Char(string='Version of Application')
    location = fields.Char(string='Location')
    last_login = fields.Datetime(string='Last Login')
    last_activity = fields.Datetime(string='Last Activity')
    device_unique_name = fields.Char(string='Device Unique Name')
    is_ios = fields.Boolean(string='Is IOS')

    def create(self, vals):
        record = super().create(vals)
        self.env['mobile.app.push.notification'].create({
            'name': 'New Device Login',
            'body': f'New login from device {record.device_name}',
            'notification_type': 'session',
            'model_name': 'user.device',
            'object_id': record.id,
            'send_notification_to': 'to_partner',
            'partner_ids': [(6, 0, [record.partner_id.id])]
        })
        return record

avoid to create new files, if you have to give me exact location where to create with directories, and send status in list and detail of session router response, keep in mind that i'm working with flutter mobile dev team, our solition should suitable for them too. In response give me solid, fully functional code, flutter team to their work, i dont need to know about it, i have postman, ngrok, and dockerized project is running on localhost. At the end of all this give me how to test this functionality with what i have, with all details. Give fully functional code without errors, before responding double check for errors like intense tester