diff --git a/src/backend/src/routers/whoami.js b/src/backend/src/routers/whoami.js index d58591ffd..9898fc03e 100644 --- a/src/backend/src/routers/whoami.js +++ b/src/backend/src/routers/whoami.js @@ -55,6 +55,26 @@ const whoami_common = ({ is_user, user }) => { } } + if(user.last_activity_ts){ + let dateString = user.last_activity_ts; + + // Replace the space with 'T' to make it ISO 8601 compliant + const isoString = dateString.replace(' ', 'T'); + + // Create a Date object and get the epoch timestamp + let epoch; + try{ + epoch = new Date(isoString).getTime() / 1000; + // round to 1 decimal place + epoch = Math.round(epoch); + }catch(e){ + console.error('Error parsing last_activity_ts', e); + } + + // add last_activity_ts + details.last_activity_ts = epoch; + } + return details; };