Display possible solution for badtoken error

This commit is contained in:
neslihanturan 2018-12-14 18:03:26 +03:00
parent 5b25229a5c
commit ce4a0c1194
2 changed files with 9 additions and 1 deletions

View file

@ -44,6 +44,7 @@ import java.util.concurrent.Callable;
import fr.free.nrw.commons.BuildConfig;
import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.PageTitle;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.achievements.FeedbackResponse;
import fr.free.nrw.commons.auth.AccountUtil;
import fr.free.nrw.commons.category.CategoryImageUtils;
@ -52,6 +53,7 @@ import fr.free.nrw.commons.notification.Notification;
import fr.free.nrw.commons.notification.NotificationUtils;
import fr.free.nrw.commons.utils.ContributionUtils;
import fr.free.nrw.commons.utils.DateUtils;
import fr.free.nrw.commons.utils.ViewUtil;
import in.yuvi.http.fluent.Http;
import io.reactivex.Observable;
import io.reactivex.Single;
@ -79,6 +81,8 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
private Gson gson;
private final OkHttpClient okHttpClient;
private final String ERROR_CODE_BAD_TOKEN = "badtoken";
public ApacheHttpClientMediaWikiApi(Context context,
String apiURL,
String wikidatApiURL,
@ -898,8 +902,11 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
if (!resultStatus.equals("Success")) {
String errorCode = result.getString("/api/error/@code");
Log.d("deneme","error code: "+errorCode);
Timber.e(errorCode);
if (errorCode.equals(ERROR_CODE_BAD_TOKEN)) {
ViewUtil.showLongToast(context, R.string.bad_token_error_proposed_solution);
}
return new UploadResult(resultStatus, errorCode);
} else {
// If success we have to remove file from temp directory

View file

@ -434,5 +434,6 @@ Upload your first media by touching the camera or gallery icon above.</string>
<string name="display_location_permission_explanation">Ask for location permission when needed for nearby notification card view feature.</string>
<string name="this_function_needs_network_connection">This function requires network connection, please check your connection settings.</string>
<string name="bad_token_error_proposed_solution">Upload failed with "badtoken" error. Logging out and in again usually help to solve this issue. Meanwhile, we are working to prevent this error. </string>
</resources>