Этот коммит содержится в:
Claudio Costa
2021-10-21 20:29:17 +02:00
коммит произвёл GitHub
родитель 246a0c297e
Коммит deac72d2be
2 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@@ -25,6 +25,10 @@ func AuditModelTypeConv(val interface{}) (newVal interface{}, converted bool) {
return newAuditUser(v), true
case User:
return newAuditUser(&v), true
case *UserPatch:
return newAuditUserPatch(v), true
case UserPatch:
return newAuditUserPatch(&v), true
case *Command:
return newAuditCommand(v), true
case Command:
@@ -168,6 +172,21 @@ func newAuditUser(u *User) auditUser {
return user
}
type auditUserPatch struct {
Name string
}
// newAuditUserPatch creates a simplified representation of UserPatch for output to audit log.
func newAuditUserPatch(up *UserPatch) auditUserPatch {
var userPatch auditUserPatch
if up != nil {
if up.Username != nil {
userPatch.Name = *up.Username
}
}
return userPatch
}
func (u auditUser) MarshalJSONObject(enc *gojay.Encoder) {
enc.StringKey("id", u.ID)
enc.StringKey("name", u.Name)