@iobroker/socket-classes 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/lib/socketCommands.js +32 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -888,6 +888,9 @@ Read all instances of the given adapter, or all instances of all adapters if ada
|
|
|
888
888
|
-->
|
|
889
889
|
|
|
890
890
|
## Changelog
|
|
891
|
+
### 1.1.1 (2022-12-22)
|
|
892
|
+
* (bluefox) Corrected error with subscribe
|
|
893
|
+
|
|
891
894
|
### 1.1.0 (2022-12-22)
|
|
892
895
|
* (bluefox) Added user check to many commands
|
|
893
896
|
* (bluefox) Downgrade axios to 0.27.2
|
package/lib/socketCommands.js
CHANGED
|
@@ -280,19 +280,21 @@ class SocketCommands {
|
|
|
280
280
|
s.push({pattern: key, regex: new RegExp(p)});
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
+
const options = socket && socket._acl ? {user: socket._acl.user} : undefined;
|
|
284
|
+
|
|
283
285
|
if (this.subscribes[type][key] === undefined) {
|
|
284
286
|
this.subscribes[type][key] = 1;
|
|
285
287
|
if (type === 'stateChange') {
|
|
286
|
-
this.adapter.subscribeForeignStates(pattern,
|
|
288
|
+
this.adapter.subscribeForeignStates(pattern, options);
|
|
287
289
|
} else if (type === 'objectChange') {
|
|
288
|
-
this.adapter.subscribeForeignObjects && this.adapter.subscribeForeignObjects(pattern,
|
|
290
|
+
this.adapter.subscribeForeignObjects && this.adapter.subscribeForeignObjects(pattern, options);
|
|
289
291
|
} else if (type === 'log') {
|
|
290
292
|
if (!this.logEnabled && this.adapter.requireLog) {
|
|
291
293
|
this.logEnabled = true;
|
|
292
|
-
this.adapter.requireLog(true);
|
|
294
|
+
this.adapter.requireLog(true, options);
|
|
293
295
|
}
|
|
294
296
|
} else if (type === 'fileChange') {
|
|
295
|
-
this.adapter.subscribeForeignFiles && this.adapter.subscribeForeignFiles(pattern, patternFile,
|
|
297
|
+
this.adapter.subscribeForeignFiles && this.adapter.subscribeForeignFiles(pattern, patternFile, options);
|
|
296
298
|
}
|
|
297
299
|
} else {
|
|
298
300
|
this.subscribes[type][key]++;
|
|
@@ -317,6 +319,8 @@ class SocketCommands {
|
|
|
317
319
|
key = pattern;
|
|
318
320
|
}
|
|
319
321
|
|
|
322
|
+
const options = socket && socket._acl ? {user: socket._acl.user} : undefined;
|
|
323
|
+
|
|
320
324
|
if (socket && typeof socket === 'object') {
|
|
321
325
|
if (!socket.subscribe || !socket.subscribe[type]) {
|
|
322
326
|
return;
|
|
@@ -324,26 +328,25 @@ class SocketCommands {
|
|
|
324
328
|
|
|
325
329
|
for (let i = socket.subscribe[type].length - 1; i >= 0; i--) {
|
|
326
330
|
if (socket.subscribe[type][i].pattern === key) {
|
|
327
|
-
|
|
328
331
|
// Remove pattern from global list
|
|
329
332
|
if (this.subscribes[type][key] !== undefined) {
|
|
330
333
|
this.subscribes[type][key]--;
|
|
331
334
|
if (this.subscribes[type][key] <= 0) {
|
|
332
335
|
if (type === 'stateChange') {
|
|
333
336
|
//console.log((socket._name || socket.id) + ' unsubscribeForeignStates ' + pattern);
|
|
334
|
-
this.adapter.unsubscribeForeignStates(pattern,
|
|
337
|
+
this.adapter.unsubscribeForeignStates(pattern, options);
|
|
335
338
|
} else if (type === 'objectChange') {
|
|
336
339
|
//console.log((socket._name || socket.id) + ' unsubscribeForeignObjects ' + pattern);
|
|
337
|
-
this.adapter.unsubscribeForeignObjects && this.adapter.unsubscribeForeignObjects(pattern,
|
|
340
|
+
this.adapter.unsubscribeForeignObjects && this.adapter.unsubscribeForeignObjects(pattern, options);
|
|
338
341
|
} else if (type === 'log') {
|
|
339
342
|
//console.log((socket._name || socket.id) + ' requireLog false');
|
|
340
343
|
if (this.logEnabled && this.adapter.requireLog) {
|
|
341
344
|
this.logEnabled = false;
|
|
342
|
-
this.adapter.requireLog(false);
|
|
345
|
+
this.adapter.requireLog(false, options);
|
|
343
346
|
}
|
|
344
347
|
} else if (type === 'fileChange') {
|
|
345
348
|
//console.log((socket._name || socket.id) + ' requireLog false');
|
|
346
|
-
this.adapter.unsubscribeForeignFiles && this.adapter.unsubscribeForeignFiles(pattern, patternFile,
|
|
349
|
+
this.adapter.unsubscribeForeignFiles && this.adapter.unsubscribeForeignFiles(pattern, patternFile, options);
|
|
347
350
|
}
|
|
348
351
|
delete this.subscribes[type][pattern];
|
|
349
352
|
}
|
|
@@ -360,16 +363,16 @@ class SocketCommands {
|
|
|
360
363
|
this.subscribes[type][key]--;
|
|
361
364
|
if (this.subscribes[type][key] <= 0) {
|
|
362
365
|
if (type === 'stateChange') {
|
|
363
|
-
this.adapter.unsubscribeForeignStates(pattern,
|
|
366
|
+
this.adapter.unsubscribeForeignStates(pattern, options);
|
|
364
367
|
} else if (type === 'objectChange') {
|
|
365
|
-
this.adapter.unsubscribeForeignObjects && this.adapter.unsubscribeForeignObjects(pattern,
|
|
368
|
+
this.adapter.unsubscribeForeignObjects && this.adapter.unsubscribeForeignObjects(pattern, options);
|
|
366
369
|
} else if (type === 'log') {
|
|
367
370
|
if (this.adapter.requireLog && this.logEnabled) {
|
|
368
371
|
this.logEnabled = false;
|
|
369
|
-
this.adapter.requireLog(false);
|
|
372
|
+
this.adapter.requireLog(false, options);
|
|
370
373
|
}
|
|
371
374
|
} else if (type === 'fileChange') {
|
|
372
|
-
this.adapter.unsubscribeForeignFiles && this.adapter.unsubscribeForeignFiles(pattern, patternFile,
|
|
375
|
+
this.adapter.unsubscribeForeignFiles && this.adapter.unsubscribeForeignFiles(pattern, patternFile, options);
|
|
373
376
|
}
|
|
374
377
|
delete this.subscribes[type][key];
|
|
375
378
|
}
|
|
@@ -378,19 +381,19 @@ class SocketCommands {
|
|
|
378
381
|
Object.keys(this.subscribes[type]).forEach(pattern => {
|
|
379
382
|
if (type === 'stateChange') {
|
|
380
383
|
//console.log((socket._name || socket.id) + ' unsubscribeForeignStates ' + pattern);
|
|
381
|
-
this.adapter.unsubscribeForeignStates(pattern,
|
|
384
|
+
this.adapter.unsubscribeForeignStates(pattern, options);
|
|
382
385
|
} else if (type === 'objectChange') {
|
|
383
386
|
//console.log((socket._name || socket.id) + ' unsubscribeForeignObjects ' + pattern);
|
|
384
|
-
this.adapter.unsubscribeForeignObjects && this.adapter.unsubscribeForeignObjects(pattern,
|
|
387
|
+
this.adapter.unsubscribeForeignObjects && this.adapter.unsubscribeForeignObjects(pattern, options);
|
|
385
388
|
} else if (type === 'log') {
|
|
386
389
|
//console.log((socket._name || socket.id) + ' requireLog false');
|
|
387
390
|
if (this.adapter.requireLog && this.logEnabled) {
|
|
388
391
|
this.logEnabled = false;
|
|
389
|
-
this.adapter.requireLog(false);
|
|
392
|
+
this.adapter.requireLog(false, options);
|
|
390
393
|
}
|
|
391
394
|
} else if (type === 'fileChange') {
|
|
392
395
|
const [id, fileName] = pattern.split('####');
|
|
393
|
-
this.adapter.unsubscribeForeignFiles && this.adapter.unsubscribeForeignFiles(id, fileName,
|
|
396
|
+
this.adapter.unsubscribeForeignFiles && this.adapter.unsubscribeForeignFiles(id, fileName, options);
|
|
394
397
|
}
|
|
395
398
|
});
|
|
396
399
|
|
|
@@ -413,22 +416,24 @@ class SocketCommands {
|
|
|
413
416
|
return;
|
|
414
417
|
}
|
|
415
418
|
|
|
419
|
+
const options = socket && socket._acl ? {user: socket._acl.user} : undefined;
|
|
420
|
+
|
|
416
421
|
for (let i = 0; i < socket.subscribe[type].length; i++) {
|
|
417
422
|
const pattern = socket.subscribe[type][i].pattern;
|
|
418
423
|
if (this.subscribes[type][pattern] === undefined) {
|
|
419
424
|
this.subscribes[type][pattern] = 1;
|
|
420
425
|
if (type === 'stateChange') {
|
|
421
|
-
this.adapter.subscribeForeignStates(pattern,
|
|
426
|
+
this.adapter.subscribeForeignStates(pattern, options);
|
|
422
427
|
} else if (type === 'objectChange') {
|
|
423
|
-
this.adapter.subscribeForeignObjects && this.adapter.subscribeForeignObjects(pattern,
|
|
428
|
+
this.adapter.subscribeForeignObjects && this.adapter.subscribeForeignObjects(pattern, options);
|
|
424
429
|
} else if (type === 'log') {
|
|
425
430
|
if (this.adapter.requireLog && !this.logEnabled) {
|
|
426
431
|
this.logEnabled = true;
|
|
427
|
-
this.adapter.requireLog(true);
|
|
432
|
+
this.adapter.requireLog(true, options);
|
|
428
433
|
}
|
|
429
434
|
} else if (type === 'fileChange') {
|
|
430
435
|
const [id, fileName] = pattern.split('####');
|
|
431
|
-
this.adapter.subscribeForeignFiles && this.adapter.subscribeForeignFiles(id, fileName,
|
|
436
|
+
this.adapter.subscribeForeignFiles && this.adapter.subscribeForeignFiles(id, fileName, options);
|
|
432
437
|
}
|
|
433
438
|
} else {
|
|
434
439
|
this.subscribes[type][pattern]++;
|
|
@@ -451,23 +456,25 @@ class SocketCommands {
|
|
|
451
456
|
return;
|
|
452
457
|
}
|
|
453
458
|
|
|
459
|
+
const options = socket && socket._acl ? {user: socket._acl.user} : undefined;
|
|
460
|
+
|
|
454
461
|
for (let i = 0; i < socket.subscribe[type].length; i++) {
|
|
455
462
|
const pattern = socket.subscribe[type][i].pattern;
|
|
456
463
|
if (this.subscribes[type][pattern] !== undefined) {
|
|
457
464
|
this.subscribes[type][pattern]--;
|
|
458
465
|
if (this.subscribes[type][pattern] <= 0) {
|
|
459
466
|
if (type === 'stateChange') {
|
|
460
|
-
this.adapter.unsubscribeForeignStates(pattern,
|
|
467
|
+
this.adapter.unsubscribeForeignStates(pattern, options);
|
|
461
468
|
} else if (type === 'objectChange') {
|
|
462
|
-
this.adapter.unsubscribeForeignObjects && this.adapter.unsubscribeForeignObjects(pattern,
|
|
469
|
+
this.adapter.unsubscribeForeignObjects && this.adapter.unsubscribeForeignObjects(pattern, options);
|
|
463
470
|
} else if (type === 'log') {
|
|
464
471
|
if (this.adapter.requireLog && !this.logEnabled) {
|
|
465
472
|
this.logEnabled = true;
|
|
466
|
-
this.adapter.requireLog(true);
|
|
473
|
+
this.adapter.requireLog(true, options);
|
|
467
474
|
}
|
|
468
475
|
} else if (type === 'fileChange') {
|
|
469
476
|
const [id, fileName] = pattern.split('####');
|
|
470
|
-
this.adapter.unsubscribeForeignFiles && this.adapter.unsubscribeForeignFiles(id, fileName,
|
|
477
|
+
this.adapter.unsubscribeForeignFiles && this.adapter.unsubscribeForeignFiles(id, fileName, options);
|
|
471
478
|
}
|
|
472
479
|
delete this.subscribes[type][pattern];
|
|
473
480
|
}
|