Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ package io.getstream.feeds.android.client.api.state.query

import io.getstream.android.core.api.filter.Filter
import io.getstream.android.core.api.filter.FilterField
import io.getstream.android.core.api.model.location.BoundingBox
import io.getstream.android.core.api.model.location.CircularRegion
import io.getstream.android.core.api.sort.Sort
import io.getstream.android.core.api.sort.SortDirection
import io.getstream.android.core.api.sort.SortField
import io.getstream.feeds.android.client.api.model.ActivityData
import io.getstream.feeds.android.client.internal.model.toCoordinate
import io.getstream.feeds.android.client.internal.state.query.unsupportedLocalValue

/**
* A query for retrieving activities with filtering, sorting, and pagination options.
Expand Down Expand Up @@ -84,6 +88,14 @@ public data class ActivitiesFilterField(
*/
public val id: ActivitiesFilterField = ActivitiesFilterField("id", ActivityData::id)

/**
* Filter by the feed ID(s) that the activity belongs to.
*
* Supported operators: `equal`, `in`
*/
public val feed: ActivitiesFilterField =
ActivitiesFilterField("feed", unsupportedLocalValue)

/**
* Filter by activity filter tags.
*
Expand Down Expand Up @@ -120,7 +132,7 @@ public data class ActivitiesFilterField(
*
* Supported operators: `equal`, `in`
*/
public val type: ActivitiesFilterField =
public val activityType: ActivitiesFilterField =
ActivitiesFilterField("activity_type", ActivityData::type)

/**
Expand All @@ -146,6 +158,28 @@ public data class ActivitiesFilterField(
*/
public val interestTags: ActivitiesFilterField =
ActivitiesFilterField("interest_tags", ActivityData::interestTags)

/**
* Filter by proximity to a location.
*
* Requires matching against [CircularRegion] or a [Map] with `lat` (latitude), `lng`
* (longitude), and `distance` (in kilometers).
*
* Supported operators: `equal`
*/
public val near: ActivitiesFilterField =
ActivitiesFilterField("near") { it.location?.toCoordinate() }

/**
* Filter by activities within a bounding box.
*
* Can be matched against [BoundingBox] or a [Map] with `ne_lat`, `ne_lng` (northeast
* corner), `sw_lat`, `sw_lng` (southwest corner).
*
* Supported operators: `equal`
*/
public val withinBounds: ActivitiesFilterField =
ActivitiesFilterField("within_bounds") { it.location?.toCoordinate() }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public sealed interface ModerationConfigsSortField : SortField<ModerationConfigD
*/
public data object Key :
ModerationConfigsSortField,
SortField<ModerationConfigData> by SortField.create("id", ModerationConfigData::key)
SortField<ModerationConfigData> by SortField.create("key", ModerationConfigData::key)

/**
* Sort by the creation timestamp of the configuration. This field allows sorting configurations
Expand All @@ -140,6 +140,14 @@ public sealed interface ModerationConfigsSortField : SortField<ModerationConfigD
ModerationConfigData::createdAt,
)

/**
* Sort by the team associated with the configuration. This field allows sorting configurations
* by team (alphabetical order).
*/
public data object Team :
ModerationConfigsSortField,
SortField<ModerationConfigData> by SortField.create("team", ModerationConfigData::team)

/**
* Sort by the last update timestamp of the configuration. This field allows sorting
* configurations by when they were last updated (newest/oldest first).
Expand All @@ -151,5 +159,3 @@ public sealed interface ModerationConfigsSortField : SortField<ModerationConfigD
ModerationConfigData::updatedAt,
)
}

/** Converts this [ModerationConfigsQuery] to a [QueryModerationConfigsRequest]. */
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.getstream.feeds.android.client.internal.model

import io.getstream.android.core.api.model.location.LocationCoordinate
import io.getstream.feeds.android.client.api.model.ActivityData
import io.getstream.feeds.android.client.api.model.ActivityDataVisibility
import io.getstream.feeds.android.client.api.model.BookmarkData
Expand All @@ -24,6 +25,7 @@ import io.getstream.feeds.android.client.api.model.FeedId
import io.getstream.feeds.android.client.api.model.FeedsReactionData
import io.getstream.feeds.android.client.internal.utils.updateIf
import io.getstream.feeds.android.client.internal.utils.upsert
import io.getstream.feeds.android.network.models.ActivityLocation
import io.getstream.feeds.android.network.models.ActivityResponse
import kotlin.math.max

Expand Down Expand Up @@ -267,3 +269,5 @@ internal fun ActivityData.updateFeedOwnValues(values: FeedOwnValues): ActivityDa
ownMembership = values.membership,
)
)

internal fun ActivityLocation.toCoordinate() = LocationCoordinate(lat.toDouble(), lng.toDouble())
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal class ActivityListEventHandlerTest(
override val handler = ActivityListEventHandler(testFilter, userId, state)

companion object {
private val testFilter = ActivitiesFilterField.type.equal("post")
private val testFilter = ActivitiesFilterField.activityType.equal("post")
private const val userId = "user-1"
private val fidScope = FidScope.of("feed-1")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ internal class FeedEventHandlerTest(
private val fidScope = FidScope.of(fid)
private val otherFidScope = FidScope.of("group:different")
private val query =
FeedQuery(fid = fid, activityFilter = ActivitiesFilterField.type.equal("post"))
FeedQuery(fid = fid, activityFilter = ActivitiesFilterField.activityType.equal("post"))
private const val userId = "user-1"
private const val activityId = "activity-1"
private val activity = activityData(activityId, type = "post")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal class OnNewActivityDefaultTest(
private val feedId = FeedId("group", "feed-1")
private const val currentUserId = "current-user"
private const val otherUserId = "other-user"
private val filter = ActivitiesFilterField.type.equal("post")
private val filter = ActivitiesFilterField.activityType.equal("post")
private val matchingActivity = activityData(type = "post", user = userData(currentUserId))
private val nonMatchingUserActivity =
activityData(type = "post", user = userData(otherUserId))
Expand Down