Reporting
This commit is contained in:
@@ -22,12 +22,17 @@ public class GetAccountStatuses extends MastodonAPIRequest<List<Status>>{
|
||||
case DEFAULT -> addQueryParameter("exclude_replies", "true");
|
||||
case INCLUDE_REPLIES -> {}
|
||||
case MEDIA -> addQueryParameter("only_media", "true");
|
||||
case NO_REBLOGS -> {
|
||||
addQueryParameter("exclude_replies", "true");
|
||||
addQueryParameter("exclude_reblogs", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum Filter{
|
||||
DEFAULT,
|
||||
INCLUDE_REPLIES,
|
||||
MEDIA
|
||||
MEDIA,
|
||||
NO_REBLOGS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.joinmastodon.android.api.requests.reports;
|
||||
|
||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||
import org.joinmastodon.android.model.ReportReason;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SendReport extends MastodonAPIRequest<Object>{
|
||||
public SendReport(String accountID, ReportReason reason, List<String> statusIDs, List<String> ruleIDs, String comment, boolean forward){
|
||||
super(HttpMethod.POST, "/reports", Object.class);
|
||||
Body b=new Body();
|
||||
b.accountId=accountID;
|
||||
b.statusIds=statusIDs;
|
||||
b.comment=comment;
|
||||
b.forward=forward;
|
||||
b.category=reason;
|
||||
b.ruleIds=ruleIDs;
|
||||
setRequestBody(b);
|
||||
}
|
||||
|
||||
private static class Body{
|
||||
public String accountId;
|
||||
public List<String> statusIds;
|
||||
public String comment;
|
||||
public boolean forward;
|
||||
public ReportReason category;
|
||||
public List<String> ruleIds;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import org.joinmastodon.android.api.MastodonAPIController;
|
||||
import org.joinmastodon.android.api.StatusInteractionController;
|
||||
import org.joinmastodon.android.model.Account;
|
||||
import org.joinmastodon.android.model.Application;
|
||||
import org.joinmastodon.android.model.Instance;
|
||||
import org.joinmastodon.android.model.Token;
|
||||
|
||||
public class AccountSession{
|
||||
@@ -13,16 +14,19 @@ public class AccountSession{
|
||||
public int tootCharLimit;
|
||||
public Application app;
|
||||
public long infoLastUpdated;
|
||||
public long instanceLastUpdated;
|
||||
public Instance instance;
|
||||
private transient MastodonAPIController apiController;
|
||||
private transient StatusInteractionController statusInteractionController;
|
||||
|
||||
AccountSession(Token token, Account self, Application app, String domain, int tootCharLimit){
|
||||
AccountSession(Token token, Account self, Application app, String domain, int tootCharLimit, Instance instance){
|
||||
this.token=token;
|
||||
this.self=self;
|
||||
this.domain=domain;
|
||||
this.app=app;
|
||||
this.tootCharLimit=tootCharLimit;
|
||||
infoLastUpdated=System.currentTimeMillis();
|
||||
this.instance=instance;
|
||||
instanceLastUpdated=infoLastUpdated=System.currentTimeMillis();
|
||||
}
|
||||
|
||||
AccountSession(){}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.api.MastodonAPIController;
|
||||
import org.joinmastodon.android.api.requests.instance.GetCustomEmojis;
|
||||
import org.joinmastodon.android.api.requests.accounts.GetOwnAccount;
|
||||
import org.joinmastodon.android.api.requests.instance.GetInstance;
|
||||
import org.joinmastodon.android.api.requests.oauth.CreateOAuthApp;
|
||||
import org.joinmastodon.android.model.Account;
|
||||
import org.joinmastodon.android.model.Application;
|
||||
@@ -84,7 +85,7 @@ public class AccountSessionManager{
|
||||
}
|
||||
|
||||
public void addAccount(Instance instance, Token token, Account self, Application app){
|
||||
AccountSession session=new AccountSession(token, self, app, instance.uri, instance.maxTootChars);
|
||||
AccountSession session=new AccountSession(token, self, app, instance.uri, instance.maxTootChars, instance);
|
||||
sessions.put(session.getID(), session);
|
||||
lastActiveAccountID=session.getID();
|
||||
writeAccountsFile();
|
||||
@@ -212,7 +213,7 @@ public class AccountSessionManager{
|
||||
HashSet<String> domains=new HashSet<>();
|
||||
for(AccountSession session:sessions.values()){
|
||||
domains.add(session.domain.toLowerCase());
|
||||
if(now-session.infoLastUpdated>24L*3600_000L){
|
||||
if(now-session.infoLastUpdated>24L*3600_000L || now-session.instanceLastUpdated>24L*360_000L*3L){
|
||||
updateSessionLocalInfo(session);
|
||||
}
|
||||
}
|
||||
@@ -247,6 +248,21 @@ public class AccountSessionManager{
|
||||
}
|
||||
})
|
||||
.exec(session.getID());
|
||||
new GetInstance()
|
||||
.setCallback(new Callback<>(){
|
||||
@Override
|
||||
public void onSuccess(Instance result){
|
||||
session.instance=result;
|
||||
session.instanceLastUpdated=System.currentTimeMillis();
|
||||
writeAccountsFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorResponse error){
|
||||
|
||||
}
|
||||
})
|
||||
.exec(session.getID());
|
||||
}
|
||||
|
||||
private void updateCustomEmojis(String domain){
|
||||
|
||||
Reference in New Issue
Block a user