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" "fmt"
"net/http" "net/http"
"strings" "strings"
"time"
"code.nonshy.com/nonshy/website/pkg/config" "code.nonshy.com/nonshy/website/pkg/config"
"code.nonshy.com/nonshy/website/pkg/controller/api" "code.nonshy.com/nonshy/website/pkg/controller/api"
"code.nonshy.com/nonshy/website/pkg/log" "code.nonshy.com/nonshy/website/pkg/log"
"code.nonshy.com/nonshy/website/pkg/models" "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. // WebhookRequest is a JSON request wrapper around all webhook messages.
@ -188,9 +191,19 @@ func Profile() http.HandlerFunc {
gender += fmt.Sprintf(" (%s)", pronouns) gender += fmt.Sprintf(" (%s)", pronouns)
} }
var photoCount = models.CountPublicPhotos(currentUser.ID)
var resp = Response{ var resp = Response{
OK: true, OK: true,
ProfileFields: []ProfileField{ 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", Name: "Age",
Value: currentUser.GetDisplayAge(), Value: currentUser.GetDisplayAge(),