Filtered posts in timelines (AND-8)

This commit is contained in:
Grishka
2023-06-07 04:47:54 +03:00
parent a24b4363d7
commit 17957b69d1
22 changed files with 253 additions and 148 deletions

View File

@@ -5,6 +5,7 @@ import org.joinmastodon.android.api.RequiredField;
import org.parceler.Parcel;
import java.time.Instant;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
@@ -22,11 +23,9 @@ public class Filter extends BaseModel{
public Instant expiresAt;
public FilterAction filterAction;
@RequiredField
public List<FilterKeyword> keywords;
public List<FilterKeyword> keywords=new ArrayList<>();
@RequiredField
public List<FilterStatus> statuses;
public List<FilterStatus> statuses=new ArrayList<>();
@Override
public void postprocess() throws ObjectValidationException{

View File

@@ -0,0 +1,21 @@
package org.joinmastodon.android.model;
import org.joinmastodon.android.api.ObjectValidationException;
import org.joinmastodon.android.api.RequiredField;
import org.parceler.Parcel;
import java.util.List;
@Parcel
public class FilterResult extends BaseModel{
@RequiredField
public Filter filter;
public List<String> keywordMatches;
@Override
public void postprocess() throws ObjectValidationException{
super.postprocess();
filter.postprocess();
}
}

View File

@@ -54,6 +54,10 @@ public class LegacyFilter extends BaseModel{
return matches(status.getContentStatus().getStrippedText());
}
public boolean isActive(){
return expiresAt==null || expiresAt.isAfter(Instant.now());
}
@Override
public String toString(){
return "Filter{"+

View File

@@ -50,6 +50,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
public Card card;
public String language;
public String text;
public List<FilterResult> filtered;
public boolean favourited;
public boolean reblogged;
@@ -63,39 +64,6 @@ public class Status extends BaseModel implements DisplayItemsParent{
public Status(){}
public Status(Status other){
this.id=other.id;
this.uri=other.uri;
this.createdAt=other.createdAt;
this.account=other.account;
this.content=other.content;
this.visibility=other.visibility;
this.sensitive=other.sensitive;
this.spoilerText=other.spoilerText;
this.mediaAttachments=other.mediaAttachments;
this.application=other.application;
this.mentions=other.mentions;
this.tags=other.tags;
this.emojis=other.emojis;
this.reblogsCount=other.reblogsCount;
this.favouritesCount=other.favouritesCount;
this.repliesCount=other.repliesCount;
this.editedAt=other.editedAt;
this.url=other.url;
this.inReplyToId=other.inReplyToId;
this.inReplyToAccountId=other.inReplyToAccountId;
this.reblog=other.reblog;
this.poll=other.poll;
this.card=other.card;
this.language=other.language;
this.text=other.text;
this.favourited=other.favourited;
this.reblogged=other.reblogged;
this.muted=other.muted;
this.bookmarked=other.bookmarked;
this.pinned=other.pinned;
}
@Override
public void postprocess() throws ObjectValidationException{
super.postprocess();
@@ -116,6 +84,10 @@ public class Status extends BaseModel implements DisplayItemsParent{
card.postprocess();
if(reblog!=null)
reblog.postprocess();
if(filtered!=null){
for(FilterResult fr:filtered)
fr.postprocess();
}
spoilerRevealed=!sensitive;
}
@@ -139,6 +111,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
", reblogsCount="+reblogsCount+
", favouritesCount="+favouritesCount+
", repliesCount="+repliesCount+
", editedAt="+editedAt+
", url='"+url+'\''+
", inReplyToId='"+inReplyToId+'\''+
", inReplyToAccountId='"+inReplyToAccountId+'\''+
@@ -147,11 +120,15 @@ public class Status extends BaseModel implements DisplayItemsParent{
", card="+card+
", language='"+language+'\''+
", text='"+text+'\''+
", filtered="+filtered+
", favourited="+favourited+
", reblogged="+reblogged+
", muted="+muted+
", bookmarked="+bookmarked+
", pinned="+pinned+
", spoilerRevealed="+spoilerRevealed+
", hasGapAfter="+hasGapAfter+
", strippedText='"+strippedText+'\''+
'}';
}