check user equality for email notifications only by ID

This commit is contained in:
Dmitry Verkhoturov
2020-01-07 14:25:27 -06:00
committed by Umputun
parent a309fc8fb0
commit eeb9c72248
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -195,7 +195,7 @@ func (e *Email) Send(ctx context.Context, req Request) (err error) {
}
if req.Comment.ID != "" {
if req.parent.User == req.Comment.User {
if req.parent.User.ID == req.Comment.User.ID {
// don't send anything if if user replied to their own comment
return nil
}
+2 -2
View File
@@ -187,8 +187,8 @@ func TestEmail_Send(t *testing.T) {
email.TokenGenFn = TokenGenFn
email.UnsubscribeURL = "https://remark42.com/api/v1/email/unsubscribe"
req := Request{
Comment: store.Comment{ID: "999", User: store.User{Name: "test_user"}, PostTitle: "test_title"},
parent: store.Comment{ID: "1", User: store.User{Name: "parent_user"}},
Comment: store.Comment{ID: "999", User: store.User{ID: "1", Name: "test_user"}, PostTitle: "test_title"},
parent: store.Comment{ID: "1", User: store.User{ID: "999", Name: "parent_user"}},
Email: "test@example.org"}
assert.NoError(t, email.Send(context.TODO(), req))
assert.Equal(t, "from@example.org", fakeSmtp.readMail())