✨ Last seen at
This commit is contained in:
@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/server/exts"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
|
||||
@ -13,9 +14,11 @@ import (
|
||||
func getStatus(c *fiber.Ctx) error {
|
||||
alias := c.Params("alias")
|
||||
|
||||
user, err := services.GetAccountWithName(alias)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusNotFound, fmt.Sprintf("account not found: %s", alias))
|
||||
var user models.Account
|
||||
if err := database.C.Where(models.Account{
|
||||
Name: alias,
|
||||
}).Preload("Profile").First(&user).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusNotFound, fmt.Sprintf("account not found: %s", err))
|
||||
}
|
||||
|
||||
status, err := services.GetStatus(user.ID)
|
||||
@ -24,6 +27,7 @@ func getStatus(c *fiber.Ctx) error {
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"status": lo.Ternary(err == nil, &status, nil),
|
||||
"last_seen_at": user.Profile.LastSeenAt,
|
||||
"is_disturbable": disturbable,
|
||||
"is_online": online,
|
||||
})
|
||||
|
Reference in New Issue
Block a user