🐛 Fix the feed isn't sorted

This commit is contained in:
LittleSheep 2025-03-12 22:11:05 +08:00
parent d6fa3bb15d
commit 95d12a0a2d

View File

@ -2,6 +2,7 @@ package services
import (
"fmt"
"sort"
"time"
"git.solsynth.dev/hypernet/interactive/pkg/internal/database"
@ -45,6 +46,10 @@ func GetFeed(c *fiber.Ctx, limit int, user *uint, cursor *time.Time) ([]FeedEntr
}
feed = append(feed, fediPosts...)
sort.Slice(feed, func(i, j int) bool {
return feed[i].CreatedAt.After(feed[j].CreatedAt)
})
return feed, nil
}