repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
cff790d
parent
494540f
author
Christopher Hoelter
date
2023-07-04 04:26:02 +0000 UTC
Ensure 'hidden' value gets updated when the draft attribute is modified. (#21)

3 files changed,  +4, -1
M db/postgres/storage.go
+2, -1
 1@@ -232,7 +232,7 @@ const (
 2 	sqlUpdatePost = `
 3 	UPDATE posts
 4 	SET slug = $1, title = $2, text = $3, description = $4, updated_at = $5, publish_at = $6,
 5-		file_size = $7, shasum = $8, data = $9
 6+		file_size = $7, shasum = $8, data = $9, hidden = $11
 7 	WHERE id = $10`
 8 	sqlUpdateUserName = `UPDATE app_users SET name = $1 WHERE id = $2`
 9 	sqlIncrementViews = `UPDATE posts SET views = views + 1 WHERE id = $1 RETURNING views`
10@@ -714,6 +714,7 @@ func (me *PsqlDB) UpdatePost(post *db.Post) (*db.Post, error) {
11 		post.Shasum,
12 		post.Data,
13 		post.ID,
14+		post.Hidden,
15 	)
16 	if err != nil {
17 		return nil, err
M filehandlers/imgs/img.go
+1, -0
1@@ -208,6 +208,7 @@ func (h *UploadImgHandler) writeImg(s ssh.Session, data *PostMetaData) error {
2 			Shasum:      data.Shasum,
3 			Text:        data.Text,
4 			Title:       data.Title,
5+			Hidden:      data.Hidden,
6 		}
7 		_, err = h.DBPool.UpdatePost(&updatePost)
8 		if err != nil {
M filehandlers/post_handler.go
+1, -0
1@@ -305,6 +305,7 @@ func (h *ScpUploadHandler) Write(s ssh.Session, entry *utils.FileEntry) (string,
2 			Shasum:      metadata.Shasum,
3 			Text:        metadata.Text,
4 			Title:       metadata.Title,
5+			Hidden:      metadata.Hidden,
6 		}
7 		_, err = h.DBPool.UpdatePost(&updatePost)
8 		if err != nil {