The Profile tab was a read-only avatar/name/email stub. It is now a real
form, modeled on the profile surfaces of GitHub/Slack/Nextcloud and scoped
to what a knowledge tool uses: display name, bio (280 chars with counter),
location, occupation, organization and website; email stays read-only
(sign-in identity). Copy explains where the name appears (shares) and
that public bookmark links never reveal identity.
Schema: migration 024_user_profile.sql + schema.sql add five nullable
text columns to User (db-converge green, fresh and upgraded paths).
models.User, userFromObject and the auth identity projection carry them,
so GET /api/me serves the stored truth (Go re-reads identity per request).
PATCH /api/me applies partial allowlisted edits: empty string clears to
NULL, rune-based caps (120/280/120/120/120), website <=2048 and http(s)
with a host; the answer is the fresh identity projection. User has no
version column (identity, not a collaborative collection), so this follows
the settings-save shape rather than the 409 contract; view-as writes stay
blocked by the middleware.
Session propagation: the auth.ts jwt callback gains an "update" trigger
that re-syncs name/email/image from Go via the same assertion the data
proxy signs (fail-quiet when Go is unreachable). The component calls
useSession().update({}) after a save — the {} argument is load-bearing:
in next-auth v5 a bare update() only re-fetches the session, it does not
fire the trigger (caught by the new browser regression). The top bar name
refreshes without a re-login.
Verified: full Go integration suite green incl. new TestProfileUpdate
(partial edits, clearing, rune caps, URL validation, auth gate);
db-converge green; web lint/SSR-lint/build 0 errors; full browser
regressions pass incl. the new profile round-trip (save → toast → top-bar
refresh → form values intact → Save re-disables on a clean baseline).
204 lines
4.4 KiB
Go
204 lines
4.4 KiB
Go
package models
|
|
|
|
// KanbanStatus is the legacy enum. Porting guide 2.1.
|
|
type KanbanStatus string
|
|
|
|
const (
|
|
Inbox KanbanStatus = "INBOX"
|
|
Todo KanbanStatus = "TODO"
|
|
InProgress KanbanStatus = "IN_PROGRESS"
|
|
Done KanbanStatus = "DONE"
|
|
Archived KanbanStatus = "ARCHIVED"
|
|
)
|
|
|
|
// User. Porting guide 2.2.
|
|
type User struct {
|
|
ID string
|
|
Name *string
|
|
Email *string
|
|
EmailVerified *string
|
|
Image *string
|
|
Password *string
|
|
Role string // USER | ADMIN
|
|
TokenVersion int // embedded in cookie JWTs; bumping revokes them
|
|
TenantID *string
|
|
CreatedAt string
|
|
UpdatedAt string
|
|
// Profile particulars (Settings → Profile, migration 024).
|
|
Bio *string
|
|
Location *string
|
|
Occupation *string
|
|
Organization *string
|
|
Website *string
|
|
}
|
|
|
|
// Account, Session, VerificationToken are auth-library tables. Porting guide 2.3.
|
|
// Session and VerificationToken are unused (sessions are JWT-based).
|
|
// Account is only needed if keeping OIDC.
|
|
type Account struct {
|
|
ID string
|
|
UserID string
|
|
Type string
|
|
Provider string
|
|
ProviderAccountID string
|
|
RefreshToken *string
|
|
AccessToken *string
|
|
ExpiresAt *int
|
|
TokenType *string
|
|
Scope *string
|
|
IDToken *string
|
|
SessionState *string
|
|
}
|
|
|
|
// Bookmark is the core object: one saved URL. Porting guide 2.4.
|
|
type Bookmark struct {
|
|
ID string
|
|
URL string
|
|
Title *string
|
|
Description *string
|
|
Favicon *string
|
|
OgImage *string
|
|
OgTitle *string
|
|
OgDescription *string
|
|
Notes *string
|
|
DueDate *string
|
|
AlertAt *string
|
|
AlertSent bool
|
|
KanbanStatus KanbanStatus
|
|
KanbanColumnID *string
|
|
ImapWatchEnabled bool
|
|
ImapQuery *string
|
|
IsPublic bool
|
|
OwnerID string
|
|
ContactID *string
|
|
CreatedAt string
|
|
UpdatedAt string
|
|
}
|
|
|
|
// Tag. Porting guide 2.5.
|
|
type Tag struct {
|
|
ID string
|
|
Name string
|
|
Color string
|
|
OwnerID string
|
|
CreatedAt string
|
|
UpdatedAt string
|
|
}
|
|
|
|
// BookmarkTag join. Porting guide 2.6.
|
|
type BookmarkTag struct {
|
|
BookmarkID string
|
|
TagID string
|
|
}
|
|
|
|
// BookmarkShare. Porting guide 2.7.
|
|
type BookmarkShare struct {
|
|
BookmarkID string
|
|
UserID string
|
|
CreatedAt string
|
|
}
|
|
|
|
// TagShare. Porting guide 2.8.
|
|
type TagShare struct {
|
|
TagID string
|
|
UserID string
|
|
CreatedAt string
|
|
}
|
|
|
|
// Contact, synced from Nextcloud CardDAV. Porting guide 2.9.
|
|
type Contact struct {
|
|
ID string
|
|
UID string
|
|
DisplayName string
|
|
Email *string
|
|
Phone *string
|
|
CardDavURL *string
|
|
UserID string
|
|
CreatedAt string
|
|
UpdatedAt string
|
|
}
|
|
|
|
// ImapConfig, one per user; password is encrypted. Porting guide 2.10.
|
|
type ImapConfig struct {
|
|
ID string
|
|
Host string
|
|
Port int
|
|
TLS bool
|
|
Username string
|
|
Password string // encrypted
|
|
Folder string
|
|
UserID string
|
|
}
|
|
|
|
// KanbanColumn, user-editable board column. Porting guide 2.11.
|
|
type KanbanColumn struct {
|
|
ID string
|
|
Label string
|
|
Color string
|
|
Position int
|
|
Key *string // INBOX/TODO/IN_PROGRESS/DONE for defaults, null for custom
|
|
UserID string
|
|
CreatedAt string
|
|
}
|
|
|
|
// Page, a Markdown workspace. Porting guide 2.12.
|
|
type Page struct {
|
|
ID string
|
|
Title string
|
|
Content string
|
|
Icon *string
|
|
Pinned bool
|
|
Position int
|
|
OwnerID string
|
|
CreatedAt string
|
|
UpdatedAt string
|
|
}
|
|
|
|
// PageBookmark links a bookmark onto a page. Porting guide 2.13.
|
|
type PageBookmark struct {
|
|
PageID string
|
|
BookmarkID string
|
|
Position int
|
|
CreatedAt string
|
|
}
|
|
|
|
// SignalSource, a watcher attached to a bookmark. Porting guide 2.14.
|
|
type SignalSource struct {
|
|
ID string
|
|
Type string
|
|
Config string // JSON, default "{}"
|
|
Enabled bool
|
|
LastCheckedAt *string
|
|
LastStatus *string
|
|
BookmarkID string
|
|
OwnerID string
|
|
CreatedAt string
|
|
UpdatedAt string
|
|
}
|
|
|
|
// Signal, one outside event about a bookmark. Porting guide 2.15.
|
|
type Signal struct {
|
|
ID string
|
|
SourceType string
|
|
Title string
|
|
Summary *string
|
|
URL *string
|
|
ExternalID *string
|
|
OccurredAt string
|
|
Read bool
|
|
SourceID *string
|
|
BookmarkID string
|
|
OwnerID string
|
|
CreatedAt string
|
|
}
|
|
|
|
// SharedDate. Porting guide 2.16.
|
|
type SharedDate struct {
|
|
ID string
|
|
Date string
|
|
Note *string
|
|
CreatorID string
|
|
RecipientID string
|
|
CreatedAt string
|
|
}
|