news/news.go
func NewNewsItem(itemdata NewsItem, author uuid.UUID) (*NewsItem, error) {
	c := new(NewsItem)
	if err := mergo.MergeWithOverwrite(c, itemdata); err != nil {
		return nil, errors.New(err.Error() + " - Could not set initial NewsItem data")
	}
	c.UUID, _ = uuid.V4()
	c.Author = author
	c.Created = time.Now()
	if err := storage.Store(c); err != nil {
		return nil, errors.New(err.Error() + " - Could not write NewsItem to storage")
	}
	eventqueue.Publish(utils.CKPTEvent{
		Type:    utils.NEWS_EVENT,
		Subject: "Nytt bidrag lagt ut",
		Message: "Det er lagt ut et nytt bidrag på ckpt.no!"})
	return c, nil
}
func NewNewsItem(itemdata NewsItem, author uuid.UUID) (*NewsItem, error) {
	c := new(NewsItem)
	if err := mergo.MergeWithOverwrite(c, itemdata); err != nil {
		return nil, errors.New(err.Error() + " - Could not set initial NewsItem data")
	}
	c.UUID, _ = uuid.V4()
	c.Author = author
	c.Created = time.Now()
	if err := storage.Store(c); err != nil {
		return nil, errors.New(err.Error() + " - Could not write NewsItem to storage")
	}
	eventqueue.Publish(utils.CKPTEvent{
		Type:    utils.NEWS_EVENT,
		Subject: "Nytt bidrag lagt ut",
		Message: "Det er lagt ut et nytt bidrag på ckpt.no!"})
	return c, nil
}
func NewNewsItem ( itemdata NewsItem , author uuid . UUID ) ( * NewsItem , error ) { c := new ( NewsItem ) if err := mergo . MergeWithOverwrite ( c , itemdata ) ; err != nil { return nil , errors . New ( err . Error ( ) + " " ) } c . UUID , _ = uuid . V4 ( ) c . Author = author c . Created = time . Now ( ) if err := storage . Store ( c ) ; err != nil { return nil , errors . New ( err . Error ( ) + " " ) } eventqueue . Publish ( utils . CKPTEvent { Type : utils . NEWS_EVENT , Subject : " " , Message : " } ) return c , nil }
//
// NewsItem related functions and methods
//
// Create a NewsItem
NewsItem related functions and methods Create a NewsItem