Oliver-ai-bot_2.0/backend/app/models/slash_command.py
Vadym Samoilenko 96ecc59f0f feat: add open_as_popup mode for slash commands requiring MS auth
Microsoft MSAL redirect flow is blocked in iframes by browsers.
When open_as_popup is enabled, the command opens a real browser
popup window (window.open) instead of an iframe modal — MSAL auth
works correctly there.

- Migration 018_slash_popup: add open_as_popup boolean column
- Admin UI: new checkbox with explanation, purple Popup badge in list
- chat-input: if open_as_popup, calls window.open() centered on screen
  instead of showing IframeModal

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 19:05:11 +00:00

23 lines
995 B
Python

"""
SlashCommand model — chat slash commands managed via admin panel
"""
from sqlalchemy import Column, String, Text, Boolean, Integer, DateTime
from sqlalchemy.dialects.postgresql import UUID
from app.database import Base
import uuid
from datetime import datetime
class SlashCommand(Base):
__tablename__ = "slash_commands"
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
name = Column(String(100), unique=True, nullable=False, index=True)
url = Column(Text, nullable=False)
description = Column(Text, nullable=False)
is_enabled = Column(Boolean, default=True, nullable=False)
sort_order = Column(Integer, default=0, nullable=False)
pass_token = Column(Boolean, default=False, nullable=False)
open_as_popup = Column(Boolean, default=False, nullable=False)
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)