From c3291edd4f63b90a216c353f03336b208547a99b Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 19 May 2023 03:13:46 +0200 Subject: [PATCH] feat: expose some more info in /settings --- backend/routes/user/get_user.go | 4 +++ frontend/src/lib/api/entities.ts | 3 +++ frontend/src/routes/settings/+page.svelte | 31 ++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/backend/routes/user/get_user.go b/backend/routes/user/get_user.go index b19fe62..2466e2e 100644 --- a/backend/routes/user/get_user.go +++ b/backend/routes/user/get_user.go @@ -2,6 +2,7 @@ package user import ( "net/http" + "time" "codeberg.org/u1f320/pronouns.cc/backend/db" "codeberg.org/u1f320/pronouns.cc/backend/log" @@ -29,6 +30,8 @@ type GetUserResponse struct { type GetMeResponse struct { GetUserResponse + CreatedAt time.Time `json:"created_at"` + MaxInvites int `json:"max_invites"` IsAdmin bool `json:"is_admin"` ListPrivate bool `json:"list_private"` @@ -194,6 +197,7 @@ func (s *Server) getMeUser(w http.ResponseWriter, r *http.Request) error { render.JSON(w, r, GetMeResponse{ GetUserResponse: dbUserToResponse(u, fields, members), + CreatedAt: u.ID.Time(), MaxInvites: u.MaxInvites, IsAdmin: u.IsAdmin, ListPrivate: u.ListPrivate, diff --git a/frontend/src/lib/api/entities.ts b/frontend/src/lib/api/entities.ts index 22fe815..4cba7b4 100644 --- a/frontend/src/lib/api/entities.ts +++ b/frontend/src/lib/api/entities.ts @@ -1,6 +1,7 @@ import { PUBLIC_BASE_URL } from "$env/static/public"; export const MAX_MEMBERS = 500; +export const MAX_FIELDS = 25; export const MAX_DESCRIPTION_LENGTH = 1000; export interface User { @@ -38,7 +39,9 @@ export enum PreferenceSize { } export interface MeUser extends User { + created_at: string; max_invites: number; + is_admin: boolean; discord: string | null; discord_username: string | null; tumblr: string | null; diff --git a/frontend/src/routes/settings/+page.svelte b/frontend/src/routes/settings/+page.svelte index 3df8a86..0b9e229 100644 --- a/frontend/src/routes/settings/+page.svelte +++ b/frontend/src/routes/settings/+page.svelte @@ -1,6 +1,12 @@