github.com/ashishbhate/mattermost-server@v5.11.1+incompatible/model/audits.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package model
     5  
     6  import (
     7  	"encoding/json"
     8  	"io"
     9  )
    10  
    11  type Audits []Audit
    12  
    13  func (o Audits) Etag() string {
    14  	if len(o) > 0 {
    15  		// the first in the list is always the most current
    16  		return Etag(o[0].CreateAt)
    17  	} else {
    18  		return ""
    19  	}
    20  }
    21  
    22  func (o Audits) ToJson() string {
    23  	if b, err := json.Marshal(o); err != nil {
    24  		return "[]"
    25  	} else {
    26  		return string(b)
    27  	}
    28  }
    29  
    30  func AuditsFromJson(data io.Reader) Audits {
    31  	var o Audits
    32  	json.NewDecoder(data).Decode(&o)
    33  	return o
    34  }