Make posts service request timestamp field (#49)

This commit is contained in:
Janos Dobronszki
2021-01-27 16:46:26 +00:00
committed by GitHub
parent d7d999dad4
commit 78f9ad4422

View File

@@ -61,10 +61,13 @@ func (p *Posts) Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.Sav
Content: req.Content,
Tags: req.Tags,
Slug: postSlug,
Created: time.Now().Unix(),
Created: req.Timestamp,
Metadata: req.Metadata,
Image: req.Image,
}
if post.Created == 0 {
post.Created = time.Now().Unix()
}
err := p.savePost(ctx, nil, post)
if err != nil {
return errors.InternalServerError("proto.save.post-save", "Failed to save new post: %v", err.Error())
@@ -80,10 +83,13 @@ func (p *Posts) Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.Sav
Slug: oldPost.Slug,
Tags: oldPost.Tags,
Created: oldPost.Created,
Updated: time.Now().Unix(),
Updated: req.Timestamp,
Metadata: req.Metadata,
Image: req.Image,
}
if post.Created == 0 {
post.Created = time.Now().Unix()
}
if len(req.Title) > 0 {
post.Title = req.Title
post.Slug = slug.Make(post.Title)