33 lines
664 B
Go
33 lines
664 B
Go
package api
|
|
|
|
import (
|
|
"git.sleepycat.moe/sam/mercury/internal/database"
|
|
"github.com/oklog/ulid/v2"
|
|
)
|
|
|
|
// Account is the basic user returned by endpoints, without any private data.
|
|
type Account struct {
|
|
ID ulid.ULID `json:"id"`
|
|
Username string `json:"username"`
|
|
Domain *string `json:"domain"`
|
|
}
|
|
|
|
type SelfAccount struct {
|
|
Account
|
|
Email string `json:"email"`
|
|
}
|
|
|
|
func DBAccountToAccount(a database.Account) Account {
|
|
return Account{
|
|
ID: a.ID,
|
|
Username: a.Username,
|
|
Domain: a.Domain,
|
|
}
|
|
}
|
|
|
|
func DBAccountToSelfAccount(a database.Account) SelfAccount {
|
|
return SelfAccount{
|
|
Account: DBAccountToAccount(a),
|
|
Email: *a.Email,
|
|
}
|
|
}
|