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

puregram

Package Overview
Dependencies
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puregram - npm Package Compare versions

Comparing version 1.1.9-rc.7 to 1.1.9-rc.8

2

package.json
{
"name": "puregram",
"version": "1.1.9-rc.7",
"version": "1.1.9-rc.8",
"main": "src/index.js",

@@ -5,0 +5,0 @@ "repository": {

@@ -251,2 +251,4 @@ let { inspect } = require('util');

get attachments() {
if (this.newAttachments) return this.newAttachments;
let attachments = [];

@@ -271,2 +273,6 @@

set attachments(newAttachments) {
this.newAttachments = newAttachments;
}
hasAttachments(type = null) {

@@ -273,0 +279,0 @@ if (type === null) return this.attachments.length > 0;

@@ -251,2 +251,4 @@ let { inspect } = require('util');

get attachments() {
if (this.newAttachments) return this.newAttachments;
let attachments = [];

@@ -271,2 +273,6 @@

set attachments(newAttachments) {
this.newAttachments = newAttachments;
}
hasAttachments(type = null) {

@@ -273,0 +279,0 @@ if (type === null) return this.attachments.length > 0;

@@ -251,2 +251,4 @@ let { inspect } = require('util');

get attachments() {
if (this.newAttachments) return this.newAttachments;
let attachments = [];

@@ -271,2 +273,6 @@

set attachments(newAttachments) {
this.newAttachments = newAttachments;
}
hasAttachments(type = null) {

@@ -273,0 +279,0 @@ if (type === null) return this.attachments.length > 0;

@@ -310,2 +310,4 @@ let { inspect } = require('util');

get attachments() {
if (this.newAttachments) return this.newAttachments;
let attachments = [];

@@ -330,2 +332,6 @@

set attachments(newAttachments) {
this.newAttachments = newAttachments;
}
hasAttachments(type = null) {

@@ -332,0 +338,0 @@ if (type === null) return this.attachments.length > 0;

@@ -14,3 +14,4 @@ let https = require('https');

keepAliveMsecs: 1000,
})
}),
mergeEvents = false
}) {

@@ -20,2 +21,3 @@ this.token = token;

this.agent = agent;
this.mergeEvents = mergeEvents;

@@ -22,0 +24,0 @@ if (this.baseApiUrl.startsWith('http://')) {

@@ -175,14 +175,22 @@ let middlewareIo = require('middleware-io');

updates.forEach(
async (update) => {
try {
await this.pollingHandler(update);
} catch (e) {
console.error('Handle polling update error:', e);
if (this.telegram.mergeEvents) {
try {
await this.mergePollingHandler(updates);
} catch (e) {
console.error('Handle polling update merging error:', e);
}
} else {
updates.forEach(
async (update) => {
try {
await this.pollingHandler(update);
} catch (e) {
console.error('Handle polling update error:', e);
}
}
},
);
);
}
}
async pollingHandler(update) {
async pollingHandler(update, merging = false) {
this.offset = update.update_id + 1 || this.offset;

@@ -221,5 +229,71 @@

return this.dispatchMiddleware(context);
if (!merging) return this.dispatchMiddleware(context);
return context;
}
async mergePollingHandler(updates) {
// eslint-cringe-code-linter-enable
const kContexts = await Promise.all(
updates.map(
update => this.pollingHandler(update, true)
)
);
const fContexts = kContexts.filter(
xContext => xContext.mediaGroupId
);
if (!fContexts.length) {
return updates.forEach(
async (update) => {
try {
await this.pollingHandler(update);
} catch (e) {
console.error('Handle polling update error:', e);
}
}
);
}
const mediaGroupIds = {};
fContexts.forEach(
(update) => {
if (!mediaGroupIds[update.mediaGroupId]) {
mediaGroupIds[update.mediaGroupId] = [];
}
mediaGroupIds[update.mediaGroupId].push(
update
);
}
);
const actualContexts = [];
// Array<Context>
for (const arrayOfContexts of Object.values(mediaGroupIds)) {
let mainContext = arrayOfContexts[0];
arrayOfContexts.slice(1).forEach(
(context) => {
mainContext.attachments = [
...mainContext.attachments,
...context.attachments
];
}
)
actualContexts.push(mainContext);
}
return actualContexts.forEach(
context => this.dispatchMiddleware(context)
);
// eslint-cringe-code-linter-disable
}
dispatchMiddleware(context) {

@@ -226,0 +300,0 @@ return this.stackMiddleware(context, middlewareIo.noopNext);

Sorry, the diff of this file is too big to display

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