Send activation email after user approved

This commit is contained in:
Chris Hunt 2013-06-05 20:16:31 -07:00
parent 93fc0e74bc
commit f6ce985121
17 changed files with 40 additions and 185 deletions

View file

@ -10,6 +10,15 @@ class UserNotifications < ActionMailer::Base
build_email(user.email, "user_notifications.signup", email_token: opts[:email_token])
end
def signup_after_approval(user, opts={})
build_email(
user.email,
'user_notifications.signup_after_approval',
email_token: opts[:email_token],
new_user_tips: SiteContent.content_for(:usage_tips)
)
end
def authorize_email(user, opts={})
build_email(user.email, "user_notifications.authorize_email", email_token: opts[:email_token])
end

View file

@ -209,7 +209,8 @@ class User < ActiveRecord::Base
self.approved = true
self.approved_by = approved_by
self.approved_at = Time.now
enqueue_welcome_message('welcome_approved') if save
send_approval_email if save
end
def self.email_hash(email)
@ -615,7 +616,13 @@ class User < ActiveRecord::Base
end
end
def send_approval_email
Jobs.enqueue(:user_email,
type: :signup_after_approval,
user_id: id,
email_token: email_tokens.first.token
)
end
end
# == Schema Information

View file

@ -800,19 +800,6 @@ cs:
- Během čtení nějakého tématu se můžete kliknutím na název tématu v horní části stránky vrátit na začátek tématu. Chcete-li naopak skočit na *konec* tématu, klikněte na šipku dolů v indikátoru pozice v dolní části stránky, nebo klikněte na odkaz 'poslední příspěvek' v souhrnu tématu u prvního příspěvku.
welcome_approved:
subject_template: "Byl jste schválen na %{site_name}!"
text_body_template: |
Gratulujeme!
Váš účet byl schválen a můžete se připojit na %{site_name}, vítejte na našem diskuzním fóru!
%{new_user_tips}
Věříme v [civilizované komunitní chování](%{base_url}/faq) za všech okolností.
Užijte si naše fórum!
welcome_user:
subject_template: "Vítejte na %{site_name}!"
text_body_template: |

View file

@ -636,19 +636,6 @@ da:
- Mens du læser et emne, kan du altid springe til toppen ved at klikke på emnets titel øverst på siden. For at komme til *bunden*, klik på ned-pilen på status-viseren nederst på skærmen, eller klik på sidste indlæg-feltet på emne-opsummeringen under det første indlæg.
welcome_approved:
subject_template: "Du er blevet godkendt på %{site_name}!"
text_body_template: |
Tillykke!
Din brugerkonto på %{site_name} er blevet godkendt, velkommen til vores debatforum!
%{new_user_tips}
Vi går ind for [civiliseret debatkultur](%{base_url}/faq) til enhver tid.
Nyd dit ophold!
welcome_user:
subject_template: "Velkommen til %{site_name}!"
text_body_template: |

View file

@ -778,19 +778,6 @@ de:
- Um an den Anfang eines Themas zu gelangen, klicke auf den Titel am oberen Rand der Seite. Um ans *Ende* zu springen, klicke auf den Abwärtspfeil in der Fortschrittsanzeige des Themas unten auf der Seite oder auf das Feld 'Letzter Beitrag' in der Zusammenfassung des Themas unter dem ersten Beitrag.
welcome_approved:
subject_template: "Du wurdest auf %{site_name} zugelassen!"
text_body_template: |
Glückwunsch!
Du wurdest auf %{site_name} zugelassen, willkommen in unserem Forum!
%{new_user_tips}
Wir stehen für [zivilisiertes Verhalten in Online-Communitys](%{base_url}/faq).
Viel Vergnügen!
welcome_user:
subject_template: "Willkommen auf %{site_name}!"
text_body_template: |

View file

@ -797,19 +797,6 @@ en:
- While reading a topic, move to the top ↑ by clicking its title at the top of the page. To reach the *bottom* ↓, click the down arrow on the topic progress indicator at the bottom of the page, or click the last post field on the topic summary under the first post.
welcome_approved:
subject_template: "You've been approved on %{site_name}!"
text_body_template: |
Congratulations!
You're approved to join %{site_name}, welcome to our discussion forum!
%{new_user_tips}
We believe in [civilized community behavior](%{base_url}/faq) at all times.
Enjoy your stay!
welcome_user:
subject_template: "Welcome to %{site_name}!"
text_body_template: |
@ -975,6 +962,24 @@ en:
%{base_url}/users/authorize-email/%{email_token}
signup_after_approval:
subject_template: "You've been approved on %{site_name}!"
text_body_template: |
Welcome to %{site_name}!
You're approved to join %{site_name}, welcome to our discussion forum!
Click the following link to confirm and activate your new account:
%{base_url}/users/activate-account/%{email_token}
If the above link is not clickable, try copying and pasting it into the address bar of your web browser.
%{new_user_tips}
We believe in [civilized community behavior](%{base_url}/faq) at all times.
Enjoy your stay!
signup:
subject_template: "[%{site_name}] Activate your new account"
text_body_template: |

View file

@ -618,19 +618,6 @@ es:
- Mientras lees un topic, vuelve a lo más alto ↑ haciendo click en su título arriba de la página. Para alcanzar el *final* ↓, haz click en la flecha hacia abajo del indicador de prograso del topic al final de la página, or click the last post field on the topic summary under the first post.
welcome_approved:
subject_template: "¡Has sido aprobado en %{site_name}!"
text_body_template: |
¡Enhorabuena!
Has sido aprobado para unirte a %{site_name}, ¡Bienvenido a nuestro foro de discusión!
%{new_user_tips}
Creemos en [civilized community behavior](%{base_url}/faq) siempre.
¡Disfruta tu estancia!
welcome_user:
subject_template: "Bienvenido a %{site_name}!"
text_body_template: |

View file

@ -785,19 +785,6 @@ fr:
- Pendant que vous lisez une discussion, vous pouvez retourner au début en cliquant sur son titre situé en haut de l'écran. Pour atteindre la *fin*, cliquez sur la flèche vers le bas sur l'indiquateur de progression en bas de la page, ou cliquez sur le champ "dernier message" dans le résumé de la discussion, sous le premier message.
welcome_approved:
subject_template: "Vous avez été accepté sur %{site_name} !"
text_body_template: |
Félicitations !
Vous avez été accepté pour rejoindre %{site_name}, bienvenue sur notre forum de discussions.
%{new_user_tips}
Nous croyons au [comportement communautaire civilisé](%{base_url}/faq) en tous temps.
Amusez-vous bien !
welcome_user:
subject_template: "Bienvenue sur %{site_name} !"
text_body_template: |

View file

@ -639,19 +639,6 @@ id:
- While reading a topic, move to the top ↑ by clicking its title at the top of the page. To reach the *bottom* ↓, click the down arrow on the topic progress indicator at the bottom of the page, or click the last post field on the topic summary under the first post.
welcome_approved:
subject_template: "You've been approved on %{site_name}!"
text_body_template: |
Congratulations!
You're approved to join %{site_name}, welcome to our discussion forum!
%{new_user_tips}
We believe in [civilized community behavior](%{base_url}/faq) at all times.
Enjoy your stay!
welcome_user:
subject_template: "Welcome to %{site_name}!"
text_body_template: |

View file

@ -765,19 +765,6 @@ it:
- Mentre leggi un topic, puoi tornare in cima cliccando il titolo all'inizio della pagina. Per raggiungere il *fondo* invece, clicca la freccia in basso nella progress bar situata in fondo alla pagina, o clicca il campo ultimo post nel sommario presente nel primo post.
welcome_approved:
subject_template: "Il tuo account è stato approvato su %{site_name}!"
text_body_template: |
Congratulazioni!
Il tuo account è stato approvato per accedere su %{site_name}, benvenuto nel nostro forum!
%{new_user_tips}
Crediamo nel [comportamento civilizzato della community](%{base_url}/faq) in ogni momento.
Goditi la permanenza!
welcome_user:
subject_template: "Benvenuto su %{site_name}!"
text_body_template: |

View file

@ -791,19 +791,6 @@ nl:
- Wanneer je een topic leest, kan je naar boven scrollen (↑) door op de topictitel bovenaan de pagina te klikken. Om de *onderkant* (↓) te bereiken klik je op de pijl naar beneden aan de onderkant van de pagina of je klikt op het Laatste Post-veld in de topicsamenvatting onder het eerste bericht.
welcome_approved:
subject_template: "Je aanmelding voor %{site_name} is goedgekeurd!"
text_body_template: |
Gefeliciteerd!
Je aanvraag om lid te worden van %{site_name} is goedgekeurd, welkom op ons discussieforum!
%{new_user_tips}
We geloven altijd in [beschaafd gemeenschappelijk gedrag](%{base_url}/faq).
Geniet van je verblijf!
welcome_user:
subject_template: "Welkom bij %{site_name}!"
text_body_template: |

View file

@ -894,19 +894,7 @@ pseudo:
- Ŵĥíłé řéáďíɳǧ á ťóƿíč, ɱóνé ťó ťĥé ťóƿ ↑ ƀý čłíčǩíɳǧ íťš ťíťłé áť ťĥé ťóƿ óƒ ťĥé ƿáǧé. Ťó řéáčĥ ťĥé *ƀóťťóɱ* ↓, čłíčǩ ťĥé ďóŵɳ ářřóŵ óɳ ťĥé ťóƿíč ƿřóǧřéšš íɳďíčáťóř áť ťĥé ƀóťťóɱ óƒ ťĥé ƿáǧé, óř čłíčǩ ťĥé łášť ƿóšť ƒíéłď óɳ ťĥé ťóƿíč šůɱɱářý ůɳďéř ťĥé ƒířšť ƿóšť.
]]
welcome_approved:
subject_template: '[[ Ýóů''νé ƀééɳ áƿƿřóνéď óɳ %{site_name}! ]]'
text_body_template: |-
[[ Čóɳǧřáťůłáťíóɳš!
Ýóů'řé áƿƿřóνéď ťó ʲóíɳ %{site_name}, ŵéłčóɱé ťó óůř ďíščůššíóɳ ƒóřůɱ!
%{new_user_tips}
Ŵé ƀéłíéνé íɳ [číνíłížéď čóɱɱůɳíťý ƀéĥáνíóř](%{base_url}/ƒáƣ) áť áłł ťíɱéš.
Éɳʲóý ýóůř šťáý!
]]
welcome_user:
subject_template: '[[ Ŵéłčóɱé ťó %{site_name}! ]]'
text_body_template: |-

View file

@ -555,19 +555,6 @@ pt:
- Enquanto estiveres a ler um tópico, podes mover para o topo clicando no título no topo da página. Para chegar ao fundo clica na seta na barra de prograsso no fundo da página, ou clica no último campo sumário do tópico debaixo do primeiro post.
welcome_approved:
subject_template: "Foste aprovado no %{site_name}!"
text_body_template: |
Parabéns!
Estás aprovado para te juntares a %{site_name}, ben-vindo ao nosso foum!
%{new_user_tips}
Acreditamos num [comportamento civilizado na comunidade](%{base_url}/faq) a toda a hora.
Diverte-te durante a estadia!
welcome_user:
subject_template: "Welcome to %{site_name}!"
text_body_template: |

View file

@ -693,19 +693,6 @@ sv:
- While reading a topic, move to the top ↑ by clicking its title at the top of the page. To reach the *bottom* ↓, click the down arrow on the topic progress indicator at the bottom of the page, or click the last post field on the topic summary under the first post.
welcome_approved:
subject_template: "You've been approved on %{site_name}!"
text_body_template: |
Congratulations!
You're approved to join %{site_name}, welcome to our discussion forum!
%{new_user_tips}
We believe in [civilized community behavior](%{base_url}/faq) at all times.
Enjoy your stay!
welcome_user:
subject_template: "Welcome to %{site_name}!"
text_body_template: |

View file

@ -763,19 +763,6 @@ zh_CN:
- 当阅读一个主题时,你可以通过点击页面顶部的标题回到顶部;要去到 *底部*,点击页面底部的主题浏览进度指示器里的向下箭头,或者点击该主题第一帖下面的汇总信息里的最后一帖区域。
welcome_approved:
subject_template: "你已经获得了 %{site_name} 的批准!"
text_body_template: |
恭喜你!
你已经被批准加入 %{site_name},欢迎来到我们论坛参与讨论!
%{new_user_tips}
我们始终相信 [文明的社会行为](%{base_url}/faq)。
好好享受你在论坛的时光吧!
welcome_user:
subject_template: "欢迎来到 %{site_name}"
text_body_template: |

View file

@ -763,19 +763,6 @@ zh_TW:
- 當閱讀一個主題時,你可以通過點擊頁面頂部的標題回到頂部;要去到 *底部*,點擊頁面底部的主題浏覽進度指示器裏的向下箭頭,或者點擊該主題第一帖下面的彙總信息裏的最後一帖區域。
welcome_approved:
subject_template: "你已經獲得了 %{site_name} 的批准!"
text_body_template: |
恭喜你!
你已經被批准加入 %{site_name},歡迎來到我們論壇參與討論!
%{new_user_tips}
我們始終相信 [文明的社會行爲](%{base_url}/faq)。
好好享受你在論壇的時光吧!
welcome_user:
subject_template: "歡迎來到 %{site_name}"
text_body_template: |

View file

@ -94,8 +94,10 @@ describe User do
let(:user) { Fabricate(:user) }
let(:admin) { Fabricate(:admin) }
it "generates a welcome message" do
user.expects(:enqueue_welcome_message).with('welcome_approved')
it "enqueues a 'signup after approval' email" do
Jobs.expects(:enqueue).with(
:user_email, has_entries(type: :signup_after_approval)
)
user.approve(admin)
end