mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-12 08:04:34 +08:00
Fix initialization and add download endpoint [SCI-9465]
This commit is contained in:
parent
2031286261
commit
d181465e12
4 changed files with 12 additions and 5 deletions
|
@ -1,9 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AssetSyncController < ApplicationController
|
||||
skip_before_action :authenticate_user!, only: :update
|
||||
skip_before_action :verify_authenticity_token, only: :update
|
||||
before_action :authenticate_asset_sync_token!, only: :update
|
||||
skip_before_action :authenticate_user!, only: %i(update download)
|
||||
skip_before_action :verify_authenticity_token, only: %i(update download)
|
||||
before_action :authenticate_asset_sync_token!, only: %i(update download)
|
||||
|
||||
def show
|
||||
asset = Asset.find_by(id: params[:asset_id])
|
||||
|
@ -19,6 +19,10 @@ class AssetSyncController < ApplicationController
|
|||
render json: AssetSyncTokenSerializer.new(asset_sync_token).as_json
|
||||
end
|
||||
|
||||
def download
|
||||
redirect_to @asset.file.url
|
||||
end
|
||||
|
||||
def update
|
||||
head(:conflict) and return if @asset_sync_token.conflicts?(request.headers['VersionToken'])
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class AssetSyncTokenSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def url
|
||||
object.asset.file.url
|
||||
asset_sync_download_url(asset_id: object.asset)
|
||||
end
|
||||
|
||||
def filename
|
||||
|
|
|
@ -610,7 +610,9 @@ class Extends
|
|||
www.gstatic.com/recaptcha/
|
||||
)
|
||||
|
||||
EXTERNAL_SERVICES << Constants::ASSET_SYNC_URL unless EXTERNAL_SERVICES.include?(Constants::ASSET_SYNC_URL)
|
||||
if Constants::ASSET_SYNC_URL && EXTERNAL_SERVICES.exclude?(Constants::ASSET_SYNC_URL)
|
||||
EXTERNAL_SERVICES << Constants::ASSET_SYNC_URL
|
||||
end
|
||||
|
||||
COLORED_BACKGROUND_ACTIONS = %w(
|
||||
my_modules/protocols
|
||||
|
|
|
@ -1003,6 +1003,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
get 'asset_sync/:asset_id', to: 'asset_sync#show', as: :asset_sync_show
|
||||
get 'asset_sync/:asset_id/download', to: 'asset_sync#download', as: :asset_sync_download
|
||||
put 'asset_sync', to: 'asset_sync#update'
|
||||
|
||||
post 'global_activities', to: 'global_activities#index'
|
||||
|
|
Loading…
Add table
Reference in a new issue