diff --git a/app/store/service.go b/app/store/service.go index 7831a3ec..f3f1bc17 100644 --- a/app/store/service.go +++ b/app/store/service.go @@ -6,6 +6,8 @@ import ( "github.com/pkg/errors" ) +var editDuration = 5 * time.Minute + // Service wraps store.Interface with additional methods type Service struct { Interface @@ -55,6 +57,11 @@ func (s *Service) EditComment(locator Locator, commentID string, text string, ed return comment, errors.Errorf("comment %s already edited at %s", commentID, comment.Edit.Timestamp) } + // edit allowed in editDuration window only + if comment.Timestamp.Add(editDuration).After(time.Now()) { + return comment, errors.Errorf("too late to edit %s", commentID) + } + comment.Text = text comment.Edit = &edit comment.Edit.Timestamp = time.Now()