mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-25 15:37:12 +00:00
make whoami return last_activity_ts
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user