-
Notifications
You must be signed in to change notification settings - Fork 1
/
message.go
33 lines (29 loc) · 1.11 KB
/
message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package actions
import (
"bytes"
"log"
"net/url"
"strings"
"github.com/khulnasoft-lab/hooker/v2/layout"
)
const hookerDocsUrl = "https://khulnasoft-lab.github.io/hooker/settings/"
func buildShortMessage(server, urls string, provider layout.LayoutProvider) string {
var builder bytes.Buffer
if len(server) > 0 && len(urls) > 0 {
builder.WriteString(provider.P("This message is too long to display here. Please visit the link to read the content."))
links := strings.Split(urls, "\n")
for _, link := range links {
linkTitle, err := url.QueryUnescape(link)
if err != nil {
log.Printf("Query unescape error: %s", err)
}
builder.WriteString(provider.P(provider.A(link, linkTitle)))
}
} else if len(server) == 0 {
builder.WriteString(provider.P("Please configure Khulnasoft server url to get link to entire scan results."))
builder.WriteString(provider.P(provider.A(hookerDocsUrl, "Hooker settings")))
} else {
builder.WriteString(provider.P("Unable to create link to entire scan results. Input message doesn't contain 'registry' and 'image' fields or they are empty"))
}
return builder.String()
}