Class: TentD::API::Followings::Notify

Inherits:
Middleware
  • Object
show all
Defined in:
lib/tentd/api/followings.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



167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/tentd/api/followings.rb', line 167

def action(env)
  return env unless following = env.notify_instance
  post = Model::Post.create(
    :type => 'https://tent.io/types/post/following/v0.1.0',
    :entity => env['tent.entity'],
    :content => {
      :id => following.public_id,
      :entity => following.entity,
      :action => env.notify_action
    }
  )
  Notifications.trigger(:type => post.type.uri, :post_id => post.id)
  env
end