mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-14 20:14:47 +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,
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user