openvk/CLI
Ilia Breitburg 5ae8b62cd1
fix(api): implement pending uploads cleanup and enhanced error response (#1384)
## Summary
- Implements automatic cleanup mechanism for pending photo uploads older
than 24 hours
- Enhances error response to include actionable information about
pending uploads
- Adds CLI command for manual cleanup with dry-run support

## Changes Made
- **CLI/CleanupPendingUploadsCommand.php**: New command to auto-delete
stale `.oct` files
- **Web/Presenters/VKAPIPresenter.php**: Enhanced error response with
pending upload details
- **openvkctl**: Added cleanup command to CLI bootstrap
- **CLI/README.md**: Documentation with usage examples and cron setup

## Problem Solved
When users encounter "There are 3 pending already" error, they now
receive:
1. **Structured JSON response** with upload details (ID, filename, size,
age, timestamp)
2. **Automatic cleanup** removes uploads older than 24 hours
3. **Manual cleanup** available via CLI command with configurable age
threshold

## Usage
```bash
# Auto-cleanup (daily cron recommended)
php openvkctl cleanup-pending-uploads

# Custom age threshold
php openvkctl cleanup-pending-uploads --max-age=1

# Preview what would be deleted
php openvkctl cleanup-pending-uploads --dry-run
```

Fixes #1275
2025-07-15 23:19:30 +03:00
..
CleanupPendingUploadsCommand.php fix(api): implement pending uploads cleanup and enhanced error response (#1384) 2025-07-15 23:19:30 +03:00
FetchToncoinTransactions.php feat: database upgrade command (#1236) 2025-05-19 23:38:47 +03:00
README.md fix(api): implement pending uploads cleanup and enhanced error response (#1384) 2025-07-15 23:19:30 +03:00
RebuildImagesCommand.php feat: database upgrade command (#1236) 2025-05-19 23:38:47 +03:00
UpgradeCommand.php feat: database upgrade command (#1236) 2025-05-19 23:38:47 +03:00

OpenVK CLI Commands

This directory contains command-line utilities for OpenVK management.

Available Commands

cleanup-pending-uploads

Automatically removes pending photo uploads older than the specified time.

Usage:

# Clean up uploads older than 24 hours (default)
php openvkctl cleanup-pending-uploads

# Clean up uploads older than 1 hour
php openvkctl cleanup-pending-uploads --max-age=1

# Dry run to see what would be deleted
php openvkctl cleanup-pending-uploads --dry-run

Options:

  • --max-age, -a: Maximum age in hours (default: 24)
  • --dry-run, -d: Show what would be deleted without actually deleting

Cron Setup: To automatically clean up pending uploads daily, add to your crontab:

# Clean up pending uploads daily at 2 AM
0 2 * * * cd /path/to/openvk && php openvkctl cleanup-pending-uploads

build-images

Rebuilds photo thumbnails and image sizes.

fetch-toncoin-transactions

Fetches Toncoin transactions for payment processing.

upgrade

Performs database upgrades and migrations.