MCPcopy Index your code
hub / github.com/parse-community/parse-server / getPushTime

Method getPushTime

src/Controllers/PushController.js:183–215  ·  view source on GitHub ↗

* Get push time from the request body. * @param {Object} request A request object * @returns {Number|undefined} The push time if it exists in the request

(body = {})

Source from the content-addressed store, hash-verified

181 * @returns {Number|undefined} The push time if it exists in the request
182 */
183 static getPushTime(body = {}) {
184 var hasPushTime = Object.prototype.hasOwnProperty.call(body, 'push_time');
185 if (!hasPushTime) {
186 return;
187 }
188 var pushTimeParam = body['push_time'];
189 var date;
190 var isLocalTime = true;
191
192 if (typeof pushTimeParam === 'number') {
193 date = new Date(pushTimeParam * 1000);
194 } else if (typeof pushTimeParam === 'string') {
195 isLocalTime = !PushController.pushTimeHasTimezoneComponent(pushTimeParam);
196 date = new Date(pushTimeParam);
197 } else {
198 throw new Parse.Error(
199 Parse.Error.PUSH_MISCONFIGURED,
200 body['push_time'] + ' is not valid time.'
201 );
202 }
203 // Check pushTime is valid or not, if it is not valid, pushTime is NaN
204 if (!isFinite(date)) {
205 throw new Parse.Error(
206 Parse.Error.PUSH_MISCONFIGURED,
207 body['push_time'] + ' is not valid time.'
208 );
209 }
210
211 return {
212 date,
213 isLocalTime,
214 };
215 }
216
217 /**
218 * Checks if a ISO8601 formatted date contains a timezone component

Callers 2

sendPushMethod · 0.80

Calls 1

Tested by

no test coverage detected