premium onboarding notification

This commit is contained in:
Andrew Brown 2020-04-20 21:30:16 -05:00
parent 6637d26d05
commit 500ede3b16
4 changed files with 22 additions and 2 deletions

View File

@ -16,6 +16,15 @@ class ContributorsController < ApplicationController
passthrough_link: Rails.application.routes.url_helpers.universe_path(relevant_universe)
) if user.present?
# Create a notification letting the universe owner know
relevant_universe.user.notifications.create(
message_html: "<div><span class='#{User.color}-text'>#{user.display_name}</span> has stopped collaborating on your <span class='#{Universe.color}-text'>#{relevant_universe.name}</span> universe.</div>",
icon: Universe.icon,
icon_color: Universe.color,
happened_at: DateTime.current,
passthrough_link: Rails.application.routes.url_helpers.universe_path(relevant_universe)
) if user.present?
#todo send "you've been removed as a contributor" email
end

View File

@ -82,7 +82,7 @@ class RegistrationsController < Devise::RegistrationsController
icon_color: Universe.color,
happened_at: DateTime.current,
passthrough_link: Rails.application.routes.url_helpers.universe_path(contributorship.universe)
) if resource.present?
)
end
end
end

View File

@ -234,13 +234,16 @@ class User < ApplicationRecord
result
end
def forum_username
def display_name
username = self.username.present? ? "@#{self.username}" : nil
username ||= self.name.present? ? self.name : nil
username ||= 'Anonymous Author'
username
end
def forum_username
display_name
end
def self.from_api_key(key)
found_key = ApiKey.includes(:user).find_by(key: key)

View File

@ -41,6 +41,14 @@ class SubscriptionService < Service
end_date: DateTime.now.end_of_day + 5.years
)
user.notifications.create(
message_html: "<div class='yellow-text text-darken-4'>You signed up for Premium!</div><div>Click here to turn on your Premium pages.</div>",
icon: 'star',
icon_color: 'text-darken-3 yellow',
happened_at: DateTime.current,
passthrough_link: Rails.application.routes.url_helpers.customization_content_types_path
) if user.reload.on_premium_plan?
report_subscription_change_to_slack(user, plan_id)
rescue Stripe::CardError => e