More profile fields for BareRTC cards

face-detect
Noah Petherbridge 2023-10-29 12:35:00 -07:00
parent f9a2d471f5
commit bb0e7fa2fc
1 changed files with 13 additions and 0 deletions

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(),