-
Notifications
You must be signed in to change notification settings - Fork 0
/
campid.go
executable file
·77 lines (64 loc) · 1.88 KB
/
campid.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package campid
import (
"io"
"github.com/blevesearch/bleve/v2"
"github.com/blevesearch/bleve/v2/mapping"
"github.com/influx6/npkg/nerror"
)
const (
AuthHeader = "Authorization"
RefreshHeader = "REFRESH-HEADER"
UserAgentHeader = "User-Agent"
DeviceCookieName = "SABU_DeviceCookie"
DeviceFingerprintCookieName = "Fingerprint"
DeviceHeaderName = "X-SABU-Device"
)
type Mail struct {
Email string
BC []string
CC []string
Message []byte
Attachments map[string][]byte
Files map[string]io.ReadCloser
}
type Mailer interface {
SendMail(mail *Mail) error
}
type Message struct {
Phone string
CountryCode string
AreaCode string
Message []byte
}
type Telephone interface {
SendText(msg *Message) error
}
func CreateIndexMappingForAll() (mapping.IndexMapping, error) {
var userMapping, err = CreateUserDocumentMapping()
if err != nil {
return nil, nerror.WrapOnly(err)
}
var roleMapping, roleMappingErr = CreateDeviceDocumentMapping()
if roleMappingErr != nil {
return nil, nerror.WrapOnly(roleMappingErr)
}
var deviceMapping, deviceErr = CreateDeviceDocumentMapping()
if deviceErr != nil {
return nil, nerror.WrapOnly(deviceErr)
}
var groupMapping, groupMappingErr = CreateDeviceDocumentMapping()
if groupMappingErr != nil {
return nil, nerror.WrapOnly(groupMappingErr)
}
var sessionMapping, sessionMappingErr = CreateDeviceDocumentMapping()
if sessionMappingErr != nil {
return nil, nerror.WrapOnly(sessionMappingErr)
}
indexMapping := bleve.NewIndexMapping()
indexMapping.AddDocumentMapping("User", userMapping)
indexMapping.AddDocumentMapping("Device", deviceMapping)
indexMapping.AddDocumentMapping("Role", roleMapping)
indexMapping.AddDocumentMapping("Group", groupMapping)
indexMapping.AddDocumentMapping("Zone", sessionMapping)
return indexMapping, nil
}