1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | function validateAndFixActivity(activity) {
|
11 | if (typeof activity !== 'object') {
|
12 | throw new Error(`validateAndFixActivity(): invalid request body.`);
|
13 | }
|
14 | if (typeof activity.type !== 'string') {
|
15 | throw new Error(`validateAndFixActivity(): missing activity type.`);
|
16 | }
|
17 | if (typeof activity.timestamp === 'string') {
|
18 | activity.rawTimestamp = activity.timestamp;
|
19 | activity.timestamp = new Date(activity.timestamp);
|
20 | }
|
21 | if (typeof activity.expiration === 'string') {
|
22 | activity.rawExpiration = activity.expiration;
|
23 | activity.expiration = new Date(activity.expiration);
|
24 | }
|
25 | if (typeof activity.localTimestamp === 'string') {
|
26 | activity.rawLocalTimestamp = activity.localTimestamp;
|
27 | activity.localTimestamp = new Date(activity.localTimestamp);
|
28 | }
|
29 | return activity;
|
30 | }
|
31 | exports.validateAndFixActivity = validateAndFixActivity;
|
32 | ;
|
33 |
|
\ | No newline at end of file |