🐛 Fix image proxy doesn't work
This commit is contained in:
		@@ -23,7 +23,6 @@ var (
 | 
				
			|||||||
func BuildDestinationMapping() {
 | 
					func BuildDestinationMapping() {
 | 
				
			||||||
	count := len(cast.ToSlice(viper.Get("destinations")))
 | 
						count := len(cast.ToSlice(viper.Get("destinations")))
 | 
				
			||||||
	for idx := 0; idx < count; idx++ {
 | 
						for idx := 0; idx < count; idx++ {
 | 
				
			||||||
		fmt.Println(idx)
 | 
					 | 
				
			||||||
		destMap := viper.GetStringMap(fmt.Sprintf("destinations.%d", idx))
 | 
							destMap := viper.GetStringMap(fmt.Sprintf("destinations.%d", idx))
 | 
				
			||||||
		var parsed models.BaseDestination
 | 
							var parsed models.BaseDestination
 | 
				
			||||||
		raw, _ := jsoniter.Marshal(destMap)
 | 
							raw, _ := jsoniter.Marshal(destMap)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,6 @@ import (
 | 
				
			|||||||
	"math/rand/v2"
 | 
						"math/rand/v2"
 | 
				
			||||||
	nurl "net/url"
 | 
						nurl "net/url"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"strings"
 | 
					 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"git.solsynth.dev/hypernet/nexus/pkg/nex/cachekit"
 | 
						"git.solsynth.dev/hypernet/nexus/pkg/nex/cachekit"
 | 
				
			||||||
@@ -109,7 +108,13 @@ func OpenAttachmentByRID(rid string, preview bool, region ...string) (url string
 | 
				
			|||||||
	case models.DestinationTypeS3:
 | 
						case models.DestinationTypeS3:
 | 
				
			||||||
		var destConfigured models.S3Destination
 | 
							var destConfigured models.S3Destination
 | 
				
			||||||
		_ = jsoniter.Unmarshal(rawDest, &destConfigured)
 | 
							_ = jsoniter.Unmarshal(rawDest, &destConfigured)
 | 
				
			||||||
		if destConfigured.EnableSigned {
 | 
							if len(destConfigured.AccessBaseURL) > 0 {
 | 
				
			||||||
 | 
								url = fmt.Sprintf(
 | 
				
			||||||
 | 
									"%s/%s",
 | 
				
			||||||
 | 
									destConfigured.AccessBaseURL,
 | 
				
			||||||
 | 
									nurl.QueryEscape(filepath.Join(destConfigured.Path, result.Attachment.Uuid)),
 | 
				
			||||||
 | 
								)
 | 
				
			||||||
 | 
							} else if destConfigured.EnableSigned {
 | 
				
			||||||
			var client *minio.Client
 | 
								var client *minio.Client
 | 
				
			||||||
			client, err = destConfigured.GetClient()
 | 
								client, err = destConfigured.GetClient()
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
@@ -123,14 +128,6 @@ func OpenAttachmentByRID(rid string, preview bool, region ...string) (url string
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			url = uri.String()
 | 
								url = uri.String()
 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if len(destConfigured.AccessBaseURL) > 0 {
 | 
					 | 
				
			||||||
			url = fmt.Sprintf(
 | 
					 | 
				
			||||||
				"%s/%s",
 | 
					 | 
				
			||||||
				destConfigured.AccessBaseURL,
 | 
					 | 
				
			||||||
				nurl.QueryEscape(filepath.Join(destConfigured.Path, result.Attachment.Uuid)),
 | 
					 | 
				
			||||||
			)
 | 
					 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			protocol := lo.Ternary(destConfigured.EnableSSL, "https", "http")
 | 
								protocol := lo.Ternary(destConfigured.EnableSSL, "https", "http")
 | 
				
			||||||
			url = fmt.Sprintf(
 | 
								url = fmt.Sprintf(
 | 
				
			||||||
@@ -148,7 +145,7 @@ func OpenAttachmentByRID(rid string, preview bool, region ...string) (url string
 | 
				
			|||||||
				destConfigured.ImageProxyURL,
 | 
									destConfigured.ImageProxyURL,
 | 
				
			||||||
				size,
 | 
									size,
 | 
				
			||||||
				size,
 | 
									size,
 | 
				
			||||||
				strings.Replace(url, destConfigured.AccessBaseURL, "", 1),
 | 
									url,
 | 
				
			||||||
			)
 | 
								)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user