|
1
|
|
|
# frozen_string_literal: true |
|
2
|
|
|
|
|
3
|
|
|
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. |
|
4
|
|
|
# |
|
5
|
|
|
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below). |
|
6
|
|
|
# |
|
7
|
|
|
# This program is free software; you can redistribute it and/or modify it under the |
|
8
|
|
|
# terms of the GNU Lesser General Public License as published by the Free Software |
|
9
|
|
|
# Foundation; either version 3.0 of the License, or (at your option) any later |
|
10
|
|
|
# version. |
|
11
|
|
|
# |
|
12
|
|
|
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY |
|
13
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
14
|
|
|
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|
15
|
|
|
# |
|
16
|
|
|
# You should have received a copy of the GNU Lesser General Public License along |
|
17
|
|
|
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. |
|
18
|
|
|
|
|
19
|
|
|
module Emailer |
|
20
|
|
|
extend ActiveSupport::Concern |
|
21
|
|
|
|
|
22
|
|
|
# Sends account activation email. |
|
23
|
|
|
def send_activation_email(user) |
|
24
|
|
|
return unless Rails.configuration.enable_email_verification |
|
25
|
|
|
|
|
26
|
|
|
@user = user |
|
27
|
|
|
UserMailer.verify_email(@user, user_verification_link, logo_image, user_color).deliver |
|
28
|
|
|
end |
|
29
|
|
|
|
|
30
|
|
|
# Sends password reset email. |
|
31
|
|
|
def send_password_reset_email(user) |
|
32
|
|
|
return unless Rails.configuration.enable_email_verification |
|
33
|
|
|
|
|
34
|
|
|
@user = user |
|
35
|
|
|
UserMailer.password_reset(@user, reset_link, logo_image, user_color).deliver_now |
|
36
|
|
|
end |
|
37
|
|
|
|
|
38
|
|
|
def send_user_promoted_email(user) |
|
39
|
|
|
return unless Rails.configuration.enable_email_verification |
|
40
|
|
|
|
|
41
|
|
|
UserMailer.user_promoted(user, root_url, logo_image, user_color).deliver_now |
|
42
|
|
|
end |
|
43
|
|
|
|
|
44
|
|
|
def send_user_demoted_email(user) |
|
45
|
|
|
return unless Rails.configuration.enable_email_verification |
|
46
|
|
|
|
|
47
|
|
|
UserMailer.user_demoted(user, root_url, logo_image, user_color).deliver_now |
|
48
|
|
|
end |
|
49
|
|
|
|
|
50
|
|
|
# Sends inivitation to join |
|
51
|
|
|
def send_invitation_email(name, email, token) |
|
52
|
|
|
return unless Rails.configuration.enable_email_verification |
|
53
|
|
|
|
|
54
|
|
|
@token = token |
|
55
|
|
|
UserMailer.invite_email(name, email, invitation_link, logo_image, user_color).deliver_now |
|
56
|
|
|
end |
|
57
|
|
|
|
|
58
|
|
|
def send_user_approved_email(user) |
|
59
|
|
|
return unless Rails.configuration.enable_email_verification |
|
60
|
|
|
|
|
61
|
|
|
UserMailer.approve_user(user, root_url, logo_image, user_color).deliver_now |
|
62
|
|
|
end |
|
63
|
|
|
|
|
64
|
|
|
def send_approval_user_signup_email(user) |
|
65
|
|
|
return unless Rails.configuration.enable_email_verification |
|
66
|
|
|
|
|
67
|
|
|
UserMailer.approval_user_signup(user, admins_url, logo_image, user_color, admin_emails).deliver_now |
|
68
|
|
|
end |
|
69
|
|
|
|
|
70
|
|
|
def send_invite_user_signup_email(user) |
|
71
|
|
|
return unless Rails.configuration.enable_email_verification |
|
72
|
|
|
|
|
73
|
|
|
UserMailer.invite_user_signup(user, admins_url, logo_image, user_color, admin_emails).deliver_now |
|
74
|
|
|
end |
|
75
|
|
|
|
|
76
|
|
|
private |
|
77
|
|
|
|
|
78
|
|
|
# Returns the link the user needs to click to verify their account |
|
79
|
|
|
def user_verification_link |
|
80
|
|
|
edit_account_activation_url(token: @user.activation_token, email: @user.email) |
|
81
|
|
|
end |
|
82
|
|
|
|
|
83
|
|
|
def admin_emails |
|
84
|
|
|
admins = User.with_role(:admin) |
|
85
|
|
|
|
|
86
|
|
|
if Rails.configuration.loadbalanced_configuration |
|
87
|
|
|
admins = admins.without_role(:super_admin) |
|
88
|
|
|
.where(provider: user_settings_provider) |
|
89
|
|
|
end |
|
90
|
|
|
|
|
91
|
|
|
admins.collect(&:email).join(",") |
|
92
|
|
|
end |
|
93
|
|
|
|
|
94
|
|
|
def reset_link |
|
95
|
|
|
edit_password_reset_url(@user.reset_token, email: @user.email) |
|
96
|
|
|
end |
|
97
|
|
|
|
|
98
|
|
|
def invitation_link |
|
99
|
|
|
if allow_greenlight_users? |
|
100
|
|
|
signup_url(invite_token: @token) |
|
101
|
|
|
else |
|
102
|
|
|
root_url(invite_token: @token) |
|
103
|
|
|
end |
|
104
|
|
|
end |
|
105
|
|
|
end |
|
106
|
|
|
|