mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-23 07:41:25 +00:00
Make posts service request timestamp field (#49)
This commit is contained in:
@@ -61,10 +61,13 @@ func (p *Posts) Save(ctx context.Context, req *proto.SaveRequest, rsp *proto.Sav
|
|||||||
Content: req.Content,
|
Content: req.Content,
|
||||||
Tags: req.Tags,
|
Tags: req.Tags,
|
||||||
Slug: postSlug,
|
Slug: postSlug,
|
||||||
Created: time.Now().Unix(),
|
Created: req.Timestamp,
|
||||||
Metadata: req.Metadata,
|
Metadata: req.Metadata,
|
||||||
Image: req.Image,
|
Image: req.Image,
|
||||||
}
|
}
|
||||||
|
if post.Created == 0 {
|
||||||
|
post.Created = time.Now().Unix()
|
||||||
|
}
|
||||||
err := p.savePost(ctx, nil, post)
|
err := p.savePost(ctx, nil, post)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.InternalServerError("proto.save.post-save", "Failed to save new post: %v", err.Error())
|
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,
|
Slug: oldPost.Slug,
|
||||||
Tags: oldPost.Tags,
|
Tags: oldPost.Tags,
|
||||||
Created: oldPost.Created,
|
Created: oldPost.Created,
|
||||||
Updated: time.Now().Unix(),
|
Updated: req.Timestamp,
|
||||||
Metadata: req.Metadata,
|
Metadata: req.Metadata,
|
||||||
Image: req.Image,
|
Image: req.Image,
|
||||||
}
|
}
|
||||||
|
if post.Created == 0 {
|
||||||
|
post.Created = time.Now().Unix()
|
||||||
|
}
|
||||||
if len(req.Title) > 0 {
|
if len(req.Title) > 0 {
|
||||||
post.Title = req.Title
|
post.Title = req.Title
|
||||||
post.Slug = slug.Make(post.Title)
|
post.Slug = slug.Make(post.Title)
|
||||||
|
|||||||
Reference in New Issue
Block a user