allow edit multiple times within time-window
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user