Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var apnConfig = common.config('apn', true) || {};
if (!apnConfig.cert && !apnConfig.pfx) {
// defaults
apnConfig.cert = process.cwd()+"/config/cert.pem";
if (!apnConfig.key) {
apnConfig.key = process.cwd()+"/config/key.pem";
}
}
var apnConnection = new apn.Connection(apnConfig);
var note = new apn.Notification();
note.badge = 1;
note.alert = opts.message;
note.payload = opts.payload;
return Promise.try(function() {
if (process.env.NODE_ENV == 'test') {
return common.redis.rpushAsync('yodel:push', JSON.stringify(note));
} else {
apnConnection.pushNotification(note, tokens);
return;
}
}).then(function() {
return device.emit('notified', null, 'notify');
});
}
.set('instance_id', req.params.instance_id)
.value();
function done(encodedCredentials) {
const credentials = utils.decodeBase64(encodedCredentials);
res.status(CONST.HTTP_STATUS_CODE.CREATED).send({
credentials: credentials
});
}
function conflict(err) {
/* jshint unused:false */
res.status(CONST.HTTP_STATUS_CODE.CONFLICT).send({});
}
return Promise
.try(() => {
return eventmesh.apiServerClient.createOSBResource({
resourceGroup: CONST.APISERVER.RESOURCE_GROUPS.INTEROPERATOR,
resourceType: CONST.APISERVER.RESOURCE_TYPES.INTEROPERATOR_SERVICEBINDINGS,
resourceId: params.binding_id,
metadata: {
finalizers: [`${CONST.APISERVER.FINALIZERS.BROKER}`]
},
labels: {
instance_guid: req.params.instance_id
},
spec: params,
status: {
state: CONST.APISERVER.RESOURCE_STATE.IN_QUEUE
}
});
findAllDeployments(fetchFromApiServer) {
return Promise
.all([
this.getServiceFabrikDeployments(),
Promise.try(() => {
if (fetchFromApiServer) {
return this.getServiceInstancesFromApiServer();
} else {
return this.getServiceInstancesForServiceBroker(this.serviceBrokerName);
}
})
])
.spread((deployments, instances) => _
.chain(_.keyBy(deployments, 'guid'))
.merge(_.keyBy(instances, 'metadata.guid')) // deep merge
.values()
.value()
);
}
return Promise.map(_.keys(values), function (colorId) {
return Promise.try(function () {
var row = rows[colorId]
if (row !== undefined) {
return row
}
// cdef undefined yet, resolve
return self._cdmanager.get({id: parseInt(colorId, 10)})
.then(function (cdef) {
return {
cdef: cdef,
outputs: jsUtil.getArrayOfNull(tx.outputs.length)
}
})
})
.then(function (row) {
// create color values and remember
translate() {
return Promise.try(() => {
const baseKeys = Object.keys(this._base.messages);
return this._keepOnlyKeys(baseKeys, this._locale.messages)
.then((localeMessages) => {
// TODO: function filterKeys.
const alreadyTranslatedLocale = baseKeys.reduce((alreadyTranslated, baseKey) => {
if (localeMessages[baseKey] && localeMessages[baseKey].original === this._base.messages[baseKey].message) {
alreadyTranslated[baseKey] = localeMessages[baseKey];
}
return alreadyTranslated;
},
{});
// TODO: function filterKeys.
const untranslatedLocale = baseKeys.reduce((untranslated, baseKey) => {
processRequest(changeObjectBody) {
return Promise.try(() => {
if (changeObjectBody.status.state === CONST.APISERVER.RESOURCE_STATE.IN_QUEUE) {
return this._processBind(changeObjectBody);
} else if (changeObjectBody.status.state === CONST.APISERVER.RESOURCE_STATE.DELETE) {
return this._processUnbind(changeObjectBody);
}
})
.catch(err => {
logger.error('Error occurred in processing request by BoshBindOperator', err);
return eventmesh.apiServerClient.updateResource({
resourceGroup: CONST.APISERVER.RESOURCE_GROUPS.BIND,
resourceType: CONST.APISERVER.RESOURCE_TYPES.DIRECTOR_BIND,
resourceId: changeObjectBody.metadata.name,
status: {
state: CONST.APISERVER.RESOURCE_STATE.FAILED,
error: utils.buildErrorJson(err)
}
function promise_to_extract_company_and_department(req, only_active = true) {
var department_id = req.params['department_id'],
company;
return Promise.try(function(){
if ( ! validator.isInt(department_id)) {
throw new Error('User '+req.user.id+' tried to open department refered by non-int ID '+department_id);
}
if (only_active) {
return req.user.getCompany({
scope : ['with_active_users', 'order_by_active_users'],
});
} else {
return req.user.getCompany({
scope : ['with_all_users'],
});
}
})
.then(function(c){
export default (store) => {
logger.debug(LABEL, 'countUpComent')
return Promise.try(() => {
store.state.article.commentCount++
})
}
module.exports = (req, res, next) => {
BbPromise.try(() => {
const request = req.azuriteRequest || {};
const { queue, message } = QueueManager.getQueueAndMessage({ queueName: request.queueName, messageId: request.messageId });
const validationContext = new ValidationContext({
request: request,
queue: queue,
message: message,
operation: req.azuriteOperation
})
validations[req.azuriteOperation](validationContext);
next();
}).catch((e) => {
res.status(e.statusCode || 500).send(e.message);
if (!e.statusCode) throw e;
});
}
return Promise.try(() => {
const messages = clone(original);
const keys = Object.keys(messages);
return Promise.try(() => {
const preparedMessages = keys
.map((key) => messages[key].message)
.map((message) => htmlEntityEncode(message))
.map((encodedMessage) => {
const preparedMessage = encodedMessage
.replace(/Talkie Premium/g, "<span class="\"notranslate\"">___TEMP_TALKIE_PREMIUM___</span>")
.replace(/Talkie/g, "<span class="\"notranslate\"">___TEMP_TALKIE___</span>")
.replace(/Premium/g, "<span class="\"notranslate\"">___TEMP_PREMIUM___</span>")
.replace(/\$(\w+)\$/g, "<span class="\"notranslate\"">$$$1$$</span>");
const htmlMessage = `<div lang="en">${preparedMessage}</div>`;
return htmlMessage;
});
return preparedMessages;