👔 Prevent user from setting published at before it real published date
This commit is contained in:
parent
851c8e2f70
commit
c125565896
@ -358,6 +358,9 @@ func NewPost(user models.Publisher, item models.Post) (models.Post, error) {
|
|||||||
if item.Alias != nil && len(*item.Alias) == 0 {
|
if item.Alias != nil && len(*item.Alias) == 0 {
|
||||||
item.Alias = nil
|
item.Alias = nil
|
||||||
}
|
}
|
||||||
|
if item.PublishedAt != nil && item.PublishedAt.Unix() < time.Now().Unix() {
|
||||||
|
return item, fmt.Errorf("post cannot be published before now")
|
||||||
|
}
|
||||||
|
|
||||||
if item.Alias != nil {
|
if item.Alias != nil {
|
||||||
re := regexp.MustCompile(`^[a-z0-9.-]+$`)
|
re := regexp.MustCompile(`^[a-z0-9.-]+$`)
|
||||||
@ -439,6 +442,9 @@ func EditPost(item models.Post) (models.Post, error) {
|
|||||||
if item.Alias != nil && len(*item.Alias) == 0 {
|
if item.Alias != nil && len(*item.Alias) == 0 {
|
||||||
item.Alias = nil
|
item.Alias = nil
|
||||||
}
|
}
|
||||||
|
if item.PublishedAt != nil && item.PublishedAt.Unix() < item.CreatedAt.Unix() {
|
||||||
|
return item, fmt.Errorf("post cannot be published before it is created")
|
||||||
|
}
|
||||||
|
|
||||||
if item.Alias != nil {
|
if item.Alias != nil {
|
||||||
re := regexp.MustCompile(`^[a-z0-9.-]+$`)
|
re := regexp.MustCompile(`^[a-z0-9.-]+$`)
|
||||||
|
Loading…
Reference in New Issue
Block a user