Skip to content

Commit

Permalink
feat(Export): allow exporting with sensitive data
Browse files Browse the repository at this point in the history
Secondary POST route to stay backwards-compatible and allow transferring a body.
  • Loading branch information
SIMULATAN committed Feb 9, 2025
1 parent f46abf0 commit be43361
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package me.snoty.backend.server.resources.wiring.flow

import io.ktor.http.*
import io.ktor.server.request.receive
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import org.koin.ktor.ext.get
import kotlinx.serialization.Serializable
import me.snoty.backend.utils.getUser
import me.snoty.backend.wiring.flow.export.FlowExportService
import me.snoty.backend.wiring.flow.import.FlowImportService
import me.snoty.backend.wiring.flow.import.ImportFlow
import org.koin.ktor.ext.get

fun Route.flowExportImportResource() {
val exportService: FlowExportService = get()
Expand All @@ -27,6 +28,21 @@ fun Route.flowExportImportResource() {
)
call.respond(exported)
}

post("export") {
@Serializable
data class ExportOptions(
val withSensitiveData: Boolean = false,
)

val options: ExportOptions? = call.receiveNullable()
val flow = getPersonalFlowOrNull() ?: return@post

val censor = options?.withSensitiveData?.let { !it } ?: true
val exported = exportService.export(flow._id, censor = censor)

call.respond(exported)
}
}

post("import") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package me.snoty.integration.common.wiring.flow.export
package me.snoty.backend.wiring.flow.export

import me.snoty.backend.utils.bson.encode
import me.snoty.backend.utils.bson.setRecursively
import me.snoty.backend.integration.config.flow.NodeId
import me.snoty.backend.wiring.flow.export.CensoredField
import me.snoty.backend.wiring.flow.export.ExportedFlow
import me.snoty.backend.wiring.flow.export.ExportedNode
import me.snoty.backend.wiring.flow.export.FlowExportService
import me.snoty.backend.wiring.flow.export.hash
import me.snoty.integration.common.model.metadata.NodeField
import me.snoty.integration.common.model.metadata.NodeFieldDetails
import me.snoty.integration.common.model.metadata.ObjectSchema
Expand Down

0 comments on commit be43361

Please sign in to comment.