add chapter repository to postgres.
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-03-26 23:50:33 +01:00
parent 525191a0f9
commit 663a95c70d
13 changed files with 420 additions and 5 deletions
+18
View File
@@ -16,6 +16,24 @@ type Chapter struct {
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()