Skip to content

Commit 944bede

Browse files
fixes - commons-app#3559 - Failed to send thanks" notification, but thank actually sent successfully
I create another Model Class->"MwThankPostResponse.java" to store the Result of Post Request POST(MW_API_PREFIX+"action=thank")
1 parent 8384ad0 commit 944bede

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

app/src/main/java/fr/free/nrw/commons/actions/ThanksClient.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ThanksClient @Inject constructor(
2727
fun thank(revisionId: Long): Observable<Boolean> {
2828
return try {
2929
service.thank(revisionId.toString(), null, csrfTokenClient.tokenBlocking, CommonsApplication.getInstance().userAgent)
30-
.map { mwQueryResponse -> mwQueryResponse.successVal == 1 }
30+
.map { mwThankPostResponse -> mwThankPostResponse.result.success== 1 }
3131
} catch (throwable: Throwable) {
3232
Observable.just(false)
3333
}

data-client/src/main/java/org/wikipedia/dataclient/Service.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.wikipedia.dataclient.mwapi.page.MwMobileViewPageLead;
1212
import org.wikipedia.dataclient.mwapi.page.MwMobileViewPageRemaining;
1313
import org.wikipedia.dataclient.mwapi.page.MwQueryPageSummary;
14+
import org.wikipedia.dataclient.mwapi.page.MwThankPostResponse;
1415
import org.wikipedia.edit.Edit;
1516
import org.wikipedia.edit.preview.EditPreview;
1617
import org.wikipedia.login.LoginClient;
@@ -192,7 +193,7 @@ public interface Service {
192193

193194
@FormUrlEncoded
194195
@POST(MW_API_PREFIX + "action=thank")
195-
@NonNull Observable<MwPostResponse> thank(@Nullable @Field("rev") String rev,
196+
@NonNull Observable<MwThankPostResponse> thank(@Nullable @Field("rev") String rev,
196197
@Nullable @Field("log") String log,
197198
@NonNull @Field("token") String token,
198199
@Nullable @Field("source") String source);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.wikipedia.dataclient.mwapi.page;
2+
3+
4+
import org.wikipedia.dataclient.mwapi.MwResponse;
5+
6+
public class MwThankPostResponse extends MwResponse {
7+
private Result result;
8+
9+
public Result getResult() {
10+
return result;
11+
}
12+
13+
public void setResult(Result result) {
14+
this.result = result;
15+
}
16+
17+
public class Result {
18+
private Integer success;
19+
private String recipient;
20+
21+
public Integer getSuccess() {
22+
return success;
23+
}
24+
25+
public void setSuccess(Integer success) {
26+
this.success = success;
27+
}
28+
29+
public String getRecipient() {
30+
return recipient;
31+
}
32+
33+
public void setRecipient(String recipient) {
34+
this.recipient = recipient;
35+
}
36+
37+
}
38+
}

0 commit comments

Comments
 (0)