-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Filter * FilterKeyword * FilterResult * FilterStatus * FeaturedTag
- Loading branch information
Showing
5 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
fediapi/src/commonMain/kotlin/xyz/wingio/fediapi/software/mastodon/model/FeaturedTag.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package xyz.wingio.fediapi.software.mastodon.model | ||
|
||
import kotlinx.datetime.Instant | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import xyz.wingio.fediapi.URL | ||
|
||
/** | ||
* Represents a hashtag that is featured on a profile. | ||
* | ||
* @param id The internal ID of the featured tag in the database. | ||
* @param name The name of the hashtag being featured. | ||
* @param url A link to all statuses by a user that contain this hashtag. | ||
* @param statusesCount The number of authored statuses containing this hashtag. | ||
* @param lastStatusAt The timestamp of the last authored status containing this hashtag. | ||
*/ | ||
@Serializable | ||
public data class FeaturedTag( | ||
val id: String, | ||
val name: String, | ||
val url: URL, | ||
@SerialName("statuses_count") val statusesCount: Int, | ||
@SerialName("last_status_at") val lastStatusAt: Instant | ||
) |
73 changes: 73 additions & 0 deletions
73
fediapi/src/commonMain/kotlin/xyz/wingio/fediapi/software/mastodon/model/filter/Filter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package xyz.wingio.fediapi.software.mastodon.model.filter | ||
|
||
import kotlinx.datetime.Instant | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Represents a user-defined filter for determining which statuses should not be shown to the user. | ||
* | ||
* @param id The ID of the [Filter] in the database. | ||
* @param title A title given by the user to name the filter. | ||
* @param context The contexts in which the filter should be applied. | ||
* @param expiresAt When the filter should no longer be applied. | ||
* @param filterAction The action to be taken when a status matches this filter. | ||
* @param keywords The keywords grouped under this filter. | ||
* @param statuses The statuses grouped under this filter. | ||
*/ | ||
@Serializable | ||
public data class Filter( | ||
val id: String, | ||
val title: String, | ||
val context: Context, | ||
@SerialName("expires_at") val expiresAt: Instant?, | ||
@SerialName("filter_action") val filterAction: FilterAction, | ||
val keywords: List<FilterKeyword>, | ||
val statuses: List<FilterStatus> | ||
) { | ||
|
||
@Serializable | ||
public enum class Context { | ||
/** | ||
* Home timeline and lists | ||
*/ | ||
@SerialName("home") HOME, | ||
|
||
/** | ||
* Notifications timeline | ||
*/ | ||
@SerialName("notifications") NOTIFICATIONS, | ||
|
||
/** | ||
* Public timelines | ||
*/ | ||
@SerialName("public") PUBLIC, | ||
|
||
/** | ||
* Expanded thread of a detailed status | ||
*/ | ||
@SerialName("thread") THREAD, | ||
|
||
/** | ||
* When viewing a profile | ||
*/ | ||
@SerialName("account") ACCOUNT | ||
} | ||
|
||
@Serializable | ||
public enum class FilterAction { | ||
/** | ||
* Show a warning that identifies the matching filter by [title], and | ||
* allow the user to expand the filtered status. | ||
* This is the default (and unknown values should be | ||
* treated as equivalent to [WARN]). | ||
*/ | ||
@SerialName("warn") WARN, | ||
|
||
/** | ||
* Do not show this status if it is received | ||
*/ | ||
@SerialName("hide") HIDE | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
.../src/commonMain/kotlin/xyz/wingio/fediapi/software/mastodon/model/filter/FilterKeyword.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package xyz.wingio.fediapi.software.mastodon.model.filter | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Represents a keyword that, if matched, should cause the filter action to be taken. | ||
* | ||
* @param id The ID of the [FilterKeyword] in the database. | ||
* @param keyword The phrase to be matched against. | ||
* @param wholeWord Should the filter consider word boundaries? See [implementation guidelines for filters](https://docs.joinmastodon.org/api/guidelines/#filters). | ||
*/ | ||
@Serializable | ||
public data class FilterKeyword( | ||
val id: String, | ||
val keyword: String, | ||
@SerialName("whole_word") val wholeWord: Boolean | ||
) |
18 changes: 18 additions & 0 deletions
18
...i/src/commonMain/kotlin/xyz/wingio/fediapi/software/mastodon/model/filter/FilterResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package xyz.wingio.fediapi.software.mastodon.model.filter | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Represents a filter whose keywords matched a given status. | ||
* | ||
* @param filter The filter that was matched. | ||
* @param keywordMatches The keyword within the filter that was matched. | ||
* @param statusMatches The status ID within the filter that was matched. | ||
*/ | ||
@Serializable | ||
public data class FilterResult( | ||
val filter: Filter, | ||
@SerialName("keyword_matches") val keywordMatches: List<String>?, | ||
@SerialName("status_matches") val statusMatches: List<String>? | ||
) |
16 changes: 16 additions & 0 deletions
16
...i/src/commonMain/kotlin/xyz/wingio/fediapi/software/mastodon/model/filter/FilterStatus.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package xyz.wingio.fediapi.software.mastodon.model.filter | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Represents a status ID that, if matched, should cause the filter action to be taken. | ||
* | ||
* @param id The ID of the [FilterStatus] in the database. | ||
* @param statusId The ID of the [Status] that will be filtered. | ||
*/ | ||
@Serializable | ||
public data class FilterStatus( | ||
val id: String, | ||
@SerialName("status_id") val statusId: String | ||
) |