feat:pull the slack message service out to slack pkg
Signed-off-by: manish-singh-bisht <mthefool218@gmail.com>
This commit is contained in:
committed by
Émile Ré
parent
7cb6edcbb5
commit
8eeab0a6d0
31
pkg/slack/connector_config.go
Normal file
31
pkg/slack/connector_config.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package slack
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var (
|
||||
accessRequestTemplate = template.Must(
|
||||
template.New("access-request.json.tmpl").
|
||||
Funcs(template.FuncMap{
|
||||
"jsonEscape": func(s string) string {
|
||||
b, _ := json.Marshal(s)
|
||||
return string(b[1 : len(b)-1])
|
||||
},
|
||||
"buildAcceptAllValue": func(docIDs, repIDs []string) string {
|
||||
value := map[string][]string{
|
||||
"document_ids": docIDs,
|
||||
"report_ids": repIDs,
|
||||
}
|
||||
b, _ := json.Marshal(value)
|
||||
s := string(b)
|
||||
s = strings.ReplaceAll(s, `\`, `\\`)
|
||||
s = strings.ReplaceAll(s, `"`, `\"`)
|
||||
return s
|
||||
},
|
||||
}).
|
||||
ParseFS(Templates, "templates/access-request.json.tmpl"),
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user