chinwagsocial/app/views
ThibG 5524258da9
Fix “Email changed” notification sometimes having wrong e-mail (#13475)
* Fix “Email changed” notification sometimes having wrong e-mail

Fixes #6778

The root of the issue is that `send_devise_notification` was called before
the changes were properly commited to the database, causing the mailer to
pick previous values if running too early.

Devise's documentation provides guidance on how to handle that[1][2], however,
I have found it to not be working, as the following happens, in that order:
- `send_devise_notification` is called for the `email_changed` notification.
  In that case, `changed?` is false and `saved_changes?` is true, so
  if we use the former, we have the same issue.
- the `after_commit` hook is called
- `send_devise_notification` is called for the `confirmation_instructions`
  notification.
  In that case, `changed?` is still false, and `saved_changes?` still true,
  so if we use the latter, that second notification email is simply not
  going to be sent (as we would be queuing the notification *after*
  executing the after_commit hook).

This is because it may be called from either an `after_update` or
`after_commit` hook, the difference not being a call to `save` but the
transaction actually being committed to the database. This may arguably
be a bug in Devise, or Devise's notification.

The proposed workaround is inspired by Devise's documentation but checks
whether a transaction is open to make the call whether to immediately
send the notification or defer it to the `after_commit` hook.

[1]: https://www.rubydoc.info/github/plataformatec/devise/Devise%2FModels%2FAuthenticatable:send_devise_notification
[2]: 406915cb78/lib/devise/models/authenticatable.rb (L133-L194)

* Fix cases when sending notifications without changing the model

* Defer sending if and only if in transaction including current record
2020-04-15 16:13:44 +02:00
..
about Fix blur behind closed registration message (#12442) 2019-11-22 15:56:59 +01:00
accounts Fix punycode being rendered instead of unicode in some places (#13030) 2020-02-03 18:44:54 +01:00
admin Add ability to filter audit log in admin UI (#13381) 2020-04-03 13:06:34 +02:00
admin_mailer Fixed not being able to display review pending hashtags in the admin UI. (#11875) 2019-09-17 16:59:16 +02:00
application Add noopener and/or noreferrer (#12202) 2019-10-24 22:44:42 +02:00
auth Fix invite request input not being shown on sign-up error if left empty (#13089) 2020-02-16 12:38:22 +01:00
authorize_interactions Fix misleading error when attempting to re-send a pending follow request (#13133) 2020-02-24 21:19:19 +01:00
directories Change last_status_at to be a date, not datetime (#12966) 2020-01-26 23:13:48 +01:00
errors Add specific rate limits for posting and following (#13172) 2020-03-08 15:17:39 +01:00
filters Various fixes and improvements (#12878) 2020-01-20 15:55:03 +01:00
follower_accounts Improve blocked view of profiles (#10491) 2019-04-07 04:59:13 +02:00
following_accounts Improve blocked view of profiles (#10491) 2019-04-07 04:59:13 +02:00
home Fix blurhash and autoplay not working on public pages (#11585) 2019-08-16 19:15:05 +02:00
invites Remove invite comments from UI (#12068) 2019-10-03 22:37:13 +02:00
kaminari Pagination improvements (#1445) 2017-04-11 01:11:41 +02:00
layouts Fix API footer link in Web UI (#13441) 2020-04-12 13:38:14 +02:00
media Save video metadata and improve video OpenGraph tags (#6481) 2018-02-16 07:22:20 +01:00
notification_mailer Fix NotificationMailer failing when receiving mention with media from remote instance (#11765) 2019-09-05 06:14:30 +02:00
oauth Add noopener and/or noreferrer (#12202) 2019-10-24 22:44:42 +02:00
public_timelines Change message of public timeline for local only (#12224) 2019-10-27 12:45:33 +01:00
relationships Change last_status_at to be a date, not datetime (#12966) 2020-01-26 23:13:48 +01:00
remote_follow Admission-based registrations mode (#10250) 2019-03-14 05:28:30 +01:00
remote_interaction Remove Atom feeds and old URLs in the form of GET /:username/updates/:id (#11247) 2019-07-07 16:16:51 +02:00
settings Fix account aliases page (#13452) 2020-04-13 06:41:43 +02:00
shared Remove fallback to long description on sidebar and meta description (#12119) 2019-10-08 22:08:55 +02:00
shares Fix blurhash and autoplay not working on public pages (#11585) 2019-08-16 19:15:05 +02:00
statuses Fix styling of polls in JS-less fallback on public pages (#13436) 2020-04-07 18:21:58 +02:00
tags Fix blurhash and autoplay not working on public pages (#11585) 2019-08-16 19:15:05 +02:00
user_mailer Fix “Email changed” notification sometimes having wrong e-mail (#13475) 2020-04-15 16:13:44 +02:00
well_known/host_meta Remove XML version of Webfinger and remove links to Atom feeds (#11460) 2019-08-01 19:14:02 +02:00