|
@ -3,8 +3,11 @@ package queries |
|
|
import ( |
|
|
import ( |
|
|
"context" |
|
|
"context" |
|
|
"errors" |
|
|
"errors" |
|
|
|
|
|
"log" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"git.aiterp.net/rpdata/api/models/stories" |
|
|
|
|
|
|
|
|
"git.aiterp.net/rpdata/api/models/characters" |
|
|
"git.aiterp.net/rpdata/api/models/characters" |
|
|
|
|
|
|
|
|
"git.aiterp.net/rpdata/api/models/changekeys" |
|
|
"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()) |
|
|
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 |
|
|
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()) |
|
|
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 |
|
|
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()) |
|
|
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 |
|
|
return comment, nil |
|
|
} |
|
|
} |