Class: TentD::API::Posts::TriggerUpdates

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



305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/tentd/api/posts.rb', line 305

def action(env)
  post = env.response
  if post && post.following && post.following == env.current_auth
    case post.type.base
    when 'https://tent.io/types/post/profile'
      Notifications.update_following_profile(:following_id => post.following.id)
    when 'https://tent.io/types/post/delete'
      if deleted_post = Model::Post.first(:public_id => post.content.id, :following_id => env.current_auth.id)
        deleted_post.destroy
      end
    end
  end
  env
end