Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vk-fast-longpoll

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vk-fast-longpoll - npm Package Compare versions

Comparing version 2.1.6 to 2.1.7

.npmignore

9

examples/sample.js
const VK = require('../');
const html = require('html-entities').XmlEntities;
const config = require('./config');
const group = new VK('api key here');
const group = new VK(config.token);
group.longpoll.start();

@@ -15,2 +16,6 @@

}
})
});
group.file.uploadMessagesPhoto('http://placehold.it/350x150').then((ph) => {
console.log(ph);
}).catch(console.error);

@@ -8,2 +8,5 @@ const request = require('request');

module.exports = class {
/**
* @param {String} token - VK user or group token
*/
constructor(token)

@@ -10,0 +13,0 @@ {

@@ -6,2 +6,6 @@ const request = require('request');

module.exports = class {
/**
* @param {Object} api - api object
*/
constructor(api)

@@ -11,2 +15,6 @@ {

}
/**
* Upload photo to message server
* @param {string} file - path to file of url
*/
uploadMessagesPhoto(file) {

@@ -24,3 +32,5 @@ return new Promise((resolve,reject) => {

let mimeType = mime(body);
this._api.photos.getMessagesUploadServer().then((server) => {
if(!fileName.endsWith('.' + mimeType.ext))
fileName += '.' + mimeType.ext;
this._api.api.photos.getMessagesUploadServer().then((server) => {
let boundary = Math.round(Math.random()*1000000000).toString(32);

@@ -32,4 +42,5 @@ let req = request.post({

}, (err, res, body) => {
console.log(body);
if(!err && res.statusCode == 200)
this._api.photos.saveMessagesPhoto(body).then(resolve).catch(reject);
this._api.api.photos.saveMessagesPhoto(body).then(resolve).catch(reject);
else if(err)

@@ -40,3 +51,3 @@ reject(err);

});
req.write('--' + boundary + '\r\nContent-Disposition: form-data; name="photo"; filename="' + fileName + '"\r\nContent-Type: ' + mimeType + '\r\n\r\n');
req.write('--' + boundary + '\r\nContent-Disposition: form-data; name="photo"; filename="' + fileName + '"\r\nContent-Type: ' + mimeType.mime + '\r\n\r\n');
req.write(body);

@@ -58,3 +69,3 @@ req.write('\r\n--' + boundary + '--');

let mimeType = mime(content);
this._api.photos.getMessagesUploadServer().then((server) => {
this._api.api.photos.getMessagesUploadServer().then((server) => {
let boundary = Math.round(Math.random()*1000000000).toString(32);

@@ -67,3 +78,3 @@ let req = request.post({

if(!err && res.statusCode == 200)
this._api.photos.saveMessagesPhoto(body).then(resolve).catch(reject);
this._api.api.photos.saveMessagesPhoto(body).then(resolve).catch(reject);
else if(err)

@@ -70,0 +81,0 @@ reject(err);

@@ -42,3 +42,5 @@ const request = require('request');

}
/**
* Starts longpoll listening
*/
start()

@@ -147,3 +149,7 @@ {

}
/**
* Bind function to event
* @param {string} event - event name
* @param {function} callback
*/
on(event, callback)

@@ -150,0 +156,0 @@ {

@@ -34,5 +34,5 @@ {

"scripts": {
"sample": "node examples/sample.js"
"test": "node examples/sample.js"
},
"version": "2.1.6",
"version": "2.1.7",
"bugs": {

@@ -39,0 +39,0 @@ "url": "https://github.com/emcifuntik/vk-fast-longpoll/issues/new",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc