- Added videoWorkflowRepository with methods to manage video and user interactions. - Introduced catalog_mapper for converting database models to protobuf representations. - Created domain_helpers for normalizing domain and ad format values. - Defined service interfaces for payment, account, notification, domain, ad template, player config, video, and user management. - Implemented OAuth helpers for generating state and caching keys. - Developed payment_proto_helpers for mapping payment-related models to protobuf. - Added service policy helpers to enforce plan requirements and user permissions. - Created user_mapper for converting user payloads to protobuf format. - Implemented value_helpers for handling various value conversions and nil checks. - Developed video_helpers for normalizing video statuses and managing storage types. - Created video_mapper for mapping video models to protobuf format. - Implemented render workflow for managing video creation and job processing.
57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
package service
|
|
|
|
import (
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
func normalizeVideoStatusValue(value string) string {
|
|
switch strings.ToLower(strings.TrimSpace(value)) {
|
|
case "processing", "pending":
|
|
return "processing"
|
|
case "failed", "error":
|
|
return "failed"
|
|
default:
|
|
return "ready"
|
|
}
|
|
}
|
|
|
|
func normalizeVideoStatusFilter(value string) string {
|
|
trimmed := strings.TrimSpace(value)
|
|
if trimmed == "" || strings.EqualFold(trimmed, "all") {
|
|
return ""
|
|
}
|
|
return normalizeVideoStatusValue(trimmed)
|
|
}
|
|
|
|
func detectStorageType(rawURL string) string {
|
|
if shouldDeleteStoredObject(rawURL) {
|
|
return "S3"
|
|
}
|
|
return "WORKER"
|
|
}
|
|
|
|
func shouldDeleteStoredObject(rawURL string) bool {
|
|
trimmed := strings.TrimSpace(rawURL)
|
|
if trimmed == "" {
|
|
return false
|
|
}
|
|
parsed, err := url.Parse(trimmed)
|
|
if err != nil {
|
|
return !strings.HasPrefix(trimmed, "/")
|
|
}
|
|
return parsed.Scheme == "" && parsed.Host == "" && !strings.HasPrefix(trimmed, "/")
|
|
}
|
|
|
|
func extractObjectKey(rawURL string) string {
|
|
trimmed := strings.TrimSpace(rawURL)
|
|
if trimmed == "" {
|
|
return ""
|
|
}
|
|
parsed, err := url.Parse(trimmed)
|
|
if err != nil {
|
|
return trimmed
|
|
}
|
|
return strings.TrimPrefix(parsed.Path, "/")
|
|
}
|