diff --git a/app/controllers/v1/learning_objects_controller.rb b/app/controllers/v1/learning_objects_controller.rb index 1a055f4190af4dddb66cde263cae3d06e8fe76f6..dcb60ded1201a48dbaf0d950d3a2d974e40731d5 100644 --- a/app/controllers/v1/learning_objects_controller.rb +++ b/app/controllers/v1/learning_objects_controller.rb @@ -35,7 +35,7 @@ class V1::LearningObjectsController < ApplicationController before_action :set_new_learning_object, only: [:index, :submissions] before_action :set_new_submission, only: :submit before_action :set_submission, only: :show_submission - before_action :authorize!, except: [:create, :tagging, :untagging, :download, :magnetlink] + before_action :authorize!, except: [:create, :tagging, :untagging, :download, :magnetlink, :validate] before_action :set_paper_trail_whodunnit, except: [:index, :show] def index @@ -97,6 +97,15 @@ class V1::LearningObjectsController < ApplicationController render json: LearningObject.where(magnetlink: params[:magnetlink]) end + # GET /learning_objects/validate?infohash="" + def validate + infohash = LearningObject::Attachment.find_by_infohash(params["infohash"]) + if infohash + render json: infohash, status: :ok + else + render status: :not_found + end + end private diff --git a/config/routes.rb b/config/routes.rb index c378cdbf174471af8bfe15f2df45569c26d043bf..1f36d091234713db1e3c154c267557b9f769889c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -165,6 +165,9 @@ Rails.application.routes.draw do resource :upload, module: 'learning_objects', only: :create resource :publish, module: 'learning_objects', only: :create end + collection do + get 'validate' + end resources :attachment, module: 'learning_objects', only: [:destroy, :update], on: :member end