tweak tags and add story repository.
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-03-26 15:47:18 +01:00
parent 410e07a6a2
commit 525191a0f9
16 changed files with 418 additions and 62 deletions
+7
View File
@@ -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
})
+14
View File
@@ -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)
}