1
0
mirror of https://github.com/lus/pasty.git synced 2023-08-10 21:13:09 +03:00

Implement automatic paste deletion

This commit is contained in:
Lukas SP
2020-09-19 01:56:50 +02:00
parent 17d2fa91c5
commit 4048edbabb
9 changed files with 180 additions and 3 deletions

View File

@@ -1,7 +1,9 @@
package pastes
import (
"github.com/Lukaesebrot/pasty/internal/env"
"github.com/alexedwards/argon2id"
"time"
)
// Paste represents a saved paste
@@ -10,6 +12,8 @@ type Paste struct {
Content string `json:"content" bson:"content"`
SuggestedSyntaxType string `json:"suggestedSyntaxType" bson:"suggestedSyntaxType"`
DeletionToken string `json:"deletionToken" bson:"deletionToken"`
Created int64 `json:"created" bson:"created"`
AutoDelete bool `json:"autoDelete" bson:"autoDelete"`
}
// Create creates a new paste object using the given content
@@ -29,6 +33,8 @@ func Create(id, content string) (*Paste, error) {
Content: content,
SuggestedSyntaxType: suggestedSyntaxType,
DeletionToken: deletionToken,
Created: time.Now().Unix(),
AutoDelete: env.Bool("AUTODELETE", false),
}, nil
}