-
Notifications
You must be signed in to change notification settings - Fork 1
/
openmessaging_from.go
39 lines (35 loc) · 960 Bytes
/
openmessaging_from.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
package gcloudcx
import (
"github.com/gildas/go-errors"
"github.com/gildas/go-logger"
)
type OpenMessageFrom struct {
ID string `json:"id"`
Type string `json:"idType,omitempty"`
Firstname string `json:"firstName,omitempty"`
Lastname string `json:"lastName,omitempty"`
Nickname string `json:"nickname,omitempty"`
}
// Redact redacts sensitive data
//
// implements logger.Redactable
func (from OpenMessageFrom) Redact() interface{} {
redacted := from
if len(from.Firstname) > 0 {
redacted.Firstname = logger.RedactWithHash(from.Firstname)
}
if len(from.Lastname) > 0 {
redacted.Lastname = logger.RedactWithHash(from.Lastname)
}
if len(from.Nickname) > 0 {
redacted.Nickname = logger.RedactWithHash(from.Nickname)
}
return redacted
}
// Validate checks if the object is valid
func (from *OpenMessageFrom) Validate() (err error) {
if len(from.ID) == 0 {
return errors.ArgumentMissing.With("channel.from.id")
}
return
}