From 43a3b62d5dc46618de05cc8de4050e82acc563ba Mon Sep 17 00:00:00 2001 From: cif Date: Fri, 4 Oct 2024 21:41:12 -0400 Subject: [PATCH] feat: just return the basic log, no data anyhow --- src/main/kotlin/com/stabledata/dao/LogsDao.kt | 2 ++ .../stabledata/endpoint/SchemaCreateCollectionRoute.kt | 7 +------ .../stabledata/endpoint/SchemaDeleteCollectionRoute.kt | 7 +------ .../stabledata/endpoint/SchemaUpdateCollectionRoute.kt | 7 +------ .../com/stabledata/endpoint/io/SchemaEndpointsIO.kt | 9 +-------- 5 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/main/kotlin/com/stabledata/dao/LogsDao.kt b/src/main/kotlin/com/stabledata/dao/LogsDao.kt index 5292b07..3676372 100644 --- a/src/main/kotlin/com/stabledata/dao/LogsDao.kt +++ b/src/main/kotlin/com/stabledata/dao/LogsDao.kt @@ -1,5 +1,6 @@ package com.stabledata.dao +import kotlinx.serialization.Serializable import org.jetbrains.exposed.sql.Table import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.select @@ -9,6 +10,7 @@ import java.util.* /** * LogEntry records every single event that is synchronized across team workspaces in Stable */ +@Serializable data class LogEntry ( val id: String, val teamId: String, diff --git a/src/main/kotlin/com/stabledata/endpoint/SchemaCreateCollectionRoute.kt b/src/main/kotlin/com/stabledata/endpoint/SchemaCreateCollectionRoute.kt index 0fd9e29..e6ec01d 100644 --- a/src/main/kotlin/com/stabledata/endpoint/SchemaCreateCollectionRoute.kt +++ b/src/main/kotlin/com/stabledata/endpoint/SchemaCreateCollectionRoute.kt @@ -5,7 +5,6 @@ import com.stabledata.DatabaseOperations import com.stabledata.dao.CollectionsTable import com.stabledata.dao.LogsTable import com.stabledata.endpoint.io.CollectionRequest -import com.stabledata.endpoint.io.CollectionsResponse import com.stabledata.plugins.JWT_NAME import io.github.oshai.kotlinlogging.KotlinLogging import io.ktor.http.* @@ -57,11 +56,7 @@ fun Application.configureCreateCollectionRoute() { return@post call.respond( HttpStatusCode.OK, - CollectionsResponse( - id = collection.id, - eventId = envelope.eventId, - confirmedAt = finalLogEntry.confirmedAt - ) + finalLogEntry ) } catch (e: ExposedSQLException) { diff --git a/src/main/kotlin/com/stabledata/endpoint/SchemaDeleteCollectionRoute.kt b/src/main/kotlin/com/stabledata/endpoint/SchemaDeleteCollectionRoute.kt index 2a54e0b..8a6fb7c 100644 --- a/src/main/kotlin/com/stabledata/endpoint/SchemaDeleteCollectionRoute.kt +++ b/src/main/kotlin/com/stabledata/endpoint/SchemaDeleteCollectionRoute.kt @@ -6,7 +6,6 @@ import com.stabledata.dao.CollectionDeleteFailedException import com.stabledata.dao.CollectionsTable import com.stabledata.dao.LogsTable import com.stabledata.endpoint.io.CollectionRequest -import com.stabledata.endpoint.io.CollectionsResponse import com.stabledata.plugins.JWT_NAME import io.github.oshai.kotlinlogging.KotlinLogging import io.ktor.http.* @@ -47,11 +46,7 @@ fun Application.configureDeleteCollectionRoute() { return@post call.respond( HttpStatusCode.OK, - CollectionsResponse( - id = collection.id, - eventId = envelope.eventId, - confirmedAt = finalLogEntry.confirmedAt - ) + finalLogEntry ) } catch (e: CollectionDeleteFailedException) { logger.error { "Delete collection transaction failed at delete query: ${e.localizedMessage}" } diff --git a/src/main/kotlin/com/stabledata/endpoint/SchemaUpdateCollectionRoute.kt b/src/main/kotlin/com/stabledata/endpoint/SchemaUpdateCollectionRoute.kt index 909609b..67aae95 100644 --- a/src/main/kotlin/com/stabledata/endpoint/SchemaUpdateCollectionRoute.kt +++ b/src/main/kotlin/com/stabledata/endpoint/SchemaUpdateCollectionRoute.kt @@ -5,7 +5,6 @@ import com.stabledata.dao.CollectionUpdateFailedException import com.stabledata.dao.CollectionsTable import com.stabledata.dao.LogsTable import com.stabledata.endpoint.io.CollectionRequest -import com.stabledata.endpoint.io.CollectionsResponse import com.stabledata.plugins.JWT_NAME import io.github.oshai.kotlinlogging.KotlinLogging import io.ktor.http.* @@ -46,11 +45,7 @@ fun Application.configureUpdateCollectionRoute() { return@post call.respond( HttpStatusCode.OK, - CollectionsResponse( - id = collection.id, - eventId = envelope.eventId, - confirmedAt = finalLogEntry.confirmedAt - ) + finalLogEntry ) } catch (e: CollectionUpdateFailedException) { logger.error { "Update collection transaction failed at update query: ${e.localizedMessage}" } diff --git a/src/main/kotlin/com/stabledata/endpoint/io/SchemaEndpointsIO.kt b/src/main/kotlin/com/stabledata/endpoint/io/SchemaEndpointsIO.kt index c2fa683..d2326e9 100644 --- a/src/main/kotlin/com/stabledata/endpoint/io/SchemaEndpointsIO.kt +++ b/src/main/kotlin/com/stabledata/endpoint/io/SchemaEndpointsIO.kt @@ -23,11 +23,4 @@ data class CollectionRequest ( return jsonParser.decodeFromString(json) } } -} - -@Serializable -data class CollectionsResponse ( - val id: String, - val eventId: String, - val confirmedAt: Long? -) \ No newline at end of file +} \ No newline at end of file