| 541 | return summary |
| 542 | |
| 543 | async def _build_admin_file_item( |
| 544 | self, file_code: FileCodes, now: Optional[datetime] = None |
| 545 | ) -> dict[str, Any]: |
| 546 | if now is None: |
| 547 | now = await get_now() |
| 548 | is_text = file_code.text is not None |
| 549 | is_expired = await file_code.is_expired() |
| 550 | name = f"{file_code.prefix}{file_code.suffix}" |
| 551 | has_download_limit = file_code.expired_count >= 0 |
| 552 | is_permanent = file_code.expired_at is None and file_code.expired_count < 0 |
| 553 | can_download = is_text or bool(file_code.file_path or file_code.uuid_file_name) |
| 554 | remaining_downloads = ( |
| 555 | max(file_code.expired_count, 0) if file_code.expired_count >= 0 else None |
| 556 | ) |
| 557 | data = { |
| 558 | "id": file_code.id, |
| 559 | "code": file_code.code, |
| 560 | "prefix": file_code.prefix, |
| 561 | "suffix": file_code.suffix, |
| 562 | "uuid_file_name": file_code.uuid_file_name, |
| 563 | "file_path": file_code.file_path, |
| 564 | "size": file_code.size or 0, |
| 565 | "text": file_code.text, |
| 566 | "expired_at": file_code.expired_at, |
| 567 | "expired_count": file_code.expired_count, |
| 568 | "used_count": file_code.used_count, |
| 569 | "created_at": file_code.created_at, |
| 570 | "file_hash": file_code.file_hash, |
| 571 | "is_chunked": file_code.is_chunked, |
| 572 | "upload_id": file_code.upload_id, |
| 573 | } |
| 574 | data.update( |
| 575 | { |
| 576 | "name": name, |
| 577 | "type": "text" if is_text else "file", |
| 578 | "status": "expired" if is_expired else "active", |
| 579 | "isText": is_text, |
| 580 | "is_text": is_text, |
| 581 | "isExpired": is_expired, |
| 582 | "is_expired": is_expired, |
| 583 | "isChunked": file_code.is_chunked, |
| 584 | "is_chunked": file_code.is_chunked, |
| 585 | "remainingDownloads": remaining_downloads, |
| 586 | "remaining_downloads": remaining_downloads, |
| 587 | "usedCount": file_code.used_count, |
| 588 | "used_count": file_code.used_count, |
| 589 | "createdAt": file_code.created_at, |
| 590 | "created_at": file_code.created_at, |
| 591 | "expiredAt": file_code.expired_at, |
| 592 | "expired_at": file_code.expired_at, |
| 593 | "fileHash": file_code.file_hash, |
| 594 | "file_hash": file_code.file_hash, |
| 595 | } |
| 596 | ) |
| 597 | status_insights = self._build_file_status_insights( |
| 598 | file_code=file_code, |
| 599 | detail=data, |
| 600 | now=now, |