databag/net/server/internal/api_getAccountListing.go

32 lines
849 B
Go
Raw Normal View History

2022-03-09 07:05:04 +00:00
package databag
import (
2022-07-22 19:28:14 +00:00
"databag/internal/store"
"net/http"
2022-03-09 07:05:04 +00:00
)
func GetAccountListing(w http.ResponseWriter, r *http.Request) {
2022-07-22 19:28:14 +00:00
var accounts []store.Account
if err := store.DB.Preload("AccountDetail").Where("searchable = ? AND disabled = ?", true, false).Find(&accounts).Error; err != nil {
ErrResponse(w, http.StatusInternalServerError, err)
return
}
2022-03-09 07:05:04 +00:00
2022-07-22 19:28:14 +00:00
profiles := []CardProfile{}
for _, account := range accounts {
profiles = append(profiles, CardProfile{
GUID: account.GUID,
Handle: account.Username,
Name: account.AccountDetail.Name,
Description: account.AccountDetail.Description,
Location: account.AccountDetail.Location,
ImageSet: account.AccountDetail.Image != "",
Version: APPVersion,
Node: getStrConfigValue(CNFDomain, ""),
})
}
2022-03-09 07:05:04 +00:00
2022-07-22 19:28:14 +00:00
WriteResponse(w, &profiles)
2022-03-09 07:05:04 +00:00
}