diff --git a/business_cases/post_creating/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/client/PostCreatingClientCase.kt b/business_cases/post_creating/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/client/PostCreatingClientCase.kt index 0d2970b7..58204961 100644 --- a/business_cases/post_creating/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/client/PostCreatingClientCase.kt +++ b/business_cases/post_creating/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/client/PostCreatingClientCase.kt @@ -8,14 +8,13 @@ import com.insanusmokrassar.postssystem.ktor.buildStandardUrl import com.insanusmokrassar.postssystem.ktor.client.BodyPair import com.insanusmokrassar.postssystem.ktor.client.unipost import io.ktor.client.HttpClient -import io.ktor.client.request.post class PostCreatingClientCase( private val baseUrl: String, private val client: HttpClient ) : PostCreatingCase { private val realBaseUrl = "$baseUrl/$postCreatingRootRoute" - override suspend fun createPost(postContent: List, triggerId: TriggerId): RegisteredPost? = client.unipost( + override suspend fun createPost(postContent: List, triggerId: TriggerId?): RegisteredPost? = client.unipost( buildStandardUrl(realBaseUrl, postCreatingCreatePostRoute), BodyPair(PostCreatingCreatePostModel.serializer(), PostCreatingCreatePostModel(postContent, triggerId)), RegisteredPost.serializer() diff --git a/business_cases/post_creating/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/BusinessPostCreatingCase.kt b/business_cases/post_creating/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/BusinessPostCreatingCase.kt index 88a90b37..e25d62d6 100644 --- a/business_cases/post_creating/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/BusinessPostCreatingCase.kt +++ b/business_cases/post_creating/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/BusinessPostCreatingCase.kt @@ -13,14 +13,16 @@ class BusinessPostCreatingCase( private val publishingRegistrar: PublishingRegistrar, private val postKeyGenerator: PostKeyGenerator = { _, _ -> uuid4().toString() } ) : PostCreatingCase { - override suspend fun createPost(postContent: List, triggerId: TriggerId): RegisteredPost? { + override suspend fun createPost(postContent: List, triggerId: TriggerId?): RegisteredPost? { val content = postContent.mapNotNull { contentRepo.registerContent(it) } val post = postsRepo.createPost(SimplePost(content.map { it.id })) ?: return null - publishingRegistrar.registerTriggerForPost( - postKeyGenerator(post.id, triggerId), - post.id - ) + triggerId ?.let { + publishingRegistrar.registerTriggerForPost( + postKeyGenerator(post.id, triggerId), + post.id + ) + } return post } diff --git a/business_cases/post_creating/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/PostCreatingCase.kt b/business_cases/post_creating/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/PostCreatingCase.kt index f581f759..123008da 100644 --- a/business_cases/post_creating/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/PostCreatingCase.kt +++ b/business_cases/post_creating/common/src/commonMain/kotlin/com/insanusmokrassar/postssystem/business_cases/post_creating/server/PostCreatingCase.kt @@ -2,19 +2,18 @@ package com.insanusmokrassar.postssystem.business_cases.post_creating.server import com.insanusmokrassar.postssystem.core.content.Content import com.insanusmokrassar.postssystem.core.post.RegisteredPost -import com.insanusmokrassar.postssystem.core.publishing.PublishingKeyReceiver import com.insanusmokrassar.postssystem.core.publishing.TriggerId import kotlinx.serialization.Serializable @Serializable data class PostCreatingCreatePostModel( val postContent: List, - val triggerId: TriggerId + val triggerId: TriggerId? ) interface PostCreatingCase { suspend fun createPost( postContent: List, - triggerId: TriggerId + triggerId: TriggerId? = null ): RegisteredPost? } \ No newline at end of file