mirror of https://github.com/docusealco/docuseal
				
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							29 lines
						
					
					
						
							770 B
						
					
					
				
			
		
		
	
	
							29 lines
						
					
					
						
							770 B
						
					
					
				| # frozen_string_literal: true
 | |
| 
 | |
| module Api
 | |
|   class TemplatesCloneController < ApiBaseController
 | |
|     load_and_authorize_resource :template
 | |
| 
 | |
|     def create
 | |
|       authorize!(:manage, @template)
 | |
| 
 | |
|       cloned_template = Templates::Clone.call(
 | |
|         @template,
 | |
|         author: current_user,
 | |
|         name: params[:name],
 | |
|         external_id: params[:external_id].presence || params[:application_key],
 | |
|         folder_name: params[:folder_name]
 | |
|       )
 | |
| 
 | |
|       cloned_template.source = :api
 | |
|       cloned_template.save!
 | |
| 
 | |
|       Templates::CloneAttachments.call(template: cloned_template, original_template: @template)
 | |
| 
 | |
|       SendTemplateCreatedWebhookRequestJob.perform_later(cloned_template)
 | |
| 
 | |
|       render json: Templates::SerializeForApi.call(cloned_template)
 | |
|     end
 | |
|   end
 | |
| end
 |