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.

41 lines
1.2 KiB

  1. package models
  2. import "time"
  3. // A Chapter is a part of a story.
  4. type Chapter struct {
  5. ID string `bson:"_id"`
  6. StoryID string `bson:"storyId"`
  7. Title string `bson:"title"`
  8. Author string `bson:"author"`
  9. Source string `bson:"source"`
  10. CreatedDate time.Time `bson:"createdDate"`
  11. FictionalDate time.Time `bson:"fictionalDate,omitempty"`
  12. EditedDate time.Time `bson:"editedDate"`
  13. CommentMode ChapterCommentMode `bson:"commentMode"`
  14. CommentsLocked bool `bson:"commentsLocked"`
  15. }
  16. // CanComment returns true if the chapter can be commented to.
  17. func (chapter *Chapter) CanComment() bool {
  18. return !chapter.CommentsLocked && chapter.CommentMode.IsEnabled()
  19. }
  20. // IsChangeObject is an interface implementation to identify it as a valid
  21. // ChangeObject in GQL.
  22. func (*Chapter) IsChangeObject() {
  23. panic("this method is a dummy, and so is its caller")
  24. }
  25. type ChapterFilter struct {
  26. StoryID *string
  27. Limit int
  28. }
  29. type ChapterUpdate struct {
  30. Title *string
  31. Source *string
  32. FictionalDate *time.Time
  33. CommentMode *ChapterCommentMode
  34. CommentsLocked *bool
  35. }