MCPcopy
hub / github.com/daptin/daptin / mailMessageFileName

Function mailMessageFileName

server/resource/mail_functions.go:148–166  ·  view source on GitHub ↗
(nameHint string, messageBytes []byte)

Source from the content-addressed store, hash-verified

146}
147
148func mailMessageFileName(nameHint string, messageBytes []byte) string {
149 name := strings.TrimSuffix(strings.TrimSpace(nameHint), ".eml")
150 if name == "" {
151 name = GetMD5Hash(messageBytes)
152 }
153 name = filepath.Base(sanitizeMailFileName(name))
154 name = strings.Trim(name, "._-")
155 if name == "" {
156 name = "message"
157 }
158 if len(name) > 96 {
159 name = name[:96]
160 }
161 u, err := uuid.NewV7()
162 if err != nil {
163 return name + ".eml"
164 }
165 return name + "-" + u.String() + ".eml"
166}
167
168func sanitizeMailFileName(value string) string {
169 var builder strings.Builder

Callers 1

MailColumnValueMethod · 0.85

Calls 3

sanitizeMailFileNameFunction · 0.85
GetMD5HashFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected