Skip to content

Commit

Permalink
Add alternate date format fields for all returned JSON status.
Browse files Browse the repository at this point in the history
Adds "_s" version of string date formats with time represented as a UNIX epoch time integer.
Fixes #93
  • Loading branch information
Misterblue committed Aug 2, 2021
1 parent 5e3732b commit d750b4e
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 17 deletions.
7 changes: 6 additions & 1 deletion docs/API-Accounts.md
Expand Up @@ -40,7 +40,8 @@ are returned (limited by pagination).
"path": "/X,Y,Z/X,Y,Z,W",
"placeid": stringIdOfPlace,
"domainid": stringIdOfDomain,
"availability": stringWhoCanSee // one of "all", "none", "connections", "friends"
"availability": stringWhoCanSee // one of "all", "none", "connections",
"friends": []
},
"profile_detail": {}, // account detail information
"friends": [ "friendName", "friendName", ... ],
Expand All @@ -49,7 +50,9 @@ are returned (limited by pagination).
"enabled": true, // 'false' if waiting for email verification
"roles": [ "role", "role", ... ], // roles of "user", "admin", ...
"when_account_created": "YYYY-MM-DDTHH:MM:SS.MMMZ",
"when_account_created_s": 1617405661,
"time_of_last_heartbeat": "YYYY-MM-DDTHH:MM:SS.MMMZ"
"time_of_last_heartbeat_s": 1627921261
},
...
]
Expand Down Expand Up @@ -146,7 +149,9 @@ The account fields that can be fetched:
|roles | all | admin | stringArray |
|ip_addr_of_creator | all | noone | string |
|when_account_created | all | noone | ISODateString |
|when_account_created_s | all | noone | integerUnixTimeSeconds |
|time_of_last_heartbeat | all | noone | ISODateString |
|time_of_last_heartbeat_s | all | noone | integerUnixTimeSeconds |

The JSON structure returned looks like the regular REST response
with the "data" object being the value requests.
Expand Down
6 changes: 5 additions & 1 deletion docs/API-Domains.md
Expand Up @@ -60,9 +60,11 @@ A request returns an array of domain descriptions:
"user_hostnames": [];
},
"time_of_last_heartbeat": "YYYY-MM-DDTHH:MM:SS.MMMZ",
"time_of_last_heartbeat_s": 1627921261
"last_sender_key": stringHostPortSourceOfLastMessage,
"addr_of_first_contact": stringHostPortOfDomainEntryCreation,
"when_domain_entry_created": "YYYY-MM-DDTHH:MM:SS.MMMZ"
"when_domain_entry_created": "YYYY-MM-DDTHH:MM:SS.MMMZ",
"when_domain_entry_created_s": 1617405661
},
...
]
Expand Down Expand Up @@ -158,7 +160,9 @@ The domain fields that can be fetched:
| images | all | domain sponsor admin | stringArray |
| addr_of_first_contact | all | noone | string |
| when_domain_entry_created | all | noone | ISODateString |
| when_domain_entry_created_s | all | noone | integerUnixTimeSeconds |
| time_of_last_heartbeat | all | noone | ISODateString |
| time_of_last_heartbeat_s | all | noone | integerUnixTimeSeconds |
| last_sender_key | all | noone | string |

The JSON structure returned looks like the regular REST response
Expand Down
3 changes: 2 additions & 1 deletion docs/API-Explore.md
Expand Up @@ -64,7 +64,8 @@ The response is a JSON array of Place descriptions.
"current_attendance': number, // reported attendance at place
"current_images': stringURLS[],
"current_info': string,
"current_last_update_time': "ISODateString"
"current_last_update_time': "ISODateString",
"current_last_update_time_s': integerUnixTimeSeconds
},
},
...
Expand Down
6 changes: 5 additions & 1 deletion docs/API-Places.md
Expand Up @@ -110,14 +110,16 @@ This request return JSON formatted as:
'protocol_version': string, // protocol version for domain-server
'active': boolean, // true if domain is heartbeating
"time_of_last_heartbeat": ISOStringDate,
"time_of_last_heartbeat_s": integerUnixTimeSeconds,
"num_users": integer
},
"thumbnail": URL,
"images": [ URL, URL, ... ]
"current_attendance": number,
"current_images": string[],
"current_info": string,
"current_last_update_time": ISOStringDate
"current_last_update_time": ISOStringDate,
"current_last_update_time_s": integerUnixTimeSeconds
},
...
],
Expand Down Expand Up @@ -247,9 +249,11 @@ The place fields that can be fetched:
| current_images | all | domainOwner, manager, admin | stringArray |
| current_info | all | domainOwner, manager, admin | string |
| current_last_update_time | all | none | ISODateString |
| current_last_update_time_s | all | none | integerUnixTimeSeconds |
| current_api_key | domainOwner, admin | none | string |
| addr_of_first_contact | all | none | string |
| when_place_entry_created | all | none | ISODateString |
| when_place_entry_created_s | all | none | integerUnixTimeSeconds |

The JSON structure returned looks like the regular REST response
with the "data" object being the value requests.
Expand Down
2 changes: 2 additions & 0 deletions docs/API-Profiles.md
Expand Up @@ -43,7 +43,9 @@ have "availability" set to "all" are returned.
"friends": [ "friendName", "friendName", ... ],
"connections": [ "connectionName", "connectionName", ...],
"when_account_created": "YYYY-MM-DDTHH:MM:SS.MMMZ",
"when_account_created_s": integerUnixTimeSeconds,
"time_of_last_heartbeat": "YYYY-MM-DDTHH:MM:SS.MMMZ"
"time_of_last_heartbeat_s": integerUnixTimeSeconds
},
...
]
Expand Down
27 changes: 18 additions & 9 deletions src/route-tools/Util.ts
Expand Up @@ -139,7 +139,8 @@ export async function buildDomainInfo(pDomain: DomainEntity): Promise<any> {
'version': pDomain.version,
'protocol_version': pDomain.protocol,
'active': pDomain.active ?? false,
'time_of_last_heartbeat': pDomain.timeOfLastHeartbeat ? pDomain.timeOfLastHeartbeat.toISOString() : undefined,
'time_of_last_heartbeat': pDomain.timeOfLastHeartbeat?.toISOString(),
'time_of_last_heartbeat_s': pDomain.timeOfLastHeartbeat?.getTime().toString(),
'num_users': pDomain.numUsers + pDomain.anonUsers
};
};
Expand Down Expand Up @@ -188,10 +189,12 @@ export async function buildDomainInfoV1(pDomain: DomainEntity): Promise<any> {
'num_users': pDomain.numUsers,
'user_hostnames': pDomain.hostnames
},
'time_of_last_heartbeat': pDomain.timeOfLastHeartbeat ? pDomain.timeOfLastHeartbeat.toISOString() : undefined,
'time_of_last_heartbeat': pDomain.timeOfLastHeartbeat?.toISOString(),
'time_of_last_heartbeat_s': pDomain.timeOfLastHeartbeat?.getTime().toString(),
'last_sender_key': pDomain.lastSenderKey,
'addr_of_first_contact': pDomain.iPAddrOfFirstContact,
'when_domain_entry_created': pDomain.whenCreated ? pDomain.whenCreated.toISOString() : undefined
'when_domain_entry_created': pDomain.whenCreated?.toISOString(),
'when_domain_entry_created_s': pDomain.whenCreated?.getTime().toString()
};
};

Expand Down Expand Up @@ -236,8 +239,10 @@ export async function buildAccountInfo(pReq: Request, pAccount: AccountEntity):
'location': await buildLocationInfo(pAccount),
'friends': pAccount.friends,
'connections': pAccount.connections,
'when_account_created': pAccount.whenCreated ? pAccount.whenCreated.toISOString() : undefined,
'time_of_last_heartbeat': pAccount.timeOfLastHeartbeat ? pAccount.timeOfLastHeartbeat.toISOString() : undefined
'when_account_created': pAccount.whenCreated?.toISOString(),
'when_account_created_s': pAccount.whenCreated?.getTime().toString(),
'time_of_last_heartbeat': pAccount.timeOfLastHeartbeat?.toISOString(),
'time_of_last_heartbeat_s': pAccount.timeOfLastHeartbeat?.getTime().toString(),
};
};
// Return the block of account information used as the account 'profile'.
Expand All @@ -254,8 +259,10 @@ export async function buildAccountProfile(pReq: Request, pAccount: AccountEntity
},
'profile_detail': pAccount.profileDetail,
'location': await buildLocationInfo(pAccount),
'when_account_created': pAccount.whenCreated ? pAccount.whenCreated.toISOString() : undefined,
'time_of_last_heartbeat': pAccount.timeOfLastHeartbeat ? pAccount.timeOfLastHeartbeat.toISOString() : undefined
'when_account_created': pAccount.whenCreated?.toISOString(),
'when_account_created_s': pAccount.whenCreated?.getTime().toString(),
'time_of_last_heartbeat': pAccount.timeOfLastHeartbeat?.toISOString(),
'time_of_last_heartbeat_s': pAccount.timeOfLastHeartbeat?.getTime().toString(),
};
};

Expand Down Expand Up @@ -291,8 +298,10 @@ export async function buildPlaceInfoSmall(pPlace: PlaceEntity, pDomain?: DomainE
'current_attendance': pPlace.currentAttendance ?? 0,
'current_images': pPlace.currentImages,
'current_info': pPlace.currentInfo,
'current_last_update_time': pPlace.currentLastUpdateTime,
'last_activity_update': pPlace.lastActivity
'current_last_update_time': pPlace.currentLastUpdateTime?.toISOString(),
'current_last_update_time_s': pPlace.currentLastUpdateTime?.getTime().toString(),
'last_activity_update': pPlace.lastActivity?.toISOString(),
'last_activity_update_s': pPlace.lastActivity?.getTime().toString()
};
return ret;
};
Expand Down
6 changes: 4 additions & 2 deletions src/routes/api/v1/requests.ts
Expand Up @@ -39,8 +39,10 @@ const procGetRequests: RequestHandler = async (req: Request, resp: Response, nex
'type': aReq.requestType,
'requesting_account_id': aReq.requestingAccountId,
'target_account_id': aReq.targetAccountId,
'when_created': aReq.whenCreated ? aReq.whenCreated.toISOString() : undefined,
'expiration_time': aReq.expirationTime ? aReq.expirationTime.toISOString() : undefined
'when_created': aReq.whenCreated?.toISOString(),
'when_created_s': aReq.whenCreated?.getTime().toString(),
'expiration_time': aReq.expirationTime?.toISOString(),
'expiration_time_s': aReq.expirationTime?.getTime().toString()
};
switch (aReq.requestType) {
case RequestType.HANDSHAKE:
Expand Down
6 changes: 4 additions & 2 deletions src/routes/api/v1/tokens.ts
Expand Up @@ -42,8 +42,10 @@ const procGetTokens: RequestHandler = async (req: Request, resp: Response, next:
'accountId': tok.accountId,
'refresh_token': tok.refreshToken,
'scope': tok.scope,
'creation_time': tok.whenCreated ? tok.whenCreated.toISOString() : undefined,
'expiration_time': tok.expirationTime ? tok.expirationTime.toISOString() : undefined,
'creation_time': tok.whenCreated?.toISOString(),
'creation_time_s': tok.whenCreated?.getTime().toString(),
'expiration_time': tok.expirationTime?.toISOString(),
'expiration_time_s': tok.expirationTime?.getTime().toString()
});
};

Expand Down

0 comments on commit d750b4e

Please sign in to comment.