From e07360d2b3dbbcd1aec42ac28b8c93e8fd279224 Mon Sep 17 00:00:00 2001 From: bagas Date: Tue, 17 Sep 2024 09:55:21 +0700 Subject: [PATCH] Add additional file types including executables and APK --- handler/user/user.go | 2 +- view/client/file/file.templ | 4 ++++ view/client/file/file_templ.go | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/handler/user/user.go b/handler/user/user.go index 020647d..ca0525f 100644 --- a/handler/user/user.go +++ b/handler/user/user.go @@ -157,7 +157,7 @@ func handlerWS(conn *websocket.Conn, userSession types.User) { } var file *models.File file, err = app.Server.Database.GetUserFile(uploadNewFile.Name, userSession.UserID.String()) - allowedFileTypes := []string{"jpg", "jpeg", "png", "gif", "bmp", "tiff", "pdf", "doc", "docx", "txt", "odt", "xls", "xlsx", "ppt", "pptx", "zip", "rar", "tar", "gz", "7z", "bz2"} + allowedFileTypes := []string{"jpg", "jpeg", "png", "gif", "bmp", "tiff", "pdf", "doc", "docx", "txt", "odt", "xls", "xlsx", "ppt", "pptx", "zip", "rar", "tar", "gz", "7z", "bz2", "exe", "bin", "sh", "bat", "cmd", "msi", "apk"} isAllowedFileType := func(fileType string) bool { for _, allowed := range allowedFileTypes { if fileType == allowed { diff --git a/view/client/file/file.templ b/view/client/file/file.templ index 934a9ea..646faee 100644 --- a/view/client/file/file.templ +++ b/view/client/file/file.templ @@ -442,6 +442,10 @@ templ FileIcon(fileType string) { } else if fileType == "zip" || fileType == "rar" || fileType == "tar" || fileType == "gz" || fileType == "7z" || fileType == "bz2" { + } else if fileType == "exe" || fileType == "bin" || fileType == "sh" || fileType == "bat" || fileType == "cmd" || fileType == "msi" { + + } else if fileType == "apk" { + } else { } diff --git a/view/client/file/file_templ.go b/view/client/file/file_templ.go index ce039b6..d672957 100644 --- a/view/client/file/file_templ.go +++ b/view/client/file/file_templ.go @@ -714,6 +714,16 @@ func FileIcon(fileType string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } + } else if fileType == "exe" || fileType == "bin" || fileType == "sh" || fileType == "bat" || fileType == "cmd" || fileType == "msi" { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else if fileType == "apk" { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } else { _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil {