aboutsummaryrefslogtreecommitdiff
path: root/userapi
diff options
context:
space:
mode:
Diffstat (limited to 'userapi')
-rw-r--r--userapi/storage/devices/postgres/devices_table.go17
-rw-r--r--userapi/storage/devices/sqlite3/devices_table.go17
2 files changed, 28 insertions, 6 deletions
diff --git a/userapi/storage/devices/postgres/devices_table.go b/userapi/storage/devices/postgres/devices_table.go
index 379fed79..cc554fe7 100644
--- a/userapi/storage/devices/postgres/devices_table.go
+++ b/userapi/storage/devices/postgres/devices_table.go
@@ -77,7 +77,7 @@ const selectDeviceByIDSQL = "" +
"SELECT display_name FROM device_devices WHERE localpart = $1 and device_id = $2"
const selectDevicesByLocalpartSQL = "" +
- "SELECT device_id, display_name FROM device_devices WHERE localpart = $1 AND device_id != $2"
+ "SELECT device_id, display_name, last_seen_ts, ip, user_agent FROM device_devices WHERE localpart = $1 AND device_id != $2"
const updateDeviceNameSQL = "" +
"UPDATE device_devices SET display_name = $1 WHERE localpart = $2 AND device_id = $3"
@@ -281,8 +281,9 @@ func (s *devicesStatements) selectDevicesByLocalpart(
for rows.Next() {
var dev api.Device
- var id, displayname sql.NullString
- err = rows.Scan(&id, &displayname)
+ var lastseents sql.NullInt64
+ var id, displayname, ip, useragent sql.NullString
+ err = rows.Scan(&id, &displayname, &lastseents, &ip, &useragent)
if err != nil {
return devices, err
}
@@ -292,6 +293,16 @@ func (s *devicesStatements) selectDevicesByLocalpart(
if displayname.Valid {
dev.DisplayName = displayname.String
}
+ if lastseents.Valid {
+ dev.LastSeenTS = lastseents.Int64
+ }
+ if ip.Valid {
+ dev.LastSeenIP = ip.String
+ }
+ if useragent.Valid {
+ dev.UserAgent = useragent.String
+ }
+
dev.UserID = userutil.MakeUserID(localpart, s.serverName)
devices = append(devices, dev)
}
diff --git a/userapi/storage/devices/sqlite3/devices_table.go b/userapi/storage/devices/sqlite3/devices_table.go
index 26c03222..cdfe2bb9 100644
--- a/userapi/storage/devices/sqlite3/devices_table.go
+++ b/userapi/storage/devices/sqlite3/devices_table.go
@@ -62,7 +62,7 @@ const selectDeviceByIDSQL = "" +
"SELECT display_name FROM device_devices WHERE localpart = $1 and device_id = $2"
const selectDevicesByLocalpartSQL = "" +
- "SELECT device_id, display_name FROM device_devices WHERE localpart = $1 AND device_id != $2"
+ "SELECT device_id, display_name, last_seen_ts, ip, user_agent FROM device_devices WHERE localpart = $1 AND device_id != $2"
const updateDeviceNameSQL = "" +
"UPDATE device_devices SET display_name = $1 WHERE localpart = $2 AND device_id = $3"
@@ -256,8 +256,9 @@ func (s *devicesStatements) selectDevicesByLocalpart(
for rows.Next() {
var dev api.Device
- var id, displayname sql.NullString
- err = rows.Scan(&id, &displayname)
+ var lastseents sql.NullInt64
+ var id, displayname, ip, useragent sql.NullString
+ err = rows.Scan(&id, &displayname, &lastseents, &ip, &useragent)
if err != nil {
return devices, err
}
@@ -267,6 +268,16 @@ func (s *devicesStatements) selectDevicesByLocalpart(
if displayname.Valid {
dev.DisplayName = displayname.String
}
+ if lastseents.Valid {
+ dev.LastSeenTS = lastseents.Int64
+ }
+ if ip.Valid {
+ dev.LastSeenIP = ip.String
+ }
+ if useragent.Valid {
+ dev.UserAgent = useragent.String
+ }
+
dev.UserID = userutil.MakeUserID(localpart, s.serverName)
devices = append(devices, dev)
}