Phase 1C: Frontend unified contact UI
This commit is contained in:
@@ -14,10 +14,9 @@ from app.plugins.builtins.entity_links.models import EntityLink
|
||||
from app.plugins.builtins.entity_links.schemas import EntityLinkRequest
|
||||
|
||||
router = APIRouter(prefix="/api/v1/dms", tags=["entity-links"])
|
||||
company_router = APIRouter(prefix="/api/v1/companies", tags=["entity-links"])
|
||||
contact_router = APIRouter(prefix="/api/v1/contacts", tags=["entity-links"])
|
||||
|
||||
VALID_ENTITY_TYPES = {"company", "contact"}
|
||||
VALID_ENTITY_TYPES = {"contact"}
|
||||
|
||||
|
||||
def _parse_uuid(val: str, field: str) -> uuid.UUID:
|
||||
@@ -36,7 +35,7 @@ async def link_file_to_entity(
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: dict = Depends(get_current_user),
|
||||
):
|
||||
"""Link a file to a company or contact."""
|
||||
"""Link a file to a contact."""
|
||||
tenant_id = uuid.UUID(current_user["tenant_id"])
|
||||
user_id = uuid.UUID(current_user["user_id"])
|
||||
fid = _parse_uuid(file_id, "file_id")
|
||||
@@ -140,35 +139,6 @@ async def list_file_links(
|
||||
]
|
||||
|
||||
|
||||
@company_router.get("/{company_id}/files", dependencies=[Depends(require_permission("entity_links:read"))])
|
||||
async def list_company_files(
|
||||
company_id: str,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: dict = Depends(get_current_user),
|
||||
):
|
||||
"""List all files linked to a company (reverse link)."""
|
||||
tenant_id = uuid.UUID(current_user["tenant_id"])
|
||||
cid = _parse_uuid(company_id, "company_id")
|
||||
|
||||
result = await db.execute(
|
||||
select(EntityLink).where(
|
||||
EntityLink.tenant_id == tenant_id,
|
||||
EntityLink.entity_type == "company",
|
||||
EntityLink.entity_id == cid,
|
||||
)
|
||||
)
|
||||
links = result.scalars().all()
|
||||
return [
|
||||
{
|
||||
"id": str(link.id),
|
||||
"file_id": str(link.file_id),
|
||||
"entity_type": link.entity_type,
|
||||
"entity_id": str(link.entity_id),
|
||||
}
|
||||
for link in links
|
||||
]
|
||||
|
||||
|
||||
@contact_router.get("/{contact_id}/files", dependencies=[Depends(require_permission("entity_links:read"))])
|
||||
async def list_contact_files(
|
||||
contact_id: str,
|
||||
|
||||
Reference in New Issue
Block a user