🐛 Fix unable to list posts with realm id

This commit is contained in:
2024-06-23 01:18:12 +08:00
parent 608c52ace6
commit c198565ced
3 changed files with 23 additions and 1 deletions

View File

@ -39,7 +39,11 @@ func listPost(c *fiber.Ctx) error {
tx := database.C
if realmId > 0 {
tx = services.FilterWithRealm(tx, uint(realmId))
if realm, err := services.GetRealmWithExtID(uint(realmId)); err != nil {
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("realm was not found: %v", err))
} else {
tx = services.FilterWithRealm(tx, realm.ID)
}
}
if len(c.Query("authorId")) > 0 {