Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Update /whoami response to match Spec v1.2
Browse files Browse the repository at this point in the history
Basically include `is_guest` and `device_id`. The latter is
needed for matrix-org/complement#305
  • Loading branch information
kegsay committed Feb 18, 2022
1 parent 131bedc commit d840893
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions clientapi/routing/whoami.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ import (

// whoamiResponse represents an response for a `whoami` request
type whoamiResponse struct {
UserID string `json:"user_id"`
UserID string `json:"user_id"`
DeviceID string `json:"device_id"`
IsGuest bool `json:"is_guest"`
}

// Whoami implements `/account/whoami` which enables client to query their account user id.
// https://matrix.org/docs/spec/client_server/r0.3.0.html#get-matrix-client-r0-account-whoami
func Whoami(req *http.Request, device *api.Device) util.JSONResponse {
return util.JSONResponse{
Code: http.StatusOK,
JSON: whoamiResponse{UserID: device.UserID},
JSON: whoamiResponse{
UserID: device.UserID,
DeviceID: device.ID,
IsGuest: device.AccountType == api.AccountTypeGuest,
},
}
}

0 comments on commit d840893

Please sign in to comment.