Skip to content

Commit

Permalink
Add email notification to external users (bigbluebutton#5565)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad authored and SebastianAppDev committed Dec 20, 2023
1 parent 256d435 commit 36033d7
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Metrics/ClassLength:
# A calculated magnitude based on number of assignments,
# branches, and conditions.
Metrics/AbcSize:
Max: 75
Max: 80

Metrics/ParameterLists:
CountKeywordArgs: false
Expand All @@ -79,7 +79,7 @@ RSpec/AnyInstance:
Enabled: false

Metrics/CyclomaticComplexity:
Max: 16
Max: 17

Metrics/PerceivedComplexity:
Max: 17
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/api/v1/migrations/external_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def create_user
# shared_users_emails: [ <list of shared users emails> ] }}
# Returns: { data: Array[serializable objects] , errors: Array[String] }
# Does: Creates a Room and its RoomMeetingOptions.
# rubocop:disable Metrics/CyclomaticComplexity
def create_room
room_hash = room_params.to_h

Expand Down Expand Up @@ -170,7 +169,6 @@ def create_room

render_data status: :created
end
# rubocop:enable Metrics/CyclomaticComplexity

# POST /api/v1/migrations/site_settings.json
# Expects: { settings: { site_settings: { :PrimaryColor, :PrimaryColorLight, :PrimaryColorDark,
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/api/v1/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ def create
activation_url: activate_account_url(token), base_url: request.base_url,
provider: current_provider).activate_account_email.deliver_later

UserMailer.with(user:, admin_panel_url:, provider: current_provider)
.new_user_signup_email.deliver_later
UserMailer.with(user:, admin_panel_url:, provider: current_provider).new_user_signup_email.deliver_later
end

create_default_room(user)
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/external_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def create_user
user = UserCreator.new(user_params: user_info, provider: current_provider, role: default_role).call
user.save!
create_default_room(user)

# Send admins an email if smtp is enabled
UserMailer.with(user:, admin_panel_url:, provider: current_provider).new_user_signup_email.deliver_later if ENV['SMTP_SERVER'].present?
end

if SettingGetter.new(setting_name: 'ResyncOnLogin', provider:).call
Expand Down
5 changes: 2 additions & 3 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ def branding

def admin_emails
# Find all the roles that have EmailOnSignup enabled
role_ids = Role.joins(role_permissions: :permission)
.with_provider(@provider)
.where(role_permissions: { value: 'true' }, permission: { name: 'EmailOnSignup' })
role_ids = Role.joins(role_permissions: :permission).with_provider(@provider).where(role_permissions: { value: 'true' },
permission: { name: 'EmailOnSignup' })
.pluck(:id)

User.where(role_id: role_ids).pluck(:email)
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/new_user_signup_email.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<p style="font-size: 24px;"><%= t('email.new_user_signup.take_action') %></p>

<a href="<%= @signup_url %>" target="_blank" style="background-color: <%= @brand_color %>; border-radius: 8px; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; font-weight: 600; margin-top: 16px; margin-bottom: 64px;">
<a href="<%= @admin_panel_url %>" target="_blank" style="background-color: <%= @brand_color %>; border-radius: 8px; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; font-weight: 600; margin-top: 16px; margin-bottom: 64px;">
<%= t('email.new_user_signup.admin_panel') %>
</a>
</div>
4 changes: 2 additions & 2 deletions app/views/user_mailer/new_user_signup_email.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

---
<%= t('email.new_user_signup.new_user') %>
<%= t('email.new_user_signup.new_user_description' %>
<%= t('email.new_user_signup.new_user_description') %>
<%= t('email.new_user_signup.name', name: @user.name) %>
<%= t('email.new_user_signup.email', email: @user.email) %>
<%= t('email.new_user_signup.take_action') %>
<%= @signup_url %>
<%= @admin_panel_url %>
---

0 comments on commit 36033d7

Please sign in to comment.