Skip to content

Commit

Permalink
Dont't get Data on session refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
DEV2DEV-DE committed Jan 18, 2024
1 parent 6876cff commit 9ae7372
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class Jablotron extends utils.Adapter {
*/
async onReady() {
try {
// the polling interval should never be less than 5 seconds to prevent possisble bans
if (this.config.pollInterval < 5) throw new Error('Poll interval must be at least 5 seconds');
// the polling interval should never be less than 10 seconds to prevent possisble bans
if (this.config.pollInterval < 5) throw new Error('Poll interval must be at least 10 seconds');
// username and password are mandatory
if (!this.config.username || !this.config.password) throw new Error('Username and password are mandatory');

Expand Down Expand Up @@ -100,7 +100,7 @@ class Jablotron extends utils.Adapter {
* @param {string} username
* @param {string} password
*/
async fetchSessionId(username, password) {
async fetchSessionId(username, password, getData = true) {
try {
const url = `${baseUrl}/userAuthorize.json`;
const data = {
Expand All @@ -116,7 +116,7 @@ class Jablotron extends utils.Adapter {
this.sessionExpires = Date.now() + SESSION_LIFETIME * 1000;
this.log.debug('Session-ID: ' + sessionId);
this.log.debug('Fetching initial data from jablonet.net');
await this.getExtendedData(headers, sessionId);
if (getData) await this.getExtendedData(headers, sessionId);
return sessionId;
} else {
throw new Error('No session id received');
Expand All @@ -134,14 +134,14 @@ class Jablotron extends utils.Adapter {
* @throws {Error} If unable to connect to jablonet.net
*/
async refreshSessionId() {
this.sessionId = await this.fetchSessionId(this.config.username, this.config.password);
this.sessionId = await this.fetchSessionId(this.config.username, this.config.password, false);
this.isConnected = this.sessionId !== '';
if (this.isConnected) {
this.sessionExpires = Date.now() + SESSION_LIFETIME * 1000;
} else {
throw new Error('Not connect to jablonet.net');
throw new Error('Error refreshing session id');
}
}
}

Check failure on line 144 in main.js

View workflow job for this annotation

GitHub Actions / check-and-lint

Expected indentation of 1 tab but found 0

/**
* get data from jablonet cloud
Expand Down

0 comments on commit 9ae7372

Please sign in to comment.