mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Updated comments and method headers to clarify that the block status being checked within AuthenticatedActivity refers to the Wikimedia Commons block status of the user
This commit is contained in:
parent
f9eed2027c
commit
22a5178e04
5 changed files with 15 additions and 15 deletions
|
|
@ -54,12 +54,12 @@ public abstract class AuthenticatedActivity extends NavigationBaseActivity {
|
|||
protected abstract void onAuthFailure();
|
||||
|
||||
/**
|
||||
* Makes API call to check if user is blocked. If the user is blocked, a snackbar
|
||||
* Makes API call to check if user is blocked from Commons. If the user is blocked, a snackbar
|
||||
* is created to notify the user
|
||||
*/
|
||||
protected void showBlockStatus()
|
||||
{
|
||||
Observable.fromCallable(() -> mediaWikiApi.isUserBlocked())
|
||||
Observable.fromCallable(() -> mediaWikiApi.isUserBlockedFromCommons())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.filter(result -> result)
|
||||
|
|
|
|||
|
|
@ -617,11 +617,11 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a user is currently blocked
|
||||
* @return whether or not the user is blocked
|
||||
* Checks to see if a user is currently blocked from Commons
|
||||
* @return whether or not the user is blocked from Commons
|
||||
*/
|
||||
@Override
|
||||
public boolean isUserBlocked() {
|
||||
public boolean isUserBlockedFromCommons() {
|
||||
boolean userBlocked = false;
|
||||
try {
|
||||
ApiResult result = api.action("query")
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public interface MediaWikiApi {
|
|||
@NonNull
|
||||
Single<Integer> getUploadCount(String userName);
|
||||
|
||||
boolean isUserBlocked();
|
||||
boolean isUserBlockedFromCommons();
|
||||
|
||||
interface ProgressListener {
|
||||
void onProgress(long transferred, long total);
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@
|
|||
<string name="share_app_title">Share App</string>
|
||||
<string name="share_coordinates_not_present">Coordinates were not specified during image selection</string>
|
||||
<string name="error_fetching_nearby_places">Error fetching nearby places.</string>
|
||||
<string name="block_notification">You are blocked from editing commons</string>
|
||||
<string name="block_notification">You are blocked from editing Commons</string>
|
||||
|
||||
<string name="menu_set_wallpaper">Set wallpaper</string>
|
||||
<string name="wallpaper_set_successfully">Wallpaper set successfully!</string>
|
||||
|
|
|
|||
|
|
@ -225,10 +225,10 @@ class ApacheHttpClientMediaWikiApiTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun isUserBlockedForInfinitelyBlockedUser() {
|
||||
fun isUserBlockedFromCommonsForInfinitelyBlockedUser() {
|
||||
server.enqueue(MockResponse().setBody("<?xml version=\"1.0\"?><api><query><userinfo id=\"1000\" name=\"testusername\" blockid=\"3000\" blockedby=\"blockerusername\" blockedbyid=\"1001\" blockreason=\"testing\" blockedtimestamp=\"2018-05-24T15:32:09Z\" blockexpiry=\"infinite\"></userinfo></query></api>"))
|
||||
|
||||
val result = testObject.isUserBlocked();
|
||||
val result = testObject.isUserBlockedFromCommons();
|
||||
|
||||
assertBasicRequestParameters(server, "GET").let { userBlockedRequest ->
|
||||
parseQueryParams(userBlockedRequest).let { body ->
|
||||
|
|
@ -243,14 +243,14 @@ class ApacheHttpClientMediaWikiApiTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun isUserBlockedForTimeBlockedUser() {
|
||||
fun isUserBlockedFromCommonsForTimeBlockedUser() {
|
||||
val currentDate = Date()
|
||||
val expiredDate = Date(currentDate.time + 10000)
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"))
|
||||
server.enqueue(MockResponse().setBody("<?xml version=\"1.0\"?><api><query><userinfo id=\"1000\" name=\"testusername\" blockid=\"3000\" blockedby=\"blockerusername\" blockedbyid=\"1001\" blockreason=\"testing\" blockedtimestamp=\"2018-05-24T15:32:09Z\" blockexpiry=\"" + dateFormat.format(expiredDate) + "\"></userinfo></query></api>"))
|
||||
|
||||
val result = testObject.isUserBlocked();
|
||||
val result = testObject.isUserBlockedFromCommons();
|
||||
|
||||
assertBasicRequestParameters(server, "GET").let { userBlockedRequest ->
|
||||
parseQueryParams(userBlockedRequest).let { body ->
|
||||
|
|
@ -265,14 +265,14 @@ class ApacheHttpClientMediaWikiApiTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun isUserBlockedForExpiredBlockedUser() {
|
||||
fun isUserBlockedFromCommonsForExpiredBlockedUser() {
|
||||
val currentDate = Date()
|
||||
val expiredDate = Date(currentDate.time - 10000)
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"))
|
||||
server.enqueue(MockResponse().setBody("<?xml version=\"1.0\"?><api><query><userinfo id=\"1000\" name=\"testusername\" blockid=\"3000\" blockedby=\"blockerusername\" blockedbyid=\"1001\" blockreason=\"testing\" blockedtimestamp=\"2018-05-24T15:32:09Z\" blockexpiry=\"" + dateFormat.format(expiredDate) + "\"></userinfo></query></api>"))
|
||||
|
||||
val result = testObject.isUserBlocked();
|
||||
val result = testObject.isUserBlockedFromCommons();
|
||||
|
||||
assertBasicRequestParameters(server, "GET").let { userBlockedRequest ->
|
||||
parseQueryParams(userBlockedRequest).let { body ->
|
||||
|
|
@ -287,10 +287,10 @@ class ApacheHttpClientMediaWikiApiTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun isUserBlockedForNotBlockedUser() {
|
||||
fun isUserBlockedFromCommonsForNotBlockedUser() {
|
||||
server.enqueue(MockResponse().setBody("<?xml version=\"1.0\"?><api><query><userinfo id=\"1000\" name=\"testusername\"></userinfo></query></api>"))
|
||||
|
||||
val result = testObject.isUserBlocked();
|
||||
val result = testObject.isUserBlockedFromCommons();
|
||||
|
||||
assertBasicRequestParameters(server, "GET").let { userBlockedRequest ->
|
||||
parseQueryParams(userBlockedRequest).let { body ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue