Skip to content

Commit e5c1915

Browse files
committed
Fix deletion of credentials.json file
1 parent 4ac2b7c commit e5c1915

File tree

7 files changed

+43
-14
lines changed

7 files changed

+43
-14
lines changed

.idea/WhatsJava.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

src/main/java/icu/jnet/whatsjava/messages/WAMessageParser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private static WAMessage[] messageToObject(JsonArray childrenArray) {
9393

9494
// Convert json message of the type "chat" into WAChat
9595
private static WAChat[] chatToObject(JsonArray childrenArray) {
96-
WAChat[] WAChats = new WAChat[childrenArray.size()];
96+
WAChat[] waChats = new WAChat[childrenArray.size()];
9797

9898
for(int i = 0; i < childrenArray.size(); i++) {
9999
JsonObject chatAttributes = childrenArray.get(i).getAsJsonArray().get(1).getAsJsonObject();
@@ -103,10 +103,10 @@ private static WAChat[] chatToObject(JsonArray childrenArray) {
103103
long lastInteraction = chatAttributes.get("t").getAsLong();
104104
boolean muted = chatAttributes.get("mute").getAsBoolean();
105105

106-
WAChats[i] = new WAChat(jid, name, unreadMessages, lastInteraction, muted);
106+
waChats[i] = new WAChat(jid, name, unreadMessages, lastInteraction, muted);
107107
}
108-
storedWAChats = WAChats;
109-
return WAChats;
108+
storedWAChats = waChats;
109+
return waChats;
110110
}
111111

112112
// Convert json message of the type "contacts" into WebChat

src/main/java/icu/jnet/whatsjava/whatsapp/WABackendConnector.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,15 @@ private int initOrRestoreSession() {
152152

153153
String challengeResponse = sendText(challengeRequest);
154154
loginStatus = Utils.encodeValidJson(challengeResponse).get("status").getAsInt();
155-
156-
// An error occurred during authentication
157-
// Old session data is invalid so it gets deleted
158-
if(loginStatus != 200) {
159-
AuthCredentials.deletePreviousSession(credentialsPath);
160-
disconnect();
161-
}
162155
} else {
163156
loginStatus = Utils.encodeValidJson(restoreResponse).get("status").getAsInt();
164157
}
158+
// An error occurred during authentication
159+
// Old session data is invalid so it gets deleted
160+
if(loginStatus != 200) {
161+
AuthCredentials.deletePreviousSession(credentialsPath);
162+
disconnect();
163+
}
165164
}
166165
listener.onReceiveLoginResponse(loginStatus);
167166
return loginStatus;
@@ -216,14 +215,14 @@ private String waitForTextMessage(String... search) {
216215
}
217216
}
218217
}
219-
Utils.waitMill(100);
218+
Utils.waitMill(50);
220219
}
221220
}
222221
return null;
223222
}
224223

225224
@Override
226-
public void onTextMessage(WebSocket websocket, String message) throws Exception {
225+
public void onTextMessage(WebSocket websocket, String message) {
227226
textMessageBuffer.add(message);
228227
}
229228

@@ -232,7 +231,7 @@ public void onBinaryMessage(WebSocket websocket, byte[] binaryMessage) throws Ex
232231
// Decrypt binary message
233232
byte[] decrypted = BinaryEncryption.decrypt(binaryMessage, auth.getEncryptionKeyPair());
234233

235-
// Use protobuf to make messages of the type "message" human readable
234+
// Use protobuf to make messages of the type "message" human-readable
236235
String decoded = new BinaryDecoder().decode(decrypted);
237236
textMessageBuffer.add(decoded);
238237
WAMessageParser.jsonToObjects(decoded);

0 commit comments

Comments
 (0)