Class: TentD::API::Followings::Follow
- Inherits:
-
Middleware
- Object
- Middleware
- TentD::API::Followings::Follow
- Defined in:
- lib/tentd/api/followings.rb
Instance Method Summary collapse
Methods inherited from Middleware
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
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/tentd/api/followings.rb', line 81 def action(env) env.following = Model::Following.create(:entity => env.params.data.entity, :groups => env.params.data.groups.to_a.map { |g| g['id'] }, :confirmed => false) client = ::TentClient.new(env.server_url, :faraday_adapter => TentD.faraday_adapter) res = client.follower.create( :entity => env['tent.entity'], :licenses => Model::ProfileInfo.tent_info.content['licenses'], :notification_path => "notifications/#{env.following.public_id}" ) case res.status when 200...300 env.follow_data = res.body else return [res.status, res.headers, res.body] end env end |