Add Blossom blob storage server and subscription management
- Introduced the `initializeBlossomServer` function to set up the Blossom blob storage server with dynamic base URL handling and ACL configuration. - Implemented the `blossomHandler` method to manage incoming requests to the Blossom API, ensuring proper URL handling and context management. - Enhanced the `PaymentProcessor` to support Blossom service levels, allowing for subscription extensions based on payment metadata. - Added methods for parsing and validating Blossom service levels, including storage quota management and subscription extension logic. - Updated the configuration to include Blossom service level settings, facilitating dynamic service level management. - Integrated storage quota checks in the blob upload process to prevent exceeding allocated limits. - Refactored existing code to improve organization and maintainability, including the removal of unused blob directory configurations. - Added tests to ensure the robustness of new functionalities and maintain existing behavior across blob operations.
This commit is contained in:
@@ -27,7 +27,6 @@ type Config struct {
|
||||
MaxBlobSize int64
|
||||
AllowedMimeTypes []string
|
||||
RequireAuth bool
|
||||
BlobDir string // Directory for storing blob files
|
||||
}
|
||||
|
||||
// NewServer creates a new Blossom server instance
|
||||
@@ -39,7 +38,7 @@ func NewServer(db *database.D, aclRegistry *acl.S, cfg *Config) *Server {
|
||||
}
|
||||
}
|
||||
|
||||
storage := NewStorage(db, cfg.BlobDir)
|
||||
storage := NewStorage(db)
|
||||
|
||||
// Build allowed MIME types map
|
||||
allowedMap := make(map[string]bool)
|
||||
@@ -198,3 +197,14 @@ func (s *Server) checkACL(
|
||||
|
||||
return actual >= required
|
||||
}
|
||||
|
||||
// getBaseURL returns the base URL, preferring request context if available
|
||||
func (s *Server) getBaseURL(r *http.Request) string {
|
||||
type baseURLKey struct{}
|
||||
if baseURL := r.Context().Value(baseURLKey{}); baseURL != nil {
|
||||
if url, ok := baseURL.(string); ok && url != "" {
|
||||
return url
|
||||
}
|
||||
}
|
||||
return s.baseURL
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user