seek4science / seek

For finding, sharing and exchanging Data, Models, Simulations and Processes in Science.
http://www.seek4science.org
BSD 3-Clause "New" or "Revised" License
77 stars 52 forks source link

Double check that subscription emails and notifications aren't sent to none registered profiles #286

Open stuzart opened 4 years ago

stuzart commented 4 years ago

It should be the case, but fix if not. Profiles that are created for a project, but do not yet have an associated registered user, should not receive notification emails for subscriptions, or for announcement notifications.

Person.receive_notifications? doesn't seem to take this into account, but the database flag may be false until a user registers.

Be careful not to block emails required during the signup process

whomingbird commented 4 years ago

i changed the line https://github.com/seek4science/seek/blob/19f7e2a9d876398c0647e35cc500ecc5c34719b2/test/unit/jobs/send_periodic_emails_job_test.rb#L148 to person1 = Factory(:min_person) person1.user = nil meaning that person1 has not registered, but tests passed.
log also shows the email is queued to deliver later.

person:#<Person id: 1040008019, created_at: "2020-06-09 23:34:35", updated_at: "2020-06-09 23:34:35", first_name: nil, last_name: "Minimal", email: "minimal_person@email.com", phone: nil, skype_name: nil, web_page: nil, description: nil, avatar_id: nil, status_id: 0, first_letter: "M", uuid: "b37420a0-8cd7-0138-4c05-2cde48001122", roles_mask: 0, orcid: nil>
[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 0eed42fd-1ca5-4423-980b-91a9259eaf88) to Test(mailers) with arguments: "SubMailer", "send_digest_subscription", "deliver_now", #<GlobalID:0x00007f97f8fb6ed0 @uri=#<URI::GID gid://seek/Person/1040008019>>, [#<GlobalID:0x00007f97f8fb66d8 @uri=#<URI::GID gid://seek/ActivityLog/3681>>], "daily"