allow edit multiple times within time-window

This commit is contained in:
Umputun
2018-05-18 12:03:53 -05:00
parent 779c89a270
commit 0c9ff0a2a0
2 changed files with 1 additions and 5 deletions
-4
View File
@@ -104,10 +104,6 @@ func (s *DataStore) EditComment(locator store.Locator, commentID string, req Edi
if err != nil {
return comment, err
}
// edit allowed only once
if comment.Edit != nil {
return comment, errors.Errorf("comment %s already edited at %s", commentID, comment.Edit.Timestamp)
}
// edit allowed in editDuration window only
if s.EditDuration > 0 && time.Now().After(comment.Timestamp.Add(s.EditDuration)) {
+1 -1
View File
@@ -158,7 +158,7 @@ func TestService_EditComment(t *testing.T) {
_, err = b.EditComment(store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, res[0].ID,
EditRequest{Orig: "yyy", Text: "xxx", Summary: "my edit"})
assert.NotNil(t, err, "allow edit once")
assert.Nil(t, err, "allow second edit")
}
func TestService_EditCommentDurationFailed(t *testing.T) {