diff --git a/README.md b/README.md index 8fd7a24..520acb0 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,6 @@ Being developed on Ubuntu 18.04. ### What could be done next -* Differentiate between phone not connected and stored session rejected. * Support group conversations properly. * Implement receiving audio, media, and document messages. * Wait for server message received acknowledgement before displaying sent message locally. diff --git a/libgowhatsapp.c b/libgowhatsapp.c index 3bd9cb1..46ad30d 100644 --- a/libgowhatsapp.c +++ b/libgowhatsapp.c @@ -177,7 +177,13 @@ gowhatsapp_eventloop(gpointer userdata) } switch(gwamsg.msgtype) { case gowhatsapp_message_type_error: - purple_connection_error(pc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, gwamsg.text); + if (strstr(gwamsg.text, "401")) { + // received error mentioning 401 – assume login failed and try again without stored session + gowhatsapp_go_login((uintptr_t)pc, NULL, NULL, NULL, NULL, NULL, NULL); + // alternatively let the user handle the session reset and just display purple_connection_error(pc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, gwamsg.text); + } else { + purple_connection_error(pc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, gwamsg.text); + } break; case gowhatsapp_message_type_session: purple_account_set_string(pc->account, GOWHATSAPP_SESSION_CLIENDID_KEY, gwamsg.clientId);