- commit
- 1a0e40b
- parent
- 0c6b9a9
- author
- Antonio Mika
- date
- 2023-11-10 19:09:55 +0000 UTC
Properly update post time when updated
2 files changed,
+5,
-0
+3,
-0
1@@ -5,6 +5,7 @@ import (
2 "errors"
3 "fmt"
4 "strings"
5+ "time"
6
7 "github.com/charmbracelet/ssh"
8 "github.com/picosh/pico/db"
9@@ -199,6 +200,7 @@ func (h *UploadImgHandler) writeImg(s ssh.Session, data *PostMetaData) error {
10 }
11
12 h.Cfg.Logger.Infof("(%s) found, updating record", data.Filename)
13+ now := time.Now()
14 updatePost := db.Post{
15 ID: data.Cur.ID,
16
17@@ -211,6 +213,7 @@ func (h *UploadImgHandler) writeImg(s ssh.Session, data *PostMetaData) error {
18 Text: data.Text,
19 Title: data.Title,
20 Hidden: data.Hidden,
21+ UpdatedAt: &now,
22 }
23 _, err = h.DBPool.UpdatePost(&updatePost)
24 if err != nil {
+2,
-0
1@@ -302,6 +302,7 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string,
2 }
3
4 logger.Infof("(%s) found, updating record", filename)
5+ now := time.Now()
6 updatePost := db.Post{
7 ID: post.ID,
8
9@@ -314,6 +315,7 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string,
10 Text: metadata.Text,
11 Title: metadata.Title,
12 Hidden: metadata.Hidden,
13+ UpdatedAt: &now,
14 }
15 _, err = h.DBPool.UpdatePost(&updatePost)
16 if err != nil {