More profile fields for BareRTC cards

This commit is contained in:
Noah Petherbridge 2023-10-29 12:35:00 -07:00
parent f9a2d471f5
commit bb0e7fa2fc

View File

@ -4,11 +4,14 @@ import (
"fmt"
"net/http"
"strings"
"time"
"code.nonshy.com/nonshy/website/pkg/config"
"code.nonshy.com/nonshy/website/pkg/controller/api"
"code.nonshy.com/nonshy/website/pkg/log"
"code.nonshy.com/nonshy/website/pkg/models"
"code.nonshy.com/nonshy/website/pkg/templates"
"code.nonshy.com/nonshy/website/pkg/utility"
)
// WebhookRequest is a JSON request wrapper around all webhook messages.
@ -188,9 +191,19 @@ func Profile() http.HandlerFunc {
gender += fmt.Sprintf(" (%s)", pronouns)
}
var photoCount = models.CountPublicPhotos(currentUser.ID)
var resp = Response{
OK: true,
ProfileFields: []ProfileField{
{
Name: "Member Since",
Value: fmt.Sprintf("%s ago", utility.FormatDurationCoarse(time.Since(currentUser.CreatedAt))),
},
{
Name: "📸 Gallery",
Value: fmt.Sprintf("At least %d photo%s", photoCount, templates.Pluralize(photoCount)),
},
{
Name: "Age",
Value: currentUser.GetDisplayAge(),