Class: TentD::API::Followers::Create

Inherits:
Middleware show all
Defined in:
lib/tentd/api/followers.rb

Instance Method Summary collapse

Methods inherited from Middleware

#call, #initialize

Methods included from Authorizable

#authorize_env!, #authorize_env?

Constructor Details

This class inherits a constructor from TentD::API::Middleware

Instance Method Details

#action(env) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/tentd/api/followers.rb', line 78

def action(env)
  return env if env.authorized_scopes.include?(:write_followers)
  if follower = Model::Follower.create_follower(env.params[:data].merge('profile' => env['profile']))
    env.authorized_scopes << :read_secrets
    env.authorized_scopes << :self
    env.notify_action = 'create'
    env.notify_instance = follower
    env.response = follower
  end
  env
end