Commit Diff


commit - 635ade7fa06283937355616d5bc0d2d38e879043
commit + cc18f53a514e6a399af0836b9ea3a59539228f52
blob - 5cd7fe34aff26c2b4021d73e29266fc0377733e7
blob + 3baacdcfc27eb099557777dbe1a5c6af3cff4e1b
--- lemmy.go
+++ lemmy.go
@@ -51,10 +51,15 @@ func (p *Post) Size() int64 {
 	return int64(len(p.Body))
 }
 
-func (p *Post) Mode() fs.FileMode  { return fs.ModeDir | 0o0555 }
-func (p *Post) ModTime() time.Time { return p.Published }
-func (p *Post) IsDir() bool        { return p.Mode().IsDir() }
-func (p *Post) Sys() interface{}   { return nil }
+func (p *Post) Mode() fs.FileMode { return fs.ModeDir | 0o0555 }
+func (p *Post) IsDir() bool       { return p.Mode().IsDir() }
+func (p *Post) Sys() interface{}  { return nil }
+func (p *Post) ModTime() time.Time {
+	if p.Updated.IsZero() {
+		return p.Published
+	}
+	return p.Updated
+}
 
 type Comment struct {
 	ID     int
@@ -65,17 +70,23 @@ type Comment struct {
 	Content     string
 	CreatorID   int `json:"creator_id"`
 	Published   time.Time
+	Updated     time.Time
 	ActivityURL string `json:"ap_id"`
 	Creator     Person `json:"-"`
 }
 
 func (c *Comment) Name() string { return strconv.Itoa(c.ID) }
 
-func (c *Comment) Size() int64        { return 0 }
-func (c *Comment) Mode() fs.FileMode  { return 0444 }
-func (c *Comment) ModTime() time.Time { return time.Unix(0, 0) } // TODO c.Updated
-func (c *Comment) IsDir() bool        { return c.Mode().IsDir() }
-func (c *Comment) Sys() interface{}   { return nil }
+func (c *Comment) Size() int64       { return 0 }
+func (c *Comment) Mode() fs.FileMode { return 0444 }
+func (c *Comment) ModTime() time.Time {
+	if c.Updated.IsZero() {
+		return c.Published
+	}
+	return c.Updated
+}
+func (c *Comment) IsDir() bool      { return c.Mode().IsDir() }
+func (c *Comment) Sys() interface{} { return nil }
 
 // ParseCommentPath returns the comment IDs referenced by a Comment.
 func ParseCommentPath(s string) []int {