Turns the rows of users, once checked, into the User that user-service.ts returns. A route turns a User into what it may send with toPublicUser or toSelfUser.

Functions

f
isRemoteUser(user: User): boolean

Checks whether user's account lives on another instance, whose user signs in here through federation (federation-service.ts). Their password, email, avatar and name are that instance's to change, so the routes that change them here refuse.

f
isUserRow(obj: unknown): obj is UserRow

Checks whether obj, a row selected with the columns of UserRow, is one.

f
toPublicUser(unnamed 0: User): PublicUser

Returns what anyone may see of user, without the hash and the email. Every route that sends another user's profile goes through it.

f
toSelfUser(unnamed 0: User): SelfUser

Returns what user sees of themselves, without the hash, for the routes that answer the caller's own account.

f
userApiToRow(user: User): UserRow

Converts a User back to a row, for updateUser. A User has no inviter id, so invited_by comes out null: don't write it back.

f
userRowToApi(row: UserRow): User

Converts a row to a User, turning nulls into undefined.

Interfaces

I
User

Returned by the lookups of user-service.ts. It must never be sent as is: it carries the password hash.

  • passwordHash: string | null

    From hashPassword, as hash.salt, or null for an account from another instance (isRemoteUser), which signs in there and never with a password here. The row stores that as ''.

I
UserRow

Selected by user-service.ts and follow-service.ts, and converted by userRowToApi. It leaves out chat_read_at and tokens_valid_after, which only the chat's read state and getSessionState query.