-
-
Notifications
You must be signed in to change notification settings - Fork 266
feat(gotify): Add public URL support and configurable image quality #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat(gotify): Add public URL support and configurable image quality #1126
Conversation
This introduces a reusable system for serving images publicly without authentication, useful for external notification services like Gotify, Discord, or Telegram. Features: - Token-based public image access via /api/v1/publicimage endpoint - No authentication required for accessing images with valid tokens - Configurable expiration time (default: 24 hours, max: 31 days) - Persistent storage in /config/public_images/ (survives restarts) - Automatic cleanup of expired images (periodic + on startup) - Validates file existence even if token not in memory (handles restarts) Configuration options: - public_base_url: External URL for Viseron (e.g., https://viseron.example.com) - public_url_expiry_hours: How long public URLs remain valid (default: 24) Technical details: - Images stored with UUID token as filename - Tokens stored in memory with expiration timestamp - After restart, API falls back to disk lookup if token not in memory - Hourly cleanup task removes expired tokens and files - Startup cleanup removes orphaned files older than max expiry - Supports JPG and PNG formats Example usage: ```yaml webserver: public_base_url: "https://viseron.example.com" public_url_expiry_hours: 48 ```
This adds support for using the webserver's public image URL system in Gotify notifications, allowing images to be viewed from external networks without authentication. Also improves image quality configuration for high-resolution cameras. Depends on: Public image URL system (#PR1_NUMBER) Features: - New option: use_public_url (default: false) to use public URLs instead of base64 - Images are now persistent and accessible after Viseron restart - Configurable image quality (image_quality: 1-100, default: 95) - Configurable image size (image_max_size: 0-7680, default: 800) - Set to 0 to disable resizing (use original camera resolution) - Recommended: 1920 for 4K cameras, 0 for maximum quality - Images saved to persistent directory instead of /tmp/ - Retrieves public_base_url and public_url_expiry_hours from webserver config Configuration changes: - Moved public_base_url to webserver config (was in Gotify) - Moved public_url_expiry_hours to webserver config (was in Gotify) - These are now global settings usable by all notification components Image quality improvements: - Base64 images now use configured JPEG quality - Public URL images use configured quality and size - Fixes low quality issue with 4K cameras (was hardcoded to 800px) Example configuration: ```yaml webserver: public_base_url: "https://viseron.example.com" public_url_expiry_hours: 168 # 7 days gotify: gotify_url: "https://gotify.example.com" gotify_token: "your-token" use_public_url: true image_max_size: 1920 # For 4K cameras image_quality: 95 # High quality JPEG cameras: camera_name: {} ``` Fixes: - Images from 4K cameras are no longer limited to 800x450px - Public URLs survive container restarts - Better image quality control for all notification types
✅ Deploy Preview for viseron ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Remove unused datetime import in publicimage.py - Fix type annotation for _cleanup_task (asyncio.Task | None) - Simplify cleanup task cancellation to avoid unreachable code
- Break long log messages to stay within 88 character limit - Use %s formatting instead of f-strings for long messages - Shorten comments while preserving meaning
- Move WEBSERVER_COMPONENT import to module level - Break long DESC_IMAGE_QUALITY string across lines - Remove useless broad-except suppression comment
Thank you and great job on this! Otherwise i think everything looks good. |
Add documentation for the new public_base_url and public_url_expiry_hours configuration options that enable public image URL generation with token-based access.
Add documentation for new Gotify features: - use_public_url option to generate temporary public URLs for images - image_max_size to control thumbnail dimensions (default 800px) - image_quality to control JPEG quality (default 95) These options allow better control over image delivery and file sizes.
Yes, you're right, I forgot about the documentation. I just updated them, it should be good now. |
The cleanup of expired public images was incorrectly using utcnow() which could cause premature deletion when the system timezone differs from UTC. Changed to use current system time for file mtime comparisons. Also simplified the cleanup logic to be file-based rather than token-based, making it more robust across restarts.
Add configurable download limit for public image tokens to automatically delete images after a specified number of downloads. Changes: - Add remaining_downloads field to PublicImageToken dataclass - Implement download counter decrement in publicimage API - Add automatic cleanup after final download - Add public_url_max_downloads configuration parameter (default: 0 = unlimited) - Update webserver documentation with usage examples Configuration: - 0 (default): Unlimited downloads - 1: Single-use URL (perfect for notifications) - N > 1: Limited sharing (delete after N downloads)
…blic-url-support Add download limit feature for public image URLs.
Update Gotify component to use the new public_url_max_downloads configuration parameter when creating public image tokens. Changes: - Get max_downloads from webserver configuration - Pass max_downloads as remaining_downloads to PublicImageToken - Default behavior: 0 = unlimited downloads (only time expiration applies)
Summary
Depends on: #1125
This adds support for using the webserver's public image URL system in Gotify notifications, allowing images to be viewed from external networks without authentication. Also improves image quality configuration for high-resolution cameras.
Features
Public URL Support
use_public_url
(default: false) to use public URLs instead of base64public_base_url
andpublic_url_expiry_hours
from webserver configImage Quality Improvements
image_quality
(1-100, default: 95)image_max_size
(0-7680, default: 800)0
to disable resizing (use original camera resolution)1920
for 4K camerasConfiguration Changes
public_base_url
from Gotify to webserver (global setting)public_url_expiry_hours
from Gotify to webserver (global setting)Configuration
Before (old way - base64 only)
Result: 800x450px image, ~87KB, base64 encoded
After (new way - public URLs with high quality)
Result: 1920x1080px image, high quality, accessible after restart
Fixes
/config/public_images/
)Breaking Changes
None - all new options have sensible defaults. Existing configurations continue to work unchanged.
Testing
public_base_url
use_public_url: true
in Gotify