fully rewrite content
This commit is contained in:
business_cases/post_creating/common/src/commonMain/kotlin/dev/inmo/postssystem/business_cases/post_creating/server
core
api
build.gradle
src
commonMain
kotlin
dev
inmo
postssystem
commonTest
kotlin
dev
inmo
postssystem
core
jvmMain
kotlin
dev
inmo
postssystem
core
content
api
business
content_adapters
binary
exposed
src
jvmMain
kotlin
dev
inmo
jvmTest
kotlin
dev
inmo
postssystem
core
ktor
client
src
commonMain
kotlin
dev
inmo
postssystem
core
server
src
jvmMain
kotlin
dev
inmo
postssystem
@ -7,25 +7,25 @@ import dev.inmo.postssystem.core.post.*
|
||||
import dev.inmo.postssystem.core.post.repo.PostsRepo
|
||||
import dev.inmo.postssystem.core.publishing.*
|
||||
|
||||
class BusinessPostCreatingCase(
|
||||
private val postsRepo: PostsRepo,
|
||||
private val contentRepo: ContentRepo,
|
||||
private val publishingRegistrar: PublishingRegistrar,
|
||||
private val postKeyGenerator: PostKeyGenerator = { _, _ -> uuid4().toString() },
|
||||
private val publishingKeyReceiverGetter: PublishingKeyReceiverGetter
|
||||
) : PostCreatingCase {
|
||||
override suspend fun createPost(postContent: List<Content>, triggerId: TriggerId?): RegisteredPost? {
|
||||
val content = postContent.mapNotNull { contentRepo.registerContent(it) }
|
||||
val post = postsRepo.createPost(SimplePost(content.map { it.id })) ?: return null
|
||||
|
||||
triggerId ?.let {
|
||||
val key = postKeyGenerator(post.id, triggerId)
|
||||
|
||||
if (publishingRegistrar.registerTriggerForPost(key, post.id)) {
|
||||
publishingKeyReceiverGetter(it) ?.acceptKey(post.id, key)
|
||||
}
|
||||
}
|
||||
|
||||
return post
|
||||
}
|
||||
}
|
||||
//class BusinessPostCreatingCase(
|
||||
// private val postsRepo: PostsRepo,
|
||||
// private val contentRepo: ContentRepo,
|
||||
// private val publishingRegistrar: PublishingRegistrar,
|
||||
// private val postKeyGenerator: PostKeyGenerator = { _, _ -> uuid4().toString() },
|
||||
// private val publishingKeyReceiverGetter: PublishingKeyReceiverGetter
|
||||
//) : PostCreatingCase {
|
||||
// override suspend fun createPost(postContent: List<Content>, triggerId: TriggerId?): RegisteredPost? {
|
||||
// val content = postContent.mapNotNull { contentRepo.registerContent(it) }
|
||||
// val post = postsRepo.createPost(SimplePost(content.map { it.id })) ?: return null
|
||||
//
|
||||
// triggerId ?.let {
|
||||
// val key = postKeyGenerator(post.id, triggerId)
|
||||
//
|
||||
// if (publishingRegistrar.registerTriggerForPost(key, post.id)) {
|
||||
// publishingKeyReceiverGetter(it) ?.acceptKey(post.id, key)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return post
|
||||
// }
|
||||
//}
|
||||
|
Reference in New Issue
Block a user