新增合作与反馈入口配置

This commit is contained in:
yml2213
2026-08-15 16:37:30 +08:00
parent 134d6fa05e
commit d9f552577a
14 changed files with 332 additions and 36 deletions
+2 -1
View File
@@ -72,7 +72,8 @@ func (h *Handler) writeObject(c *gin.Context, publicOnly bool) {
!strings.HasPrefix(key, "announcement/") &&
!strings.HasPrefix(key, "mohong/") &&
!strings.HasPrefix(key, "crash/") &&
!strings.HasPrefix(key, "aw-recycle/") {
!strings.HasPrefix(key, "aw-recycle/") &&
!strings.HasPrefix(key, "cooperation-feedback/") {
response.Error(c, http.StatusNotFound, "not_found", "文件不存在或暂不可访问")
return
}
+2 -2
View File
@@ -106,7 +106,7 @@ func normalizeContentType(contentType string, data []byte) string {
func fileURLForScene(scene string, key string) string {
fileURL := "/api/files/object?key=" + url.QueryEscape(key)
if scene == "home-banner" || scene == "avatar" || scene == "payment-cert" || scene == "announcement" || scene == "mohong" || scene == "crash" || scene == "aw-recycle" {
if scene == "home-banner" || scene == "avatar" || scene == "payment-cert" || scene == "announcement" || scene == "mohong" || scene == "crash" || scene == "aw-recycle" || scene == "cooperation-feedback" {
fileURL = "/api/public/files/object?key=" + url.QueryEscape(key)
}
return fileURL
@@ -115,7 +115,7 @@ func fileURLForScene(scene string, key string) string {
func normalizeScene(scene string) string {
scene = strings.TrimSpace(strings.ToLower(scene))
switch scene {
case "listing", "handoff", "dispute", "realname", "avatar", "home-banner", "chat", "payment-cert", "announcement", "qrcode", "mohong", "crash", "aw-recycle", "manual-disbursement":
case "listing", "handoff", "dispute", "realname", "avatar", "home-banner", "chat", "payment-cert", "announcement", "qrcode", "mohong", "crash", "aw-recycle", "cooperation-feedback", "manual-disbursement":
return scene
default:
return "misc"
@@ -40,3 +40,14 @@ func TestAWRecycleSceneUsesPublicFileURL(t *testing.T) {
t.Fatalf("aw-recycle file url = %q, want public file endpoint", got)
}
}
func TestCooperationFeedbackSceneUsesPublicFileURL(t *testing.T) {
if got := normalizeScene("cooperation-feedback"); got != "cooperation-feedback" {
t.Fatalf("normalize cooperation-feedback scene = %q", got)
}
key := "cooperation-feedback/2026/07/19/example.webp"
got := fileURLForScene("cooperation-feedback", key)
if !strings.HasPrefix(got, "/api/public/files/object?") {
t.Fatalf("cooperation-feedback file url = %q, want public file endpoint", got)
}
}