Class: TentD::API::Posts::CreatePost

Inherits:
Middleware 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



118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/tentd/api/posts.rb', line 118

def action(env)
  authorize_post!(env)
  set_app_details(env.params.data)
  set_publicity(env.params.data)
  parse_times(env.params.data)
  data = env.params[:data].slice(*whitelisted_attributes(env))
  data.public_id = env.params.data.id if env.params.data.id
  post = Model::Post.create(data)
  post.assign_permissions(env.params.data.permissions) if post.original
  env['response'] = post
  env
end