Send an email to the user when a recording is done processing

Had to add an email attribute to users to store their email to send the
notification. Will only send it for user rooms since they are the only
ones we know who to notify.
This commit is contained in:
Leonardo Crauss Daronco
2016-12-08 18:33:19 -02:00
parent 09c30bb5bd
commit e94f3d7a10
12 changed files with 161 additions and 7 deletions

View File

@ -21,6 +21,7 @@ class User < ApplicationRecord
def self.from_omniauth(auth_hash)
user = find_or_initialize_by(uid: auth_hash['uid'], provider: auth_hash['provider'])
user.username = self.send("#{auth_hash['provider']}_username", auth_hash) rescue nil
user.email = self.send("#{auth_hash['provider']}_email", auth_hash) rescue nil
user.name = auth_hash['info']['name']
user.save!
user
@ -30,10 +31,18 @@ class User < ApplicationRecord
auth_hash['info']['nickname']
end
def self.twitter_email(auth_hash)
auth_hash['info']['email']
end
def self.google_username(auth_hash)
auth_hash['info']['email'].split('@').first
end
def self.google_email(auth_hash)
auth_hash['info']['email']
end
def room_url
"/rooms/#{encrypted_id}"
end