Able to list all the friend without status filter

This commit is contained in:
2024-04-25 22:08:49 +08:00
parent e0d496cc47
commit 3e9c84a284
4 changed files with 32 additions and 13 deletions

View File

@ -9,13 +9,21 @@ import (
func listFriendship(c *fiber.Ctx) error {
user := c.Locals("principal").(models.Account)
status := c.QueryInt("status", int(models.FriendshipActive))
status := c.QueryInt("status", -1)
if friends, err := services.ListFriend(user, models.FriendshipStatus(status)); err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
var err error
var friends []models.AccountFriendship
if status < 0 {
if friends, err = services.ListAllFriend(user); err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
} else {
return c.JSON(friends)
if friends, err = services.ListFriend(user, models.FriendshipStatus(status)); err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
}
return c.JSON(friends)
}
func getFriendship(c *fiber.Ctx) error {

View File

@ -1,6 +1,9 @@
package server
import (
"net/http"
"strings"
"git.solsynth.dev/hydrogen/passport/pkg"
"git.solsynth.dev/hydrogen/passport/pkg/i18n"
"git.solsynth.dev/hydrogen/passport/pkg/server/ui"
@ -14,8 +17,6 @@ import (
jsoniter "github.com/json-iterator/go"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"net/http"
"strings"
)
var A *fiber.App