2022-10-19 03:25:43 +04:00
|
|
|
package guestbook
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Reply struct {
|
2022-10-21 04:38:08 +04:00
|
|
|
ID int64 `json:"id,omitempty"`
|
2022-10-19 03:25:43 +04:00
|
|
|
Created string `json:"created,omitempty"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewReply(entryID int64, message string) (*Reply, error) {
|
|
|
|
if message == "" {
|
|
|
|
return nil, errors.New("empty reply field")
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Reply{
|
|
|
|
ID: entryID,
|
|
|
|
Created: time.Now().UTC().Format(DateFormat),
|
|
|
|
Message: message}, nil
|
|
|
|
}
|