Respect filter expiration date when applying filters (#2661)
* Respect filter expiration date when applying filters. #2578 * Fix typing for filter `expires_in` api points
This commit is contained in:
parent
be4645ec38
commit
b21def5041
5 changed files with 45 additions and 7 deletions
|
|
@ -3,6 +3,7 @@ package com.keylesspalace.tusky.network
|
|||
import android.text.TextUtils
|
||||
import com.keylesspalace.tusky.entity.Filter
|
||||
import com.keylesspalace.tusky.entity.Status
|
||||
import java.util.Date
|
||||
import java.util.regex.Pattern
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -54,7 +55,9 @@ class FilterModel @Inject constructor() {
|
|||
|
||||
private fun makeFilter(filters: List<Filter>): Pattern? {
|
||||
if (filters.isEmpty()) return null
|
||||
val tokens = filters.map { filterToRegexToken(it) }
|
||||
val tokens = filters
|
||||
.filter { it.expiresAt?.before(Date()) != true }
|
||||
.map { filterToRegexToken(it) }
|
||||
|
||||
return Pattern.compile(TextUtils.join("|", tokens), Pattern.CASE_INSENSITIVE)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -536,7 +536,7 @@ interface MastodonApi {
|
|||
@Field("context[]") context: List<String>,
|
||||
@Field("irreversible") irreversible: Boolean?,
|
||||
@Field("whole_word") wholeWord: Boolean?,
|
||||
@Field("expires_in") expiresIn: String?
|
||||
@Field("expires_in") expiresIn: Int?
|
||||
): Call<Filter>
|
||||
|
||||
@FormUrlEncoded
|
||||
|
|
@ -547,7 +547,7 @@ interface MastodonApi {
|
|||
@Field("context[]") context: List<String>,
|
||||
@Field("irreversible") irreversible: Boolean?,
|
||||
@Field("whole_word") wholeWord: Boolean?,
|
||||
@Field("expires_in") expiresIn: String?
|
||||
@Field("expires_in") expiresIn: Int?
|
||||
): Call<Filter>
|
||||
|
||||
@DELETE("api/v1/filters/{id}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue