This commit is contained in:
@@ -61,6 +61,13 @@ func (s *CharacterService) List(ctx context.Context, filter models.CharacterFilt
|
||||
}
|
||||
|
||||
sort.Slice(characters, func(i, j int) bool {
|
||||
if len(characters[i].ID) > len(characters[j].ID) {
|
||||
return true
|
||||
}
|
||||
if len(characters[i].ID) < len(characters[j].ID) {
|
||||
return false
|
||||
}
|
||||
|
||||
return strings.Compare(characters[i].ID, characters[j].ID) < 0
|
||||
})
|
||||
|
||||
|
||||
@@ -34,6 +34,20 @@ func (s *StoryService) FindComment(ctx context.Context, id string) (*models.Comm
|
||||
}
|
||||
|
||||
func (s *StoryService) ListStories(ctx context.Context, filter models.StoryFilter) ([]*models.Story, error) {
|
||||
if filter.Unlisted != nil && *filter.Unlisted {
|
||||
token := s.authService.TokenFromContext(ctx)
|
||||
if !token.Authenticated() {
|
||||
return nil, errors.New("you cannot view unlisted stories")
|
||||
}
|
||||
if !token.Permitted("story.unlisted") {
|
||||
if filter.Author == nil {
|
||||
filter.Author = &token.UserID
|
||||
} else if *filter.Author != token.UserID {
|
||||
return nil, errors.New("you cannot view your own unlisted stories")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s.stories.List(ctx, filter)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user