make triggerId optinal in create post case
This commit is contained in:
@@ -13,14 +13,16 @@ class BusinessPostCreatingCase(
|
||||
private val publishingRegistrar: PublishingRegistrar,
|
||||
private val postKeyGenerator: PostKeyGenerator = { _, _ -> uuid4().toString() }
|
||||
) : PostCreatingCase {
|
||||
override suspend fun createPost(postContent: List<Content>, triggerId: TriggerId): RegisteredPost? {
|
||||
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
|
||||
|
||||
publishingRegistrar.registerTriggerForPost(
|
||||
postKeyGenerator(post.id, triggerId),
|
||||
post.id
|
||||
)
|
||||
triggerId ?.let {
|
||||
publishingRegistrar.registerTriggerForPost(
|
||||
postKeyGenerator(post.id, triggerId),
|
||||
post.id
|
||||
)
|
||||
}
|
||||
|
||||
return post
|
||||
}
|
||||
|
@@ -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<Content>,
|
||||
val triggerId: TriggerId
|
||||
val triggerId: TriggerId?
|
||||
)
|
||||
|
||||
interface PostCreatingCase {
|
||||
suspend fun createPost(
|
||||
postContent: List<Content>,
|
||||
triggerId: TriggerId
|
||||
triggerId: TriggerId? = null
|
||||
): RegisteredPost?
|
||||
}
|
Reference in New Issue
Block a user