add published posts repo triggering from publishing trigger

This commit is contained in:
InsanusMokrassar 2020-08-15 14:23:30 +06:00
parent 8104678a99
commit 277d978f9e

View File

@ -3,6 +3,7 @@ package com.insanusmokrassar.postssystem.core.publishing
import com.insanusmokrassar.postssystem.core.post.PostId
import com.insanusmokrassar.postssystem.core.post.RegisteredPost
import com.insanusmokrassar.postssystem.core.post.repo.PostsRepo
import com.insanusmokrassar.postssystem.core.post.repo.WritePostsRepo
import com.insanusmokrassar.postssystem.core.publishing.repos.PublishingKeysRepo
import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel
@ -19,6 +20,7 @@ interface PublishingTrigger {
class BusinessPublishingTrigger(
private val postsRepo: PostsRepo,
private val publishedPostsRepo: WritePostsRepo,
private val publishingKeysRepo: PublishingKeysRepo
) : PublishingTrigger {
private val postingTriggeredChannel: BroadcastChannel<RegisteredPost> = BroadcastChannel(Channel.BUFFERED)
@ -30,6 +32,7 @@ class BusinessPublishingTrigger(
return postsRepo.getPostById(postId) ?.let { post ->
if (postsRepo.deletePost(postId)) {
publishedPostsRepo.createPost(post)
postingTriggeredChannel.send(post)
postId
} else {