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

Function setInitial

src/StatusHandler.js:136–181  ·  view source on GitHub ↗
(body = {}, where, options = { source: 'rest' })

Source from the content-addressed store, hash-verified

134 const handler = restStatusHandler(PUSH_STATUS_COLLECTION, config);
135 let objectId = existingObjectId;
136 const setInitial = function (body = {}, where, options = { source: 'rest' }) {
137 const now = new Date();
138 let pushTime = now.toISOString();
139 let status = 'pending';
140 if (Object.prototype.hasOwnProperty.call(body, 'push_time')) {
141 if (config.hasPushScheduledSupport) {
142 pushTime = body.push_time;
143 status = 'scheduled';
144 } else {
145 logger.warn('Trying to schedule a push while server is not configured.');
146 logger.warn('Push will be sent immediately');
147 }
148 }
149
150 const data = body.data || {};
151 const payloadString = JSON.stringify(data);
152 let pushHash;
153 if (typeof data.alert === 'string') {
154 pushHash = md5Hash(data.alert);
155 } else if (typeof data.alert === 'object') {
156 pushHash = md5Hash(JSON.stringify(data.alert));
157 } else {
158 pushHash = 'd41d8cd98f00b204e9800998ecf8427e';
159 }
160 const object = {
161 pushTime,
162 query: JSON.stringify(where),
163 payload: payloadString,
164 source: options.source,
165 title: options.title,
166 expiry: body.expiration_time,
167 expiration_interval: body.expiration_interval,
168 status: status,
169 numSent: 0,
170 pushHash,
171 // lockdown!
172 ACL: {},
173 };
174 return handler.create(object).then(result => {
175 objectId = result.objectId;
176 pushStatus = {
177 objectId,
178 };
179 return Promise.resolve(pushStatus);
180 });
181 };
182
183 const setRunning = function (batches) {
184 logger.verbose(

Callers

nothing calls this directly

Calls 3

md5HashFunction · 0.90
warnMethod · 0.80
createMethod · 0.80

Tested by

no test coverage detected