* Initial automatic cleanup with rubocop * Fix syntax error introduced by rubocop * Cleanup seeds file * Cleanup lib folder * Exclude bin folder because it contains auto generated files * Make Rubocop a little bit more chatty * Block length should not include comments in the count * Cleanup config folder * Cleanup specs * Updated Rubocop version and generated a todo file * Fix broken ArticlesApi spec * Fix tests * Restored rubocop pre-commit hook
28 lines
596 B
Ruby
28 lines
596 B
Ruby
class TwilioToken
|
|
attr_accessor :user, :room_name
|
|
|
|
def initialize(user, room_name)
|
|
@user = user
|
|
@room_name = room_name
|
|
end
|
|
|
|
def get
|
|
account_sid = ApplicationConfig["TWILIO_ACCOUNT_SID"]
|
|
api_key = ApplicationConfig["TWILIO_VIDEO_API_KEY"]
|
|
api_secret = ApplicationConfig["TWILIO_VIDEO_API_SECRET"]
|
|
|
|
token = Twilio::JWT::AccessToken.new(
|
|
account_sid,
|
|
api_key,
|
|
api_secret,
|
|
[],
|
|
identity: user.id,
|
|
)
|
|
|
|
grant = Twilio::JWT::AccessToken::VideoGrant.new
|
|
grant.room = room_name
|
|
token.add_grant(grant)
|
|
|
|
token.to_jwt
|
|
end
|
|
end
|