From 8481641ba02e3cd07f6e91d89926dbd05af15d9c Mon Sep 17 00:00:00 2001 From: Fabian Wilkens Date: Sat, 6 Feb 2021 01:44:31 +0100 Subject: [PATCH] Add registration mail --- scripts/change_url | 11 ++ scripts/install | 9 + scripts/upgrade | 8 + sources/patches/app-01-add-mail.patch | 268 ++++++++++++++++++++++++++ 4 files changed, 296 insertions(+) create mode 100644 sources/patches/app-01-add-mail.patch diff --git a/scripts/change_url b/scripts/change_url index 7f33874..1558d8e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -119,6 +119,17 @@ ynh_script_progression --message="Modifying a config file..." --weight=1 config_file="$final_path/live/.env" ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=$old_path" --replace_string="RAILS_RELATIVE_URL_ROOT=$new_path" --target_file="$config_file" +if [ $change_domain -eq 1 ] +then + mail_new="$app@$domain_new" + ynh_replace_string --match_string="$mail" --replace_string="$mail_new" --target_file="$final_path/live/app/mailers/application_mailer.rb" + ynh_replace_string --match_string="$domain" --replace_string="$domain_new" --target_file="$final_path/live/app/views/user_mailer/welcome.html.erb" +fi +if [ $change_path -eq 1 ] +then + ynh_replace_string --match_string="$path_url" --replace_string="$path_new" --target_file="$final_path/live/app/views/user_mailer/welcome.html.erb" +fi + #================================================= # Modify Standard Notes - Extensions #================================================= diff --git a/scripts/install b/scripts/install index 180a517..744b90f 100755 --- a/scripts/install +++ b/scripts/install @@ -39,6 +39,7 @@ else access_domain=$domain fi fi +mail=$app$domain #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -59,6 +60,7 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=install_extensions --value=$install_extensions ynh_app_setting_set --app=$app --key=access_domain --value=$access_domain +ynh_app_setting_set --app=$app --key=mail --value=$mail #================================================= # STANDARD MODIFICATIONS @@ -148,6 +150,13 @@ ynh_replace_string --match_string="DB_DATABASE=standard_notes_db" --replace_stri ynh_replace_string --match_string="DB_USERNAME=std_notes_user" --replace_string="DB_USERNAME=$db_user" --target_file="$config_file" ynh_replace_string --match_string="DB_PASSWORD=changeme123" --replace_string="DB_PASSWORD=$db_pwd" --target_file="$config_file" ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=/" --replace_string="RAILS_RELATIVE_URL_ROOT=$path_url" --target_file="$config_file" +ynh_replace_string --match_string="SMTP_HOST=.*$" --replace_string="SMTP_HOST=localhost" --target_file="$config_file" +ynh_replace_string --match_string="SMTP_PORT=.*$" --replace_string="SMTP_PORT=25" --target_file="$config_file" +ynh_replace_string --match_string="SMTP_DOMAIN=.*$" --replace_string="SMTP_DOAMIN=localhost" --target_file="$config_file" + +ynh_replace_string --match_string="__MAIL__" --replace_string="$mail" --target_file="$final_path/live/app/mailers/application_mailer.rb" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/live/app/views/user_mailer/welcome.html.erb" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/live/app/views/user_mailer/welcome.html.erb" #================================================= # INSTALLING Standard Notes - Synicing Server diff --git a/scripts/upgrade b/scripts/upgrade index ab63b9b..fd777dc 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -27,6 +27,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) port=$(ynh_app_setting_get --app=$app --key=port) install_extensions=$(ynh_app_setting_get --app=$app --key=install_extensions) access_domain=$(ynh_app_setting_get --app=$app --key=access_domain) +mail=$(ynh_app_setting_get --app=$app --key=mail) #================================================= # CHECK VERSION @@ -187,6 +188,13 @@ ynh_replace_string --match_string="DB_DATABASE=standard_notes_db" --replace_stri ynh_replace_string --match_string="DB_USERNAME=std_notes_user" --replace_string="DB_USERNAME=$db_user" --target_file="$config_file" ynh_replace_string --match_string="DB_PASSWORD=changeme123" --replace_string="DB_PASSWORD=$db_pwd" --target_file="$config_file" ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=/" --replace_string="RAILS_RELATIVE_URL_ROOT=$path_url" --target_file="$config_file" +ynh_replace_string --match_string="SMTP_HOST=$" --replace_string="SMTP_HOST=localhost" --target_file="$config_file" +ynh_replace_string --match_string="SMTP_PORT=$" --replace_string="SMTP_PORT=25" --target_file="$config_file" +ynh_replace_string --match_string="SMTP_DOMAIN=$" --replace_string="SMTP_DOAMIN=localhost" --target_file="$config_file" + +ynh_replace_string --match_string="__MAIL__" --replace_string="$mail" --target_file="$final_path/live/app/mailers/application_mailer.rb" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/live/app/views/user_mailer/welcome.html.erb" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/live/app/views/user_mailer/welcome.html.erb" #================================================= # INSTALLING Standard Notes - Synicing Server diff --git a/sources/patches/app-01-add-mail.patch b/sources/patches/app-01-add-mail.patch new file mode 100644 index 0000000..3693618 --- /dev/null +++ b/sources/patches/app-01-add-mail.patch @@ -0,0 +1,268 @@ +diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb +index a813bad..b7f2e2f 100644 +--- a/app/mailers/application_mailer.rb ++++ b/app/mailers/application_mailer.rb +@@ -1,4 +1,4 @@ + class ApplicationMailer < ActionMailer::Base +- default from: 'Standard Notes ' ++ default from: 'Standard Notes <__MAIL__>' + layout 'mailer' + end +diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb +index 6bbbb11..ac7f55e 100644 +--- a/app/mailers/user_mailer.rb ++++ b/app/mailers/user_mailer.rb +@@ -25,4 +25,9 @@ class UserMailer < ApplicationMailer + user = User.find(user_id) + mail(to: user.email, subject: 'Two-factor authentication has been disabled for your account.') + end ++ ++ def welcome(user) ++ @email = user.email ++ mail(to: @email, subject: 'Welcome to your private notes account') ++ end + end +diff --git a/app/views/user_mailer/welcome.html.erb b/app/views/user_mailer/welcome.html.erb +new file mode 100644 +index 0000000..fa4ba56 +--- /dev/null ++++ b/app/views/user_mailer/welcome.html.erb +@@ -0,0 +1,226 @@ ++ ++ ++ ++ ++ ++ ++ ++
++
++
++
++
++
++ Welcome to ++ Standard Notes. ++
++
++
++ Registered as <%= @email %> ++
++
++
++

++ Hi there, ++

++

++ Welcome to your new private notes account. ++ We created Standard Notes to be a safe, private, and lasting place for your most important work. ++

++

++ You should know: ++

++
    ++
  1. ++ Your notes are fully encrypted on your device before they're ever sent to our servers. ++ This means even we can't read the contents of your notes. ++
  2. ++
  3. ++ Standard Notes is available on all your devices. Download the ++ iOS ++ and ++ Android ++ app to go mobile. Use the ++ web app on the go. Or download the desktop app on ++ Mac, Windows, and Linux. ++
  4. ++
++

++ Install instructions for Extensions: ++

++
    ++
  1. ++ Open the Standard Notes web or Desktop app ++
  2. ++
  3. ++ Press Extensions in the button left corner ++
  4. ++
  5. ++ Press on Import Extensions in the button right corner of the new window. ++
  6. ++
  7. ++ Enter https://__DOMAIN____PATH__/extensions/repo.json in the field. ++
  8. ++
  9. ++ Press Enter on your keyboard. ++
  10. ++
  11. ++ Press on Install ++
  12. ++
  13. ++ Now you can see Editors, Themes and Components which you can install ++
  14. ++
++

To have all Standard Notes extensions use Standard Notes Extened:

++
++
++
++

Standard Notes Extended

++

++ Unlock entirely new workflows with powerful editors and cloud backup options ++ with ++ Extended. ++ Extended is our paid extensions program, and how we support continued development on Standard Notes. ++

++

++ Benefits: ++

++
    ++
  • ++

    Encrypted attachments for your notes stored directly in your Dropbox, Google Drive, or WebDAV.

    ++
  • ++
  • ++

    Unlimited access to powerful extensions, editors, and beautiful themes.

    ++
  • ++
  • ++

    Note version history (up to 100 years)

    ++
  • ++
  • ++

    Automatic daily backups of your data to your email inbox, Dropbox, OneDrive, and Google Drive

    ++
  • ++
  • ++

    Two-factor authentication

    ++
  • ++
  • ++

    Support our mission for privacy and longevity in software

    ++
  • ++
++ ++

As low as

++

$2.48/month

++
++ ++
Learn More
++
++
++
++
++
++
++
++ ++ +diff --git a/lib/sync_engine/abstract/user_manager.rb b/lib/sync_engine/abstract/user_manager.rb +index 26a549a..af92835 100644 +--- a/lib/sync_engine/abstract/user_manager.rb ++++ b/lib/sync_engine/abstract/user_manager.rb +@@ -29,6 +29,7 @@ module SyncEngine + else + user = @user_class.new(email: email, encrypted_password: hash_password(password)) + user.update!(registration_params(params)) ++ UserMailer.welcome(user).deliver_later + return success_auth_response(user, params) + end + end