From 1d7278d950e50c989f47e2c8a4dfcedd6ba67f5e Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Thu, 24 May 2018 13:53:22 +0100 Subject: [PATCH] Fix typo and bug in /devices/{deviceID} (#465) * Fix typo in API Endpoint Signed-off-by: Andrew Morgan * Fixed another typo and bug Use a sql.NullInt64 instead of an Int64 as that allows for values to sometimes be null when pulling from a postgres table. Can result in error otherwise. Signed-off-by: Andrew Morgan --- .../dendrite/clientapi/auth/storage/devices/devices_table.go | 2 +- src/github.com/matrix-org/dendrite/clientapi/routing/device.go | 2 +- src/github.com/matrix-org/dendrite/clientapi/routing/routing.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/clientapi/auth/storage/devices/devices_table.go b/src/github.com/matrix-org/dendrite/clientapi/auth/storage/devices/devices_table.go index c8ece6b9..9512acfc 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/auth/storage/devices/devices_table.go +++ b/src/github.com/matrix-org/dendrite/clientapi/auth/storage/devices/devices_table.go @@ -173,7 +173,7 @@ func (s *devicesStatements) selectDeviceByID( ctx context.Context, localpart, deviceID string, ) (*authtypes.Device, error) { var dev authtypes.Device - var created int64 + var created sql.NullInt64 stmt := s.selectDeviceByIDStmt err := stmt.QueryRowContext(ctx, localpart, deviceID).Scan(&created) if err == nil { diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/device.go b/src/github.com/matrix-org/dendrite/clientapi/routing/device.go index d519c8a6..cf6f24a7 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/device.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/device.go @@ -40,7 +40,7 @@ type deviceUpdateJSON struct { DisplayName *string `json:"display_name"` } -// GetDeviceByID handles /device/{deviceID} +// GetDeviceByID handles /devices/{deviceID} func GetDeviceByID( req *http.Request, deviceDB *devices.Database, device *authtypes.Device, deviceID string, diff --git a/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go b/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go index 8e6b2b0a..40f50d2b 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go +++ b/src/github.com/matrix-org/dendrite/clientapi/routing/routing.go @@ -361,7 +361,7 @@ func Setup( }), ).Methods(http.MethodGet, http.MethodOptions) - r0mux.Handle("/device/{deviceID}", + r0mux.Handle("/devices/{deviceID}", common.MakeAuthAPI("get_device", deviceDB, func(req *http.Request, device *authtypes.Device) util.JSONResponse { vars := mux.Vars(req) return GetDeviceByID(req, deviceDB, device, vars["deviceID"])