mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-22 23:35:26 +00:00
publish when a new post is created
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/micro/micro/v3/service/errors"
|
"github.com/micro/micro/v3/service/errors"
|
||||||
"github.com/micro/micro/v3/service/logger"
|
"github.com/micro/micro/v3/service/logger"
|
||||||
"github.com/micro/micro/v3/service/model"
|
"github.com/micro/micro/v3/service/model"
|
||||||
|
"github.com/micro/micro/v3/service"
|
||||||
|
|
||||||
"github.com/gosimple/slug"
|
"github.com/gosimple/slug"
|
||||||
proto "github.com/micro/services/posts/proto"
|
proto "github.com/micro/services/posts/proto"
|
||||||
@@ -130,6 +131,9 @@ func (p *Posts) savePost(ctx context.Context, oldPost, post *proto.Post) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if oldPost == nil {
|
if oldPost == nil {
|
||||||
|
// publish the post as an event
|
||||||
|
service.NewEvent("posts").Publish(ctx, post)
|
||||||
|
|
||||||
for _, tagName := range post.Tags {
|
for _, tagName := range post.Tags {
|
||||||
_, err := p.Tags.Add(ctx, &tags.AddRequest{
|
_, err := p.Tags.Add(ctx, &tags.AddRequest{
|
||||||
ResourceID: post.Id,
|
ResourceID: post.Id,
|
||||||
|
|||||||
Reference in New Issue
Block a user