Merge pull request #906 from teviot/teviot-patch-2
Pass-through post creation time when importing posts
Этот коммит содержится в:
@@ -88,6 +88,8 @@ func CreatePost(c *Context, post *model.Post, doUpdateLastViewed bool) (*model.P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post.CreateAt = 0
|
||||||
|
|
||||||
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
||||||
|
|
||||||
post.UserId = c.Session.UserId
|
post.UserId = c.Session.UserId
|
||||||
|
|||||||
@@ -120,7 +120,10 @@ func (o *Post) PreSave() {
|
|||||||
|
|
||||||
o.OriginalId = ""
|
o.OriginalId = ""
|
||||||
|
|
||||||
|
if o.CreateAt == 0 {
|
||||||
o.CreateAt = GetMillis()
|
o.CreateAt = GetMillis()
|
||||||
|
}
|
||||||
|
|
||||||
o.UpdateAt = o.CreateAt
|
o.UpdateAt = o.CreateAt
|
||||||
|
|
||||||
if o.Props == nil {
|
if o.Props == nil {
|
||||||
|
|||||||
@@ -83,5 +83,18 @@ func TestPostIsValid(t *testing.T) {
|
|||||||
func TestPostPreSave(t *testing.T) {
|
func TestPostPreSave(t *testing.T) {
|
||||||
o := Post{Message: "test"}
|
o := Post{Message: "test"}
|
||||||
o.PreSave()
|
o.PreSave()
|
||||||
|
|
||||||
|
if o.CreateAt == 0 {
|
||||||
|
t.Fatal("should be set")
|
||||||
|
}
|
||||||
|
|
||||||
|
past := GetMillis() - 1
|
||||||
|
o = Post{Message: "test", CreateAt: past}
|
||||||
|
o.PreSave()
|
||||||
|
|
||||||
|
if o.CreateAt > past {
|
||||||
|
t.Fatal("should not be updated")
|
||||||
|
}
|
||||||
|
|
||||||
o.Etag()
|
o.Etag()
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user