GraphQL API and utilities for the rpdata project
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package models
import "time"
// A Chapter is a part of a story.
type Chapter struct { ID string `bson:"_id"` StoryID string `bson:"storyId"` Title string `bson:"title"` Author string `bson:"author"` Source string `bson:"source"` CreatedDate time.Time `bson:"createdDate"` FictionalDate time.Time `bson:"fictionalDate,omitempty"` EditedDate time.Time `bson:"editedDate"` CommentMode ChapterCommentMode `bson:"commentMode"` CommentsLocked bool `bson:"commentsLocked"` }
func (chapter *Chapter) ApplyUpdate(update ChapterUpdate) { if update.Title != nil { chapter.Title = *update.Title } if update.Source != nil { chapter.Source = *update.Source } if update.FictionalDate != nil { chapter.FictionalDate = update.FictionalDate.UTC() } if update.CommentMode != nil { chapter.CommentMode = *update.CommentMode } if update.CommentsLocked != nil { chapter.CommentsLocked = *update.CommentsLocked } }
// CanComment returns true if the chapter can be commented to.
func (chapter *Chapter) CanComment() bool { return !chapter.CommentsLocked && chapter.CommentMode.IsEnabled() }
// IsChangeObject is an interface implementation to identify it as a valid
// ChangeObject in GQL.
func (*Chapter) IsChangeObject() { panic("this method is a dummy, and so is its caller") }
type ChapterFilter struct { StoryID *string Limit int }
type ChapterUpdate struct { Title *string Source *string FictionalDate *time.Time CommentMode *ChapterCommentMode CommentsLocked *bool }
|