summaryrefslogtreecommitdiff
path: root/internal/typeutils/internaltofrontend.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r--internal/typeutils/internaltofrontend.go33
1 files changed, 17 insertions, 16 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go
index 975214da7..8ad1681d0 100644
--- a/internal/typeutils/internaltofrontend.go
+++ b/internal/typeutils/internaltofrontend.go
@@ -32,6 +32,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/media"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
"github.com/superseriousbusiness/gotosocial/internal/util"
)
@@ -568,10 +569,18 @@ func (c *converter) EmojiCategoryToAPIEmojiCategory(ctx context.Context, categor
}, nil
}
-func (c *converter) TagToAPITag(ctx context.Context, t *gtsmodel.Tag) (apimodel.Tag, error) {
+func (c *converter) TagToAPITag(ctx context.Context, t *gtsmodel.Tag, stubHistory bool) (apimodel.Tag, error) {
return apimodel.Tag{
- Name: t.Name,
- URL: t.URL,
+ Name: strings.ToLower(t.Name),
+ URL: uris.GenerateURIForTag(t.Name),
+ History: func() *[]any {
+ if !stubHistory {
+ return nil
+ }
+
+ h := make([]any, 0)
+ return &h
+ }(),
}, nil
}
@@ -1297,19 +1306,11 @@ func (c *converter) convertTagsToAPITags(ctx context.Context, tags []*gtsmodel.T
var errs gtserror.MultiError
if len(tags) == 0 {
- // GTS model tags were not populated
-
- // Preallocate expected GTS slice
- tags = make([]*gtsmodel.Tag, 0, len(tagIDs))
+ var err error
- // Fetch GTS models for tag IDs
- for _, id := range tagIDs {
- tag := new(gtsmodel.Tag)
- if err := c.db.GetByID(ctx, id, tag); err != nil {
- errs.Appendf("error fetching tag %s from database: %v", id, err)
- continue
- }
- tags = append(tags, tag)
+ tags, err = c.db.GetTags(ctx, tagIDs)
+ if err != nil {
+ errs.Appendf("error fetching tags from database: %v", err)
}
}
@@ -1318,7 +1319,7 @@ func (c *converter) convertTagsToAPITags(ctx context.Context, tags []*gtsmodel.T
// Convert GTS models to frontend models
for _, tag := range tags {
- apiTag, err := c.TagToAPITag(ctx, tag)
+ apiTag, err := c.TagToAPITag(ctx, tag, false)
if err != nil {
errs.Appendf("error converting tag %s to api tag: %v", tag.ID, err)
continue