From 80ecacdc5d2a29b8ac6c72a4db75c1bc3c511b58 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Tue, 2 Mar 2021 09:22:21 +0000 Subject: [PATCH] only publish if no post existed before --- posts/handler/posts.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/posts/handler/posts.go b/posts/handler/posts.go index d3c65b8..865fb5b 100644 --- a/posts/handler/posts.go +++ b/posts/handler/posts.go @@ -131,11 +131,11 @@ func (p *Posts) savePost(ctx context.Context, oldPost, post *proto.Post) error { return err } - // publish the post as an event - logger.Infof("Publishing post: '%v'", post.Title) - service.NewEvent("posts").Publish(ctx, post) - if oldPost == nil { + // publish the post as an event + logger.Infof("Publishing post: '%v'", post.Title) + service.NewEvent("posts").Publish(ctx, post) + for _, tagName := range post.Tags { _, err := p.Tags.Add(ctx, &tags.AddRequest{ ResourceID: post.Id,