Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// add attributes
body.attrs[i] = {};
for (k in m) {
if ('url' !== k) {
body.attrs[i][k] = m[k];
}
}
url = m[k];
}
// push url into [media_url]
body.media_urls.push(url);
}
return request.post(this.wpcom, def, path, query, body, fn);
};
for (k in f) {
debug('add %o => %o', k, f[k]);
if ('file' !== k) {
param = 'attrs[' + i + '][' + k + ']';
params.formData.push([param, f[k]]);
}
}
// set file path
f = f.file;
f = 'string' === typeof f ? fs.createReadStream(f) : f;
}
params.formData.push(['media[]', f]);
}
return request.post(this.wpcom, def, params, query, null, fn);
};
Post.prototype.add = function (query, body, fn) {
if ('function' === typeof body) {
fn = body;
body = query;
query = {};
}
var path = '/sites/' + this._sid + '/posts/new';
return request.post(this.wpcom, null, path, query, body, function (err, data) {
if (err) {
return fn(err);
}
// update POST object
this._id = data.ID;
debug('Set post _id: %s', this._id);
this._slug = data.slug;
debug('Set post _slug: %s', this._slug);
fn(null, data)
}.bind(this));
};
Reblog.prototype.add = function (query, body, fn) {
if ('function' === typeof body) {
fn = body;
body = query;
query = {};
}
if (body && !body.destination_site_id) {
return fn(new Error('destination_site_id is not defined'));
}
var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';
return request.post(this.wpcom, null, path, query, body, fn);
};
Tag.prototype.add = function (query, body, fn) {
var path = '/sites/' + this._sid + '/tags/new';
return request.post(this.wpcom, null, path, query, body, fn);
};