5524258da9
* 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]:
|
||
---|---|---|
.circleci | ||
.dependabot | ||
.github | ||
app | ||
bin | ||
config | ||
db | ||
dist | ||
lib | ||
log | ||
nanobox | ||
public | ||
spec | ||
streaming | ||
vendor | ||
.buildpacks | ||
.codeclimate.yml | ||
.dockerignore | ||
.editorconfig | ||
.env.nanobox | ||
.env.production.sample | ||
.env.test | ||
.env.vagrant | ||
.eslintignore | ||
.eslintrc.js | ||
.foreman | ||
.gitattributes | ||
.gitignore | ||
.haml-lint.yml | ||
.nanoignore | ||
.nvmrc | ||
.profile | ||
.rspec | ||
.rubocop.yml | ||
.ruby-version | ||
.sass-lint.yml | ||
.slugignore | ||
.yarnclean | ||
app.json | ||
Aptfile | ||
AUTHORS.md | ||
babel.config.js | ||
boxfile.yml | ||
Capfile | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
config.ru | ||
CONTRIBUTING.md | ||
crowdin.yml | ||
docker-compose.yml | ||
Dockerfile | ||
Gemfile | ||
Gemfile.lock | ||
LICENSE | ||
package.json | ||
postcss.config.js | ||
priv-config | ||
Procfile | ||
Procfile.dev | ||
Rakefile | ||
README.md | ||
scalingo.json | ||
Vagrantfile | ||
yarn.lock |
Mastodon is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones. On Mastodon, users can publish anything they want: links, pictures, text, video. All Mastodon servers are interoperable as a federated network (users on one server can seamlessly communicate with users from another one, including non-Mastodon software that implements ActivityPub)!
Click below to learn more in a video:
Navigation
- Project homepage 🐘
- Support the development via Patreon
- View sponsors
- Blog
- Documentation
- Browse Mastodon servers
- Browse Mastodon apps
Features
No vendor lock-in: Fully interoperable with any conforming platform
It doesn't have to be Mastodon, whatever implements ActivityPub is part of the social network! Learn more
Real-time, chronological timeline updates
See the updates of people you're following appear in real-time in the UI via WebSockets. There's a firehose view as well!
Media attachments like images and short videos
Upload and view images and WebM/MP4 videos attached to the updates. Videos with no audio track are treated like GIFs; normal videos are looped - like vines!
Safety and moderation tools
Private posts, locked accounts, phrase filtering, muting, blocking and all sorts of other features, along with a reporting and moderation system. Learn more
OAuth2 and a straightforward REST API
Mastodon acts as an OAuth2 provider so 3rd party apps can use the REST and Streaming APIs, resulting in a rich app ecosystem with a lot of choices!
Deployment
Tech stack:
- Ruby on Rails powers the REST API and other web pages
- React.js and Redux are used for the dynamic parts of the interface
- Node.js powers the streaming API
Requirements:
- PostgreSQL 9.5+
- Redis 4+
- Ruby 2.5+
- Node.js 10.13+
The repository includes deployment configurations for Docker and docker-compose, but also a few specific platforms like Heroku, Scalingo, and Nanobox. The stand-alone installation guide is available in the documentation.
A Vagrant configuration is included for development purposes.
Contributing
Mastodon is free, open-source software licensed under AGPLv3.
You can open issues for bugs you've found or features you think are missing. You can also submit pull requests to this repository, or submit translations using Crowdin. To get started, take a look at CONTRIBUTING.md. If your contributions are accepted into Mastodon, you can request to be paid through our OpenCollective.
IRC channel: #mastodon on irc.freenode.net
License
Copyright (C) 2016-2020 Eugen Rochko & other Mastodon contributors (see AUTHORS.md)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.