Browse Source

Added story to comment changes.

module-madness-pointers
Gisle Aune 5 years ago
parent
commit
db4d46c368
  1. 33
      graph2/queries/comment.go
  2. 3
      graph2/schema/types/Comment.gql

33
graph2/queries/comment.go

@ -3,8 +3,11 @@ package queries
import (
"context"
"errors"
"log"
"time"
"git.aiterp.net/rpdata/api/models/stories"
"git.aiterp.net/rpdata/api/models/characters"
"git.aiterp.net/rpdata/api/models/changekeys"
@ -69,7 +72,15 @@ func (r *mutationResolver) AddComment(ctx context.Context, input input.CommentAd
return models.Comment{}, errors.New("Failed to add comment: " + err.Error())
}
go changes.Submit("Comment", "add", token.UserID, true, changekeys.Many(comment, chapter, models.Story{ID: chapter.StoryID}), comment, chapter)
go func() {
story, err := stories.FindID(chapter.StoryID)
if err != nil {
log.Println("WARNING: Couldn't log comment change:", err)
return
}
changes.Submit("Comment", "add", token.UserID, true, changekeys.Many(comment, chapter, models.Story{ID: chapter.StoryID}), comment, chapter, story)
}()
return comment, nil
}
@ -112,7 +123,15 @@ func (r *mutationResolver) EditComment(ctx context.Context, input input.CommentE
return models.Comment{}, errors.New("Could not post comment: " + err.Error())
}
go changes.Submit("Comment", "edit", token.UserID, true, changekeys.Many(comment, chapter, models.Story{ID: chapter.StoryID}), comment, chapter)
go func() {
story, err := stories.FindID(chapter.StoryID)
if err != nil {
log.Println("WARNING: Couldn't log comment change:", err)
return
}
changes.Submit("Comment", "edit", token.UserID, true, changekeys.Many(comment, chapter, models.Story{ID: chapter.StoryID}), comment, chapter, story)
}()
return comment, nil
}
@ -142,5 +161,15 @@ func (r *mutationResolver) RemoveComment(ctx context.Context, input input.Commen
return models.Comment{}, errors.New("Failed to remove comment: " + err.Error())
}
go func() {
story, err := stories.FindID(chapter.StoryID)
if err != nil {
log.Println("WARNING: Couldn't log comment change:", err)
return
}
changes.Submit("Comment", "remove", token.UserID, true, changekeys.Many(comment, chapter, models.Story{ID: chapter.StoryID}), comment, chapter, story)
}()
return comment, nil
}

3
graph2/schema/types/Comment.gql

@ -8,6 +8,9 @@ type Comment {
"subject"
subject: String!
"The chapter ID the comment belongs to."
chapterId: String!
"The comment's author."
author: String!

Loading…
Cancel
Save