Skip to content
Closed
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
1 change: 1 addition & 0 deletions services/flipcash/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
alias(libs.plugins.flipcash.android.library)
alias(libs.plugins.flipcash.android.ed25519.shadow)
id("com.google.devtools.ksp")
id("org.jetbrains.kotlin.plugin.parcelize")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.flipcash.services.internal.annotations.FlipcashManagedChannel
import com.flipcash.services.internal.network.extensions.asCountryCode
import com.flipcash.services.internal.network.extensions.asPublicKey
import com.flipcash.services.internal.network.extensions.asUserId
import com.flipcash.services.internal.network.extensions.authenticate
import com.flipcash.services.internal.network.extensions.buildAuthenticated
import com.flipcash.services.internal.network.extensions.sign
import com.getcode.ed25519.Ed25519.KeyPair
import com.getcode.opencode.internal.network.core.GrpcApi
Expand Down Expand Up @@ -53,8 +53,7 @@ internal class AccountApi @Inject constructor(
suspend fun login(owner: KeyPair): RpcAccountService.LoginResponse {
val request = RpcAccountService.LoginRequest.newBuilder()
.setTimestamp(Timestamp.newBuilder().setSeconds(System.currentTimeMillis() / 1_000))
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -75,8 +74,7 @@ internal class AccountApi @Inject constructor(
.setUserId(userId.asUserId())
.setPlatform(Common.Platform.GOOGLE)
.setCountryCode(countryCode.asCountryCode())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.codeinc.flipcash.gen.activity.v1.Model
import com.codeinc.flipcash.gen.activity.v1.validate
import com.flipcash.services.internal.annotations.FlipcashManagedChannel
import com.flipcash.services.internal.network.extensions.asQueryOptions
import com.flipcash.services.internal.network.extensions.authenticate
import com.flipcash.services.internal.network.extensions.buildAuthenticated
import com.flipcash.services.internal.network.extensions.toNotificationIds
import com.flipcash.services.models.ActivityFeedType
import com.flipcash.services.models.QueryOptions
Expand Down Expand Up @@ -44,8 +44,7 @@ internal class ActivityFeedApi @Inject constructor(
val request = ActivityFeedService.GetLatestNotificationsRequest.newBuilder()
.setType(Model.ActivityFeedType.forNumber(type.ordinal))
.setMaxItems(maxItems)
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -69,8 +68,7 @@ internal class ActivityFeedApi @Inject constructor(
val request = ActivityFeedService.GetPagedNotificationsRequest.newBuilder()
.setType(Model.ActivityFeedType.forNumber(type.ordinal))
.setQueryOptions(queryOptions.asQueryOptions())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -92,9 +90,7 @@ internal class ActivityFeedApi @Inject constructor(
val request = ActivityFeedService.GetBatchNotificationsRequest.newBuilder()
.apply {
addAllIds(ids.toNotificationIds())
}.apply {
setAuth(authenticate(owner))
}.build()
}.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.flipcash.services.internal.annotations.FlipcashManagedChannel
import com.flipcash.services.internal.network.extensions.asChatId
import com.flipcash.services.internal.network.extensions.asUserId
import com.flipcash.services.internal.network.extensions.authenticate
import com.flipcash.services.internal.network.extensions.buildAuthenticated
import com.flipcash.services.models.chat.BlobAccessContext
import com.flipcash.services.models.chat.BlobId
import com.getcode.ed25519.Ed25519
Expand Down Expand Up @@ -38,8 +39,7 @@ internal class BlobStorageApi @Inject constructor(

suspend fun getUploadPolicy(owner: Ed25519.KeyPair): RpcBlobStorageService.GetUploadPolicyResponse {
val request = RpcBlobStorageService.GetUploadPolicyRequest.newBuilder()
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -56,8 +56,7 @@ internal class BlobStorageApi @Inject constructor(
val request = RpcBlobStorageService.InitiateExternalUploadRequest.newBuilder()
.setMimeType(mimeType)
.setSizeBytes(sizeBytes)
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -72,8 +71,7 @@ internal class BlobStorageApi @Inject constructor(
): RpcBlobStorageService.CompleteExternalUploadResponse {
val request = RpcBlobStorageService.CompleteExternalUploadRequest.newBuilder()
.setBlobId(blobId.toProto())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.codeinc.flipcash.gen.blocklist.v1.validate
import com.flipcash.services.internal.annotations.FlipcashManagedChannel
import com.flipcash.services.internal.network.extensions.asQueryOptions
import com.flipcash.services.internal.network.extensions.asUserId
import com.flipcash.services.internal.network.extensions.authenticate
import com.flipcash.services.internal.network.extensions.buildAuthenticated
import com.flipcash.services.models.QueryOptions
import com.getcode.ed25519.Ed25519.KeyPair
import com.getcode.opencode.internal.network.core.GrpcApi
Expand Down Expand Up @@ -34,8 +34,7 @@ internal class BlocklistApi @Inject constructor(
suspend fun blockUser(userId: ID, owner: KeyPair): BlocklistService.BlockUserResponse {
val request = BlocklistService.BlockUserRequest.newBuilder()
.setUserId(userId.asUserId())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -51,8 +50,7 @@ internal class BlocklistApi @Inject constructor(
suspend fun unblockUser(userId: ID, owner: KeyPair): BlocklistService.UnblockUserResponse {
val request = BlocklistService.UnblockUserRequest.newBuilder()
.setUserId(userId.asUserId())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -67,8 +65,7 @@ internal class BlocklistApi @Inject constructor(
suspend fun isBlocked(userId: ID, owner: KeyPair): BlocklistService.IsBlockedResponse {
val request = BlocklistService.IsBlockedRequest.newBuilder()
.setUserId(userId.asUserId())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -87,8 +84,7 @@ internal class BlocklistApi @Inject constructor(
): BlocklistService.GetBlocklistResponse {
val request = BlocklistService.GetBlocklistRequest.newBuilder()
.setQueryOptions(queryOptions.asQueryOptions())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.flipcash.services.internal.network.extensions.asProtoMuteState
import com.flipcash.services.internal.network.extensions.asProtoRules
import com.flipcash.services.internal.network.extensions.asQueryOptions
import com.flipcash.services.internal.network.extensions.asViewMode
import com.flipcash.services.internal.network.extensions.authenticate
import com.flipcash.services.internal.network.extensions.buildAuthenticated
import com.flipcash.services.models.QueryOptions
import com.flipcash.services.models.chat.ChatId
import com.flipcash.services.models.chat.ChatType
Expand Down Expand Up @@ -46,8 +46,7 @@ internal class ChatApi @Inject constructor(
val request = RpcChatService.GetChatRequest.newBuilder()
.setChatId(chatId.asChatId())
.setViewMode(viewMode.asViewMode())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -64,8 +63,7 @@ internal class ChatApi @Inject constructor(
val request = RpcChatService.GetDmChatFeedRequest.newBuilder()
.setQueryOptions(queryOptions.asQueryOptions())
.setDmChatType(chatType.asProtoChatType())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -80,8 +78,7 @@ internal class ChatApi @Inject constructor(
): RpcChatService.GetGroupChatFeedResponse {
val request = RpcChatService.GetGroupChatFeedRequest.newBuilder()
.setQueryOptions(queryOptions.asQueryOptions())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand Down Expand Up @@ -119,8 +116,7 @@ internal class ChatApi @Inject constructor(

val request = requestBuilder
.setIdempotencyKey(idempotencyKey.asProtoIdempotencyKey())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -135,8 +131,7 @@ internal class ChatApi @Inject constructor(
): RpcChatService.JoinChatResponse {
val request = RpcChatService.JoinChatRequest.newBuilder()
.setChatId(chatId.asChatId())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -151,8 +146,7 @@ internal class ChatApi @Inject constructor(
): RpcChatService.LeaveChatResponse {
val request = RpcChatService.LeaveChatRequest.newBuilder()
.setChatId(chatId.asChatId())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -169,8 +163,7 @@ internal class ChatApi @Inject constructor(
val request = RpcChatService.MuteChatRequest.newBuilder()
.setChatId(chatId.asChatId())
.setMute(mute.asProtoMuteState())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand All @@ -185,8 +178,7 @@ internal class ChatApi @Inject constructor(
): RpcChatService.UnmuteChatResponse {
val request = RpcChatService.UnmuteChatRequest.newBuilder()
.setChatId(chatId.asChatId())
.apply { setAuth(authenticate(owner)) }
.build()
.buildAuthenticated(owner) { setAuth(it) }

request.validate().orThrow()

Expand Down
Loading
Loading