|  | @ -7,24 +7,22 @@ import ( | 
		
	
		
			
				|  |  | 	"git.aiterp.net/rpdata/api/internal/session" |  |  | 	"git.aiterp.net/rpdata/api/internal/session" | 
		
	
		
			
				|  |  | 	"git.aiterp.net/rpdata/api/model/change" |  |  | 	"git.aiterp.net/rpdata/api/model/change" | 
		
	
		
			
				|  |  | 	"git.aiterp.net/rpdata/api/model/story" |  |  | 	"git.aiterp.net/rpdata/api/model/story" | 
		
	
		
			
				|  |  |  |  |  | 	"git.aiterp.net/rpdata/api/resolver/types" | 
		
	
		
			
				|  |  | ) |  |  | ) | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | // ChapterResolver for the Chapter graphql type
 |  |  |  | 
		
	
		
			
				|  |  | type ChapterResolver struct{ C story.Chapter } |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | // ChapterArgs is args for chapter query
 |  |  | // ChapterArgs is args for chapter query
 | 
		
	
		
			
				|  |  | type ChapterArgs struct { |  |  | type ChapterArgs struct { | 
		
	
		
			
				|  |  | 	ID string |  |  | 	ID string | 
		
	
		
			
				|  |  | } |  |  | } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | // Chapter implements the chapter query
 |  |  | // Chapter implements the chapter query
 | 
		
	
		
			
				|  |  | func (r *QueryResolver) Chapter(ctx context.Context, args *ChapterArgs) (*ChapterResolver, error) { |  |  |  | 
		
	
		
			
				|  |  |  |  |  | func (r *QueryResolver) Chapter(ctx context.Context, args *ChapterArgs) (*types.ChapterResolver, error) { | 
		
	
		
			
				|  |  | 	chapter, err := story.FindChapterID(args.ID) |  |  | 	chapter, err := story.FindChapterID(args.ID) | 
		
	
		
			
				|  |  | 	if err != nil { |  |  | 	if err != nil { | 
		
	
		
			
				|  |  | 		return nil, err |  |  | 		return nil, err | 
		
	
		
			
				|  |  | 	} |  |  | 	} | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | 	return &ChapterResolver{C: chapter}, nil |  |  |  | 
		
	
		
			
				|  |  |  |  |  | 	return &types.ChapterResolver{C: chapter}, nil | 
		
	
		
			
				|  |  | } |  |  | } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | // AddChapterArgs is args for the addChapter mutation
 |  |  | // AddChapterArgs is args for the addChapter mutation
 | 
		
	
	
		
			
				|  | @ -39,7 +37,7 @@ type AddChapterArgs struct { | 
		
	
		
			
				|  |  | } |  |  | } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | // AddChapter implements the addChapter mutation
 |  |  | // AddChapter implements the addChapter mutation
 | 
		
	
		
			
				|  |  | func (r *MutationResolver) AddChapter(ctx context.Context, args *AddChapterArgs) (*ChapterResolver, error) { |  |  |  | 
		
	
		
			
				|  |  |  |  |  | func (r *MutationResolver) AddChapter(ctx context.Context, args *AddChapterArgs) (*types.ChapterResolver, error) { | 
		
	
		
			
				|  |  | 	input := args.Input |  |  | 	input := args.Input | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | 	user := session.FromContext(ctx).User() |  |  | 	user := session.FromContext(ctx).User() | 
		
	
	
		
			
				|  | @ -80,7 +78,7 @@ func (r *MutationResolver) AddChapter(ctx context.Context, args *AddChapterArgs) | 
		
	
		
			
				|  |  | 		"fictionalDate": fictionalDate, |  |  | 		"fictionalDate": fictionalDate, | 
		
	
		
			
				|  |  | 	}) |  |  | 	}) | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | 	return &ChapterResolver{C: chapter}, nil |  |  |  | 
		
	
		
			
				|  |  |  |  |  | 	return &types.ChapterResolver{C: chapter}, nil | 
		
	
		
			
				|  |  | } |  |  | } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | // EditChapterArgs is args for the editChapter mutation
 |  |  | // EditChapterArgs is args for the editChapter mutation
 | 
		
	
	
		
			
				|  | @ -94,7 +92,7 @@ type EditChapterArgs struct { | 
		
	
		
			
				|  |  | } |  |  | } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | // EditChapter implements the editChapter mutation
 |  |  | // EditChapter implements the editChapter mutation
 | 
		
	
		
			
				|  |  | func (r *MutationResolver) EditChapter(ctx context.Context, args *EditChapterArgs) (*ChapterResolver, error) { |  |  |  | 
		
	
		
			
				|  |  |  |  |  | func (r *MutationResolver) EditChapter(ctx context.Context, args *EditChapterArgs) (*types.ChapterResolver, error) { | 
		
	
		
			
				|  |  | 	input := args.Input |  |  | 	input := args.Input | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | 	user := session.FromContext(ctx).User() |  |  | 	user := session.FromContext(ctx).User() | 
		
	
	
		
			
				|  | @ -132,7 +130,7 @@ func (r *MutationResolver) EditChapter(ctx context.Context, args *EditChapterArg | 
		
	
		
			
				|  |  | 		"fictionalDate": fictionalDate, |  |  | 		"fictionalDate": fictionalDate, | 
		
	
		
			
				|  |  | 	}) |  |  | 	}) | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | 	return &ChapterResolver{C: chapter}, nil |  |  |  | 
		
	
		
			
				|  |  |  |  |  | 	return &types.ChapterResolver{C: chapter}, nil | 
		
	
		
			
				|  |  | } |  |  | } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | // DeleteChapterArgs is args for the addChapter mutation
 |  |  | // DeleteChapterArgs is args for the addChapter mutation
 | 
		
	
	
		
			
				|  | @ -141,7 +139,7 @@ type DeleteChapterArgs struct { | 
		
	
		
			
				|  |  | } |  |  | } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | // RemoveChapter implements the removeChapter mutation
 |  |  | // RemoveChapter implements the removeChapter mutation
 | 
		
	
		
			
				|  |  | func (r *MutationResolver) RemoveChapter(ctx context.Context, args *DeleteChapterArgs) (*ChapterResolver, error) { |  |  |  | 
		
	
		
			
				|  |  |  |  |  | func (r *MutationResolver) RemoveChapter(ctx context.Context, args *DeleteChapterArgs) (*types.ChapterResolver, error) { | 
		
	
		
			
				|  |  | 	user := session.FromContext(ctx).User() |  |  | 	user := session.FromContext(ctx).User() | 
		
	
		
			
				|  |  | 	if user == nil || !user.Permitted("member", "chapter.edit") { |  |  | 	if user == nil || !user.Permitted("member", "chapter.edit") { | 
		
	
		
			
				|  |  | 		return nil, ErrUnauthorized |  |  | 		return nil, ErrUnauthorized | 
		
	
	
		
			
				|  | @ -159,45 +157,5 @@ func (r *MutationResolver) RemoveChapter(ctx context.Context, args *DeleteChapte | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | 	go change.Submit("Chapter", "remove", user.ID, chapter.ID, nil) |  |  | 	go change.Submit("Chapter", "remove", user.ID, chapter.ID, nil) | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | 	return &ChapterResolver{C: chapter}, nil |  |  |  | 
		
	
		
			
				|  |  | } |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | // ID resolves Chapter.id
 |  |  |  | 
		
	
		
			
				|  |  | func (r *ChapterResolver) ID() string { |  |  |  | 
		
	
		
			
				|  |  | 	return r.C.ID |  |  |  | 
		
	
		
			
				|  |  | } |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | // StoryID resolves Chapter.storyId
 |  |  |  | 
		
	
		
			
				|  |  | func (r *ChapterResolver) StoryID() string { |  |  |  | 
		
	
		
			
				|  |  | 	return r.C.StoryID |  |  |  | 
		
	
		
			
				|  |  | } |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | // Title resolves Chapter.title
 |  |  |  | 
		
	
		
			
				|  |  | func (r *ChapterResolver) Title() string { |  |  |  | 
		
	
		
			
				|  |  | 	return r.C.Title |  |  |  | 
		
	
		
			
				|  |  | } |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | // Author resolves Chapter.author
 |  |  |  | 
		
	
		
			
				|  |  | func (r *ChapterResolver) Author() string { |  |  |  | 
		
	
		
			
				|  |  | 	return r.C.Author |  |  |  | 
		
	
		
			
				|  |  | } |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | // Source resolves Chapter.source
 |  |  |  | 
		
	
		
			
				|  |  | func (r *ChapterResolver) Source() string { |  |  |  | 
		
	
		
			
				|  |  | 	return r.C.Source |  |  |  | 
		
	
		
			
				|  |  | } |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | // CreatedDate resolves Chapter.createdDate
 |  |  |  | 
		
	
		
			
				|  |  | func (r *ChapterResolver) CreatedDate() string { |  |  |  | 
		
	
		
			
				|  |  | 	return r.C.CreatedDate.Format(time.RFC3339Nano) |  |  |  | 
		
	
		
			
				|  |  | } |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | // FictionalDate resolves Chapter.fictionalDate
 |  |  |  | 
		
	
		
			
				|  |  | func (r *ChapterResolver) FictionalDate() string { |  |  |  | 
		
	
		
			
				|  |  | 	return r.C.FictionalDate.Format(time.RFC3339Nano) |  |  |  | 
		
	
		
			
				|  |  | } |  |  |  | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  | // EditedDate resolves Chapter.editedDate
 |  |  |  | 
		
	
		
			
				|  |  | func (r *ChapterResolver) EditedDate() string { |  |  |  | 
		
	
		
			
				|  |  | 	return r.C.EditedDate.Format(time.RFC3339Nano) |  |  |  | 
		
	
		
			
				|  |  |  |  |  | 	return &types.ChapterResolver{C: chapter}, nil | 
		
	
		
			
				|  |  | } |  |  | } |