From e93b80531e16d5fe47bca5b57f882a94e1dc58b3 Mon Sep 17 00:00:00 2001 From: Siddhartha Basu Date: Fri, 3 Nov 2023 13:01:24 -0500 Subject: [PATCH] feat(service.go): add publishing of content creation and update events The `StoreContent` and `UpdateContent` methods in the `ContentService` now publish events when content is created or updated. This allows other parts of the application to be notified of these events and take appropriate actions. --- internal/app/service/service.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/app/service/service.go b/internal/app/service/service.go index 848e2d9..e847a7c 100644 --- a/internal/app/service/service.go +++ b/internal/app/service/service.go @@ -140,8 +140,11 @@ func (srv *ContentService) StoreContent( return ctnt, aphgrpc.HandleGetError(ctx, err) } cid, _ := strconv.ParseInt(mcont.Key, 10, 64) + ctnt = srv.buildContent(cid, mcont) + //nolint:errcheck + srv.publisher.Publish(srv.Topics["contentCreate"], ctnt) - return srv.buildContent(cid, mcont), nil + return ctnt, nil } func (srv *ContentService) UpdateContent( @@ -157,8 +160,11 @@ func (srv *ContentService) UpdateContent( return ctnt, aphgrpc.HandleGetError(ctx, err) } cid, _ := strconv.ParseInt(mcont.Key, 10, 64) + ctnt = srv.buildContent(cid, mcont) + //nolint:errcheck + srv.publisher.Publish(srv.Topics["contentUpdate"], ctnt) - return srv.buildContent(cid, mcont), nil + return ctnt, nil } func (srv *ContentService) DeleteContent(