Merge branch 'feature/backend-refactor' into feature/files-mapping

This commit is contained in:
Maksim Chegulov 2022-03-10 14:15:49 +03:00
commit ad68b7dc60
68 changed files with 1641 additions and 2638 deletions

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.202
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Web.Studio", "web\ASC.Web.Studio\ASC.Web.Studio.csproj", "{90183112-BCD6-4E16-9CA2-12231930DAB4}"
EndProject
@ -52,16 +52,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Files.Service", "produc
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.ApiSystem", "common\services\ASC.ApiSystem\ASC.ApiSystem.csproj", "{C2BB03A0-C35B-433F-96D4-3A06CBC06AD7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.UrlShortener.Svc", "common\services\ASC.UrlShortener.Svc\ASC.UrlShortener.Svc.csproj", "{04A56018-C41E-4634-A185-A13E9250C75A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Feed.Aggregator", "common\services\ASC.Feed.Aggregator\ASC.Feed.Aggregator.csproj", "{07CCC11F-76CB-448E-B15A-72E09FBB348B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Thumbnails.Svc", "common\services\ASC.Thumbnails.Svc\ASC.Thumbnails.Svc.csproj", "{1D2F61B2-B1F4-45F0-83CA-03370FD6E62C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Files.Core", "products\ASC.Files\Core\ASC.Files.Core.csproj", "{F0A39728-940D-4DBE-A37A-05D4EB57F342}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Socket.IO.Svc", "common\services\ASC.Socket.IO.Svc\ASC.Socket.IO.Svc.csproj", "{2DADEAD3-0FE9-4199-9817-41A32E6BF450}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Data.Storage.Migration", "common\services\ASC.Data.Storage.Migration\ASC.Data.Storage.Migration.csproj", "{02356BD7-7E99-457B-BEFF-090CE4DF067D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Data.Storage.Encryption", "common\services\ASC.Data.Storage.Encryption\ASC.Data.Storage.Encryption.csproj", "{17A05AE2-21C8-4C1C-B422-6AB80F13F63E}"
@ -85,8 +81,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Mail", "products\ASC.Ma
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Radicale", "common\services\ASC.Radicale\ASC.Radicale.csproj", "{74998718-3C9A-4A89-B834-14453762C60F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.SsoAuth.Svc", "common\services\ASC.SsoAuth.Svc\ASC.SsoAuth.Svc.csproj", "{6AD828EA-FBA2-4D30-B969-756B3BE78E4E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Web.HealthChecks.UI", "web\ASC.Web.HealthChecks.UI\ASC.Web.HealthChecks.UI.csproj", "{0C1A387E-0CD0-4BE8-82FC-9FCAD05BF289}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.ClearEvents", "common\services\ASC.ClearEvents\ASC.ClearEvents.csproj", "{448221A8-EABA-4200-9192-E08BF241A487}"
@ -199,10 +193,6 @@ Global
{C2BB03A0-C35B-433F-96D4-3A06CBC06AD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2BB03A0-C35B-433F-96D4-3A06CBC06AD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2BB03A0-C35B-433F-96D4-3A06CBC06AD7}.Release|Any CPU.Build.0 = Release|Any CPU
{04A56018-C41E-4634-A185-A13E9250C75A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04A56018-C41E-4634-A185-A13E9250C75A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04A56018-C41E-4634-A185-A13E9250C75A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04A56018-C41E-4634-A185-A13E9250C75A}.Release|Any CPU.Build.0 = Release|Any CPU
{07CCC11F-76CB-448E-B15A-72E09FBB348B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07CCC11F-76CB-448E-B15A-72E09FBB348B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07CCC11F-76CB-448E-B15A-72E09FBB348B}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -215,10 +205,6 @@ Global
{F0A39728-940D-4DBE-A37A-05D4EB57F342}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0A39728-940D-4DBE-A37A-05D4EB57F342}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0A39728-940D-4DBE-A37A-05D4EB57F342}.Release|Any CPU.Build.0 = Release|Any CPU
{2DADEAD3-0FE9-4199-9817-41A32E6BF450}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2DADEAD3-0FE9-4199-9817-41A32E6BF450}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DADEAD3-0FE9-4199-9817-41A32E6BF450}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DADEAD3-0FE9-4199-9817-41A32E6BF450}.Release|Any CPU.Build.0 = Release|Any CPU
{02356BD7-7E99-457B-BEFF-090CE4DF067D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02356BD7-7E99-457B-BEFF-090CE4DF067D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02356BD7-7E99-457B-BEFF-090CE4DF067D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -255,10 +241,6 @@ Global
{74998718-3C9A-4A89-B834-14453762C60F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74998718-3C9A-4A89-B834-14453762C60F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74998718-3C9A-4A89-B834-14453762C60F}.Release|Any CPU.Build.0 = Release|Any CPU
{6AD828EA-FBA2-4D30-B969-756B3BE78E4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AD828EA-FBA2-4D30-B969-756B3BE78E4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AD828EA-FBA2-4D30-B969-756B3BE78E4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AD828EA-FBA2-4D30-B969-756B3BE78E4E}.Release|Any CPU.Build.0 = Release|Any CPU
{0C1A387E-0CD0-4BE8-82FC-9FCAD05BF289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C1A387E-0CD0-4BE8-82FC-9FCAD05BF289}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C1A387E-0CD0-4BE8-82FC-9FCAD05BF289}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@ -22,10 +22,8 @@
"common\\services\\ASC.ElasticSearch\\ASC.ElasticSearch.csproj",
"common\\services\\ASC.Feed.Aggregator\\ASC.Feed.Aggregator.csproj",
"common\\services\\ASC.Notify\\ASC.Notify.csproj",
"common\\services\\ASC.Socket.IO.Svc\\ASC.Socket.IO.Svc.csproj",
"common\\services\\ASC.Studio.Notify\\ASC.Studio.Notify.csproj",
"common\\services\\ASC.TelegramService\\ASC.TelegramService.csproj",
"common\\services\\ASC.UrlShortener.Svc\\ASC.UrlShortener.Svc.csproj",
"common\\services\\ASC.Webhooks.Service\\ASC.Webhooks.Service.csproj",
"products\\ASC.Files\\Core\\ASC.Files.Core.csproj",
"products\\ASC.Files\\Server\\ASC.Files.csproj",

View File

@ -9,6 +9,9 @@ if %errorlevel% == 0 (
echo service create "Onlyoffice%%~nf"
call sc create "Onlyoffice%%~nf" displayname= "ONLYOFFICE %%~nf" binPath= "!servicepath!"
)
for /R "build\run\" %%f in (*.xml) do (
call build\install\win\WinSW3.0.0.exe install %%f
)
)
echo.

View File

@ -9,6 +9,10 @@ if %errorlevel% == 0 (
call sc stop "Onlyoffice%%~nf"
call sc delete "Onlyoffice%%~nf"
)
for /R "run\" %%f in (*.xml) do (
call install\win\WinSW3.0.0.exe stop %%f
call install\win\WinSW3.0.0.exe uninstall %%f
)
)
echo.

Binary file not shown.

View File

@ -1,4 +0,0 @@
@echo off
PUSHD %~dp0..\..
set servicepath=%cd%\common\services\ASC.Socket.IO.Svc\bin\Debug\ASC.Socket.IO.Svc.exe urls=http://0.0.0.0:5028 $STORAGE_ROOT=%cd%\Data log:dir=%cd%\Logs log:name=socketio pathToConf=%cd%\config core:products:folder=%cd%\products core:products:subfolder=server socket:path=%cd%\common\ASC.Socket.IO

10
build/run/SocketIO.xml Normal file
View File

@ -0,0 +1,10 @@
<service>
<id>OnlyofficeSocketIO</id>
<name>ONLYOFFICE SocketIO</name>
<startmode>manual</startmode>
<executable>node</executable>
<arguments>../../common/ASC.Socket.IO/server.js</arguments>
<log mode="none"/>
<delayedAutoStart>true</delayedAutoStart>
<onfailure action="restart" delay="5 sec" />
</service>

10
build/run/SsoAuth.xml Normal file
View File

@ -0,0 +1,10 @@
<service>
<id>OnlyofficeSsoAuth</id>
<name>ONLYOFFICE SsoAuth</name>
<startmode>manual</startmode>
<executable>node</executable>
<arguments>../../common/ASC.SSoAuth/app.js</arguments>
<log mode="none"/>
<delayedAutoStart>true</delayedAutoStart>
<onfailure action="restart" delay="5 sec" />
</service>

View File

@ -1,4 +0,0 @@
@echo off
PUSHD %~dp0..\..
set servicepath=%cd%\common\services\ASC.UrlShortener.Svc\bin\Debug\ASC.UrlShortener.Svc.exe urls=http://0.0.0.0:5029 $STORAGE_ROOT=%cd%\Data log:dir=%cd%\Logs log:name=urlshortener pathToConf=%cd%\config core:products:folder=%cd%\products core:products:subfolder=server

View File

@ -0,0 +1,10 @@
<service>
<id>OnlyofficeUrlShortenerService</id>
<name>ONLYOFFICE UrlShortenerService</name>
<startmode>manual</startmode>
<executable>node</executable>
<arguments>../../common/ASC.UrlShortener/index.js</arguments>
<log mode="none"/>
<delayedAutoStart>true</delayedAutoStart>
<onfailure action="restart" delay="5 sec" />
</service>

View File

@ -0,0 +1 @@
yarn install --cwd %~dp0../../common/ASC.SsoAuth/ --frozen-lockfile

View File

@ -4,9 +4,17 @@ require("winston-daily-rotate-file");
const path = require("path");
const config = require("../config");
const fs = require("fs");
const fileName =
config.get("logPath") ||
path.join(__dirname, "..", "..", "..", "Logs", "socket-io.%DATE%.log");
let logpath = config.get("logPath");
if(logpath != null)
{
if(!path.isAbsolute(logpath))
{
logpath = path.join(__dirname, "..", logpath);
}
}
const fileName = logpath ? path.join(logpath, "socket-io.%DATE%.log") : path.join(__dirname, "..", "..", "..", "Logs", "socket-io.%DATE%.log");
const dirName = path.dirname(fileName);
if (!fs.existsSync(dirName)) {

View File

@ -3,7 +3,7 @@
crypto = require("crypto"),
moment = require("moment");
const skey = config.get("core.machinekey");
const skey = config.get("core").machinekey;
const trustInterval = 5 * 60 * 1000;
function check(token) {

View File

@ -1,4 +1,5 @@
const portalInternalUrl = require("../config").get("portal.internal.url");
const conf = require("../config");
const portalInternalUrl = conf.get("core")["base-domain"] === "localhost" ? "http://localhost" : "";
module.exports = (req) => {
if (portalInternalUrl) return portalInternalUrl;

View File

@ -1,13 +1,5 @@
{
"port": 9899,
"core.machinekey": "1123askdasjklasbnd",
"portal.internal.url": "",
"redis": {
"enabled": false,
"host": "localhost",
"port": 6379,
"db": 0,
"pass": "",
"ttl": 84600
}
"appsettings": "../../../config",
"environment": "Development"
}

View File

@ -1,8 +1,49 @@
const nconf = require('nconf');
const path = require('path');
const fs = require("fs");
nconf.argv()
.env()
.file({ file: path.join(__dirname, 'config.json') });
.file("config", path.join(__dirname, 'config.json'));
getAndSaveAppsettings();
module.exports = nconf;
function getAndSaveAppsettings(){
var appsettings = nconf.get("appsettings");
if(!path.isAbsolute(appsettings)){
appsettings =path.join(__dirname, appsettings);
}
var env = nconf.get("environment");
var valueEnv = nconf.get(env);
var fileWithEnv = path.join(appsettings, 'appsettings.' + valueEnv + '.json');
if(fs.existsSync(fileWithEnv)){
nconf.file("appsettings", fileWithEnv);
}
else{
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
}
nconf.file("appsettingsServices", path.join(appsettings, 'appsettings.services.json'));
var redisWithEnv = path.join(appsettings, 'redis.' + valueEnv + '.json');
if(fs.existsSync(fileWithEnv)){
nconf.file("redis", redisWithEnv);
}
else{
nconf.file("redis", path.join(__dirname, appsettings, 'redis.json'));
}
var redis = nconf.get("Redis");
if(redis != null)
{
redis.host = redis.Hosts[0].Host;
redis.port = redis.Hosts[0].Port;
redis.connect_timeout = redis.ConnectTimeout;
redis.db = redis.Database;
nconf.set("Redis", redis);
}
}

View File

@ -20,14 +20,14 @@ winston.stream = {
const port = config.get("port") || 9899;
const app = express();
const secret = config.get("core.machinekey") + new Date().getTime();
const secret = config.get("core").machinekey + new Date().getTime();
const secretCookieParser = cookieParser(secret);
const baseCookieParser = cookieParser();
const redisOptions = config.get("redis");
const redisOptions = config.get("Redis");
let store;
if (redisOptions?.enabled) {
if (redisOptions != null) {
const redisClient = redis.createClient(redisOptions);
store = new RedisStore({ client: redisClient });
} else {

View File

@ -36,14 +36,22 @@ const fs = require("fs"),
require('winston-daily-rotate-file');
const app = express();
let logDir = config["logPath"] ? config["logPath"] : config.app.logDir;
// ensure log directory exists
fs.existsSync(logDir) || fs.mkdirSync(logDir);
let logpath = config["logPath"];
if(logpath != null)
{
if(!path.isAbsolute(logpath))
{
logpath = path.join(__dirname, logpath);
}
// ensure log directory exists
fs.existsSync(logpath) || fs.mkdirSync(logpath);
}
let transports = [];
if (config.logger.file) {
logDir = config["logPath"] ? logDir : (config.app.logDir[0] === "." ? path.join(__dirname, config.app.logDir) : config.app.logDir);
let logDir = logpath ? logpath : (config.app.logDir[0] === "." ? path.join(__dirname, config.app.logDir) : config.app.logDir);
config.logger.file.filename = path.join(logDir, config.app.logName);
transports.push(new (winston.transports.DailyRotateFile)(config.logger.file));
}
@ -77,7 +85,7 @@ app.use(favicon(path.join(__dirname, "public", "favicon.ico")))
{
resave: true,
saveUninitialized: true,
secret: config["core.machinekey"] ? config["core.machinekey"] : config.app.machinekey
secret: config["core"].machinekey ? config["core"].machinekey : config.app.machinekey
}))
.use(cors());

View File

@ -27,7 +27,7 @@ var Coder = function() {
return undefined;
const jsonStr = JSON.stringify(data);
const dataEncoded = hash.encode(jsonStr, config["core.machinekey"] ? config["core.machinekey"] : config.app.machinekey);
const dataEncoded = hash.encode(jsonStr, config["machinekey"] ? config["core"].machinekey : config.app.machinekey);
return dataEncoded;
},
@ -36,7 +36,7 @@ var Coder = function() {
if (!data && typeof (data) !== "string")
return undefined;
const jsonStr = hash.decode(data, config["core.machinekey"] ? config["core.machinekey"] : config.app.machinekey);
const jsonStr = hash.decode(data, config["core"].machinekey ? config["core"].machinekey : config.app.machinekey);
const dataDecoded = JSON.parse(jsonStr);
return dataDecoded;

View File

@ -2,8 +2,8 @@
"app": {
"name": "Onlyoffice Single Sign-On handler",
"port": 9834,
"machinekey": "1123askdasjklasbnd",
"logDir": "./logs",
"appsettings": "../../../config",
"environment": "Development",
"logName": "web.sso.%DATE%.log",
"contact": {
"type": "support",

View File

@ -21,10 +21,31 @@ const nconf = require("nconf"),
nconf.argv()
.env()
.file({ file: path.join(__dirname, "config.json") });
.file("config",path.join(__dirname, "config.json"));
if (nconf.get("NODE_ENV") !== "development" && fs.existsSync(path.join(__dirname, nconf.get("NODE_ENV") + ".json"))) {
nconf.file({ file: path.join(__dirname, nconf.get("NODE_ENV") + ".json") });
nconf.file("config", path.join(__dirname, nconf.get("NODE_ENV") + ".json"));
}
getAndSaveAppsettings();
module.exports = nconf;
function getAndSaveAppsettings(){
var appsettings = nconf.get("app").appsettings;
if(!path.isAbsolute(appsettings)){
appsettings =path.join(__dirname, appsettings);
}
var env = nconf.get("app").environment;
var valueEnv = nconf.get(env);
var fileWithEnv = path.join(appsettings, 'appsettings.' + valueEnv + '.json');
if(fs.existsSync(fileWithEnv)){
nconf.file("appsettings", fileWithEnv);
}
else{
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
}
nconf.file("appsettingsServices", path.join(appsettings, 'appsettings.services.json'));
}

View File

@ -2,8 +2,8 @@
"app": {
"name": "Onlyoffice Single Sign-On handler",
"port": 9834,
"machinekey": "Vskoproizvolny Salt par Chivreski",
"logDir": "/var/log/onlyoffice/",
"appsettings": "../../../config",
"environment": "Development",
"logName": "web.sso.%DATE%.log",
"logSamlData": false,
"portal": {

View File

@ -30,7 +30,16 @@ require('winston-daily-rotate-file');
const path = require('path');
const config = require('../config');
const fs = require('fs');
const fileName = config.get("logPath") || path.join(__dirname, "..", "Logs", "web.shorturl.%DATE%.log");
let logpath = config.get("logPath");
if(logpath != null)
{
if(!path.isAbsolute(logpath))
{
logpath = path.join(__dirname, "..", logpath);
}
}
const fileName = logpath ? path.join(logpath, "web.shorturl.%DATE%.log") : path.join(__dirname, "..", "Logs", "web.shorturl.%DATE%.log");
const dirName = path.dirname(fileName);
if (!fs.existsSync(dirName)) {

View File

@ -1,10 +1,5 @@
{
"port": 17100,
"core.machinekey": "1123askdasjklasbnd",
"sql": {
"host": "127.0.0.1",
"user": "root",
"password": "111111",
"database": "onlyoffice"
}
"port": 9999,
"appsettings": "../../../config",
"environment": "Development"
}

View File

@ -26,9 +26,49 @@
const nconf = require("nconf");
const path = require("path");
const fs = require("fs");
nconf.argv()
.env()
.file({ file: path.join(__dirname, 'config.json') });
.file("config", path.join(__dirname, 'config.json') );
module.exports = nconf;
getAndSaveAppsettings();
getAndSaveSql();
module.exports = nconf;
function getAndSaveAppsettings(){
var appsettings = nconf.get("appsettings");
if(!path.isAbsolute(appsettings)){
appsettings =path.join(__dirname, appsettings);
}
var env = nconf.get("environment");
var valueEnv = nconf.get(env);
var fileWithEnv = path.join(appsettings, 'appsettings.' + valueEnv + '.json');
if(fs.existsSync(fileWithEnv)){
nconf.file("appsettings", fileWithEnv);
}
else{
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
}
nconf.file("appsettingsServices", path.join(appsettings, 'appsettings.services.json'));
}
function getAndSaveSql(){
var sql = new Map();
var connetionString = nconf.get("ConnectionStrings").default.connectionString;
var conf = connetionString.split(';');
for(let i = 0; i < conf.length; i++){
var splited = conf[i].split('=');
if(splited.Length < 2) continue;
if(splited[0] != null){
sql[splited[0]] = splited[1];
}
}
nconf.set("sql", sql);
}

View File

@ -38,8 +38,6 @@ const query = require('./app/sqlConsts');
const config = require('./config');
const co = require('co');
var app = express();
app.use(cookieParser());

View File

@ -29,7 +29,7 @@ const
crypto = require('crypto'),
moment = require('moment');
const skey = config.get("core.machinekey");
const skey = config.get("core").machinekey;
const trustInterval = 5 * 60 * 1000;
function check(req) {

View File

@ -1,37 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<GenerateMvcApplicationPartsAssemblyAttributes>false</GenerateMvcApplicationPartsAssemblyAttributes>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
<PackageReference Include="StackExchange.Redis.Extensions.AspNetCore" Version="7.2.1" />
<PackageReference Include="StackExchange.Redis.Extensions.Newtonsoft" Version="7.2.1" />
<PackageReference Include="SocketIOClient" Version="3.0.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ASC.Api.Core\ASC.Api.Core.csproj" />
<ProjectReference Include="..\..\ASC.Common\ASC.Common.csproj" />
<ProjectReference Include="..\..\ASC.Core.Common\ASC.Core.Common.csproj" />
<ProjectReference Include="..\..\ASC.Data.Encryption\ASC.Data.Encryption.csproj" />
</ItemGroup>
</Project>

View File

@ -1,131 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2020
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.DependencyInjection;
using ASC.Common.Utils;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using StackExchange.Redis.Extensions.Core.Configuration;
using StackExchange.Redis.Extensions.Newtonsoft;
namespace ASC.Socket.IO.Svc
{
public class Program
{
public async static Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSystemd()
.UseWindowsService()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<BaseWorkerStartup>())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
config
.AddJsonFile("appsettings.json")
.AddJsonFile("storage.json")
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env}.json", true)
.AddJsonFile("redis.json")
.AddJsonFile($"redis.{env}.json", true)
.AddJsonFile("socket.json")
.AddJsonFile($"appsettings.{env}.json", true)
.AddJsonFile($"socket.{env}.json", true)
.AddEnvironmentVariables()
.AddCommandLine(args)
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
);
})
.ConfigureServices((hostContext, services) =>
{
services.AddMemoryCache();
services.AddHttpClient();
var diHelper = new DIHelper(services);
var redisConfiguration = hostContext.Configuration.GetSection("Redis").Get<RedisConfiguration>();
var kafkaConfiguration = hostContext.Configuration.GetSection("kafka").Get<KafkaSettings>();
if (kafkaConfiguration != null)
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCacheNotify<>));
}
else if (redisConfiguration != null)
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCacheNotify<>));
services.AddStackExchangeRedisExtensions<NewtonsoftSerializer>(redisConfiguration);
}
else
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(MemoryCacheNotify<>));
}
diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
services.AddHostedService<SocketServiceLauncher>();
diHelper.TryAdd<SocketServiceLauncher>();
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, false, false);
})
.ConfigureNLogLogging();
}
}

View File

@ -1,29 +0,0 @@
{
"profiles": {
"Kestrel WebServer": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"$STORAGE_ROOT": "../../../Data",
"log__name": "socket",
"log__dir": "../../../Logs",
"core__products__folder": "../../../products",
"ASPNETCORE_URLS": "http://localhost:5028",
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WSL 2 : Ubuntu 20.04": {
"commandName": "WSL2",
"launchBrowser": false,
"environmentVariables": {
"$STORAGE_ROOT": "../../../Data",
"log__name": "socket",
"log__dir": "../../../Logs",
"core__products__folder": "../../../products",
"ASPNETCORE_URLS": "http://localhost:5028",
"ASPNETCORE_ENVIRONMENT": "Development"
},
"distributionName": "Ubuntu-20.04"
}
}
}

View File

@ -1,287 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Utils;
using ASC.Core;
using ASC.Core.Notify.Signalr;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using SocketIOClient;
namespace ASC.Socket.IO.Svc
{
[Singletone]
public class SocketServiceLauncher : IHostedService
{
private int PingInterval { get; set; }
private int ReconnectAttempts { get; set; }
private Process Proc { get; set; }
private ProcessStartInfo StartInfo { get; set; }
private SocketIO SocketClient { get; set; }
private CancellationTokenSource CancellationTokenSource { get; set; }
private ILog Logger { get; set; }
private string LogDir { get; set; }
private IConfiguration Configuration { get; set; }
private ConfigurationExtension ConfigurationExtension { get; }
private CoreBaseSettings CoreBaseSettings { get; set; }
private SignalrServiceClient SignalrServiceClient { get; set; }
private IHostEnvironment HostEnvironment { get; set; }
public SocketServiceLauncher(
IOptionsMonitor<ILog> options,
IConfiguration configuration,
ConfigurationExtension configurationExtension,
CoreBaseSettings coreBaseSettings,
IOptionsSnapshot<SignalrServiceClient> signalrServiceClient,
IHostEnvironment hostEnvironment)
{
Logger = options.CurrentValue;
Configuration = configuration;
ConfigurationExtension = configurationExtension;
CoreBaseSettings = coreBaseSettings;
SignalrServiceClient = signalrServiceClient.Value;
HostEnvironment = hostEnvironment;
}
public Task StartAsync(CancellationToken cancellationToken)
{
try
{
var settings = ConfigurationExtension.GetSetting<SocketSettings>("socket");
var path = settings.Path;
if (!Path.IsPathRooted(settings.Path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, settings.Path));
}
PingInterval = settings.PingInterval.GetValueOrDefault(10000);
ReconnectAttempts = settings.ReconnectAttempts.GetValueOrDefault(5);
StartInfo = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
FileName = "node",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = $"\"{Path.Combine(path, "server.js")}\"",
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory
};
StartInfo.EnvironmentVariables.Add("core.machinekey", Configuration["core:machinekey"]);
StartInfo.EnvironmentVariables.Add("port", settings.Port);
if (!string.IsNullOrEmpty(settings.RedisHost) && !string.IsNullOrEmpty(settings.RedisPort))
{
StartInfo.EnvironmentVariables.Add("redis:host", settings.RedisHost);
StartInfo.EnvironmentVariables.Add("redis:port", settings.RedisPort);
}
if (CoreBaseSettings.Standalone)
{
StartInfo.EnvironmentVariables.Add("portal.internal.url", "http://localhost");
}
LogDir = Logger.LogDirectory;
StartInfo.EnvironmentVariables.Add("logPath", CrossPlatform.PathCombine(LogDir, "socket-io.%DATE%.log"));
StartNode();
}
catch (Exception e)
{
Logger.Error(e);
}
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
StopPing();
StopNode();
return Task.CompletedTask;
}
private void StartNode()
{
StopNode();
Proc = Process.Start(StartInfo);
CancellationTokenSource = new CancellationTokenSource();
var task = new Task(StartPing, CancellationTokenSource.Token, TaskCreationOptions.LongRunning);
task.Start(TaskScheduler.Default);
}
private void StopNode()
{
try
{
if (Proc != null && !Proc.HasExited)
{
Proc.Kill();
if (!Proc.WaitForExit(10000)) /* wait 10 seconds */
{
Logger.Warn("The process does not wait for completion.");
}
Proc.Close();
Proc.Dispose();
Proc = null;
}
}
catch (Exception e)
{
Logger.Error("SocketIO failed stop", e);
}
}
private async void StartPing()
{
try
{
var settings = ConfigurationExtension.GetSetting<SocketSettings>("socket");
var uri = new Uri($"ws://localhost:{settings.Port}"); //TODO: replace localhost to variable
var token = SignalrServiceClient.CreateAuthToken();
SocketClient = new SocketIO(uri, new SocketIOOptions
{
ExtraHeaders = new Dictionary<string, string>
{
{ "Authorization", token }
},
ConnectionTimeout = TimeSpan.FromSeconds(30),
Reconnection = true,
ReconnectionAttempts = ReconnectAttempts,
EIO = 4,
Path = "/socket.io",
Transport = SocketIOClient.Transport.TransportProtocol.WebSocket,
RandomizationFactor = 0.5
});
SocketClient.OnConnected += IOClient_OnConnected;
SocketClient.OnDisconnected += IOClient_OnDisconnected;
SocketClient.OnReconnectAttempt += IOClient_OnReconnectAttempt;
SocketClient.OnError += IOClient_OnError;
SocketClient.On("pong", response =>
{
Logger.Debug($"pong (server) at {response}");
});
Logger.Debug("Try to connect...");
await SocketClient.ConnectAsync();
}
catch (Exception ex)
{
if (CancellationTokenSource.IsCancellationRequested) return;
Logger.Error(ex.Message);
StopNode();
Process.GetCurrentProcess().Kill();
}
}
private async void IOClient_OnConnected(object sender, EventArgs e)
{
var socket = sender as SocketIO;
Logger.Info($"Socket_OnConnected Socket.Id: {socket.Id}");
while (SocketClient.Connected)
{
if (CancellationTokenSource.IsCancellationRequested) return;
await Task.Delay(PingInterval);
if (!SocketClient.Connected)
break;
await SocketClient.EmitAsync("ping", DateTime.UtcNow.ToString());
}
}
private void IOClient_OnDisconnected(object sender, string e)
{
Logger.Debug($"Socket_OnDisconnected {e}");
}
private void IOClient_OnReconnectAttempt(object sender, int attempt)
{
Logger.Debug($"Try to reconnect... attempt {attempt}");
if (attempt >= ReconnectAttempts)
{
StopPing();
Process.GetCurrentProcess().Kill();
}
}
private void IOClient_OnError(object sender, string e)
{
Logger.Error($"IOClient_OnError {e}");
}
private void StopPing()
{
try
{
if (SocketClient != null)
{
SocketClient.OnConnected -= IOClient_OnConnected;
SocketClient.OnDisconnected -= IOClient_OnDisconnected;
SocketClient.OnReconnectAttempt -= IOClient_OnReconnectAttempt;
SocketClient.OnError -= IOClient_OnError;
SocketClient.Dispose();
SocketClient = null;
}
CancellationTokenSource.Cancel();
}
catch (Exception ex)
{
Logger.Error($"Ping failed stop {ex.Message}");
StopNode();
Process.GetCurrentProcess().Kill();
}
}
}
}

View File

@ -1,13 +0,0 @@
namespace ASC.Socket.IO.Svc
{
public class SocketSettings
{
public string Path { get; set; }
public string Port { get; set; }
public string RedisHost { get; set; }
public string RedisPort { get; set; }
public int? PingInterval { get; set; }
public int? ReconnectAttempts { get; set; }
}
}

View File

@ -1,3 +0,0 @@
{
"pathToConf": "..\\..\\..\\config"
}

View File

@ -1,34 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<GenerateMvcApplicationPartsAssemblyAttributes>false</GenerateMvcApplicationPartsAssemblyAttributes>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
<PackageReference Include="StackExchange.Redis.Extensions.AspNetCore" Version="7.2.1" />
<PackageReference Include="StackExchange.Redis.Extensions.Newtonsoft" Version="7.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ASC.Api.Core\ASC.Api.Core.csproj" />
<ProjectReference Include="..\..\ASC.Common\ASC.Common.csproj" />
<ProjectReference Include="..\..\ASC.Data.Encryption\ASC.Data.Encryption.csproj" />
</ItemGroup>
</Project>

View File

@ -1,119 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Utils;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
namespace ASC.SsoAuth.Svc
{
[Singletone]
public class Launcher : IHostedService
{
private ProcessStartInfo startInfo;
private Process proc;
private string LogDir { get; set; }
private ILog Logger { get; set; }
private IConfiguration Configuration { get; }
private ConfigurationExtension ConfigurationExtension { get; }
private IHostEnvironment HostEnvironment { get; }
public Launcher(
IOptionsMonitor<ILog> options,
IConfiguration configuration,
ConfigurationExtension configurationExtension,
IHostEnvironment hostEnvironment)
{
Logger = options.CurrentValue;
Configuration = configuration;
ConfigurationExtension = configurationExtension;
HostEnvironment = hostEnvironment;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
try
{
var cfg = ConfigurationExtension.GetSetting<SsoAuthSettings>("ssoauth");
startInfo = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
FileName = "node",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = $"\"{Path.GetFullPath(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, cfg.Path, "app.js"))}\"",
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory
};
startInfo.EnvironmentVariables.Add("core.machinekey", Configuration["core:machinekey"]);
startInfo.EnvironmentVariables.Add("port", cfg.Port);
LogDir = Logger.LogDirectory;
startInfo.EnvironmentVariables.Add("logPath", LogDir);
await StartNode(cancellationToken);
}
catch (Exception e)
{
Logger.Error("Start", e);
}
}
public Task StopAsync(CancellationToken cancellationToken)
{
try
{
if (proc != null && !proc.HasExited)
{
proc.Kill();
proc.WaitForExit(10000);
proc.Close();
proc.Dispose();
proc = null;
}
}
catch (Exception e)
{
Logger.Error("Stop", e);
}
return Task.CompletedTask;
}
private async Task StartNode(CancellationToken cancellationToken)
{
await StopAsync(cancellationToken);
proc = Process.Start(startInfo);
}
}
}

View File

@ -1,130 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2020
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.DependencyInjection;
using ASC.Common.Utils;
using ASC.SsoAuth.Svc;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using StackExchange.Redis.Extensions.Core.Configuration;
using StackExchange.Redis.Extensions.Newtonsoft;
namespace ASC.Socket.IO.Svc
{
public class Program
{
public async static Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSystemd()
.UseWindowsService()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<BaseWorkerStartup>())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
config
.AddJsonFile("appsettings.json")
.AddJsonFile("storage.json")
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env}.json", true)
.AddJsonFile("redis.json")
.AddJsonFile($"redis.{env}.json", true)
.AddJsonFile("ssoauth.json")
.AddJsonFile($"appsettings.{env}.json", true)
.AddJsonFile($"ssoauth.{env}.json", true)
.AddEnvironmentVariables()
.AddCommandLine(args)
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
);
})
.ConfigureServices((hostContext, services) =>
{
services.AddMemoryCache();
var diHelper = new DIHelper(services);
var redisConfiguration = hostContext.Configuration.GetSection("Redis").Get<RedisConfiguration>();
var kafkaConfiguration = hostContext.Configuration.GetSection("kafka").Get<KafkaSettings>();
if (kafkaConfiguration != null)
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCache<>));
}
else if (redisConfiguration != null)
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(RedisCache<>));
services.AddStackExchangeRedisExtensions<NewtonsoftSerializer>(redisConfiguration);
}
else
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(MemoryCacheNotify<>));
}
diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
services.AddHostedService<Launcher>();
diHelper.TryAdd<Launcher>();
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, false, false);
})
.ConfigureNLogLogging();
}
}

View File

@ -1,29 +0,0 @@
{
"profiles": {
"Kestrel WebServer": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"$STORAGE_ROOT": "../../../Data",
"log__name": "sso",
"log__dir": "../../../Logs",
"core__products__folder": "../../../products",
"ASPNETCORE_URLS": "http://localhost:5024",
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WSL 2 : Ubuntu 20.04": {
"commandName": "WSL2",
"launchBrowser": false,
"environmentVariables": {
"$STORAGE_ROOT": "../../../Data",
"log__name": "sso",
"log__dir": "../../../Logs",
"core__products__folder": "../../../products",
"ASPNETCORE_URLS": "http://localhost:5024",
"ASPNETCORE_ENVIRONMENT": "Development"
},
"distributionName": "Ubuntu-20.04"
}
}
}

View File

@ -1,24 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
namespace ASC.SsoAuth.Svc
{
public class SsoAuthSettings
{
public string Path { get; set; }
public string Port { get; set; }
}
}

View File

@ -1,3 +0,0 @@
{
"pathToConf": "..\\..\\..\\config"
}

View File

@ -1,35 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<GenerateMvcApplicationPartsAssemblyAttributes>false</GenerateMvcApplicationPartsAssemblyAttributes>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<NoWarn>1701;1702;NU1701</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
<PackageReference Include="StackExchange.Redis.Extensions.AspNetCore" Version="7.2.1" />
<PackageReference Include="StackExchange.Redis.Extensions.Newtonsoft" Version="7.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ASC.Api.Core\ASC.Api.Core.csproj" />
<ProjectReference Include="..\..\ASC.Common\ASC.Common.csproj" />
<ProjectReference Include="..\..\ASC.Data.Encryption\ASC.Data.Encryption.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

View File

@ -1,16 +0,0 @@
global using System.Diagnostics;
global using ASC.Api.Core;
global using ASC.Common;
global using ASC.Common.DependencyInjection;
global using ASC.Common.Logging;
global using ASC.Common.Module;
global using ASC.Common.Utils;
global using Autofac;
global using Autofac.Extensions.DependencyInjection;
global using Microsoft.Extensions.Options;
global using StackExchange.Redis.Extensions.Core.Configuration;
global using StackExchange.Redis.Extensions.Newtonsoft;

View File

@ -1,91 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2020
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
namespace ASC.UrlShortener.Svc
{
public static class Program
{
public async static Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSystemd()
.UseWindowsService()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<BaseWorkerStartup>())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
config.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env}.json", true)
.AddJsonFile($"urlshortener.{env}.json", true)
.AddJsonFile("storage.json")
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env}.json", true)
.AddJsonFile("redis.json")
.AddJsonFile($"redis.{env}.json", true)
.AddEnvironmentVariables()
.AddCommandLine(args)
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
);
})
.ConfigureServices((hostContext, services) =>
{
services.AddMemoryCache();
var diHelper = new DIHelper(services);
services.AddHostedService<UrlShortenerServiceLauncher>();
diHelper.TryAdd<UrlShortenerServiceLauncher>();
services.AddStackExchangeRedisExtensions<NewtonsoftSerializer>(hostContext.Configuration.GetSection("Redis").Get<RedisConfiguration>());
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, false, false);
})
.ConfigureNLogLogging();
}
}

View File

@ -1,29 +0,0 @@
{
"profiles": {
"Kestrel WebServer": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"$STORAGE_ROOT": "../../../Data",
"log__name": "urlshortener",
"log__dir": "../../../Logs",
"core__products__folder": "../../../products",
"ASPNETCORE_URLS": "http://localhost:5029",
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WSL 2 : Ubuntu 20.04": {
"commandName": "WSL2",
"launchBrowser": false,
"environmentVariables": {
"$STORAGE_ROOT": "../../../Data",
"log__name": "urlshortener",
"log__dir": "../../../Logs",
"core__products__folder": "../../../products",
"ASPNETCORE_URLS": "http://localhost:5029",
"ASPNETCORE_ENVIRONMENT": "Development"
},
"distributionName": "Ubuntu-20.04"
}
}
}

View File

@ -1,137 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2020
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
namespace ASC.UrlShortener.Svc
{
[Singletone]
public class UrlShortenerService : IServiceController
{
private readonly ILog log;
private readonly IConfiguration configuration;
private readonly IHostEnvironment hostEnvironment;
private readonly ConfigurationExtension configurationExtension;
private Process process;
public UrlShortenerService(
IOptionsMonitor<ILog> options,
IConfiguration config,
IHostEnvironment host,
ConfigurationExtension configurationExtension)
{
log = options.Get("ASC.UrlShortener.Svc");
configuration = config;
hostEnvironment = host;
this.configurationExtension = configurationExtension;
}
public void Start()
{
try
{
Stop();
var processStartInfo = GetProcessStartInfo();
process = Process.Start(processStartInfo);
}
catch (Exception e)
{
log.Fatal("Start", e);
}
}
public void Stop()
{
try
{
if (process == null || process.HasExited)
{
return;
}
process.Kill();
process.WaitForExit(10000);
process.Close();
process.Dispose();
process = null;
}
catch (Exception e)
{
log.Error("stop", e);
}
}
private ProcessStartInfo GetProcessStartInfo()
{
var path = configuration["urlshortener:path"] ?? "../../ASC.UrlShortener/index.js";
var port = configuration["urlshortener:port"] ?? "9999";
var startInfo = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
FileName = "node",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = $"\"{Path.GetFullPath(CrossPlatform.PathCombine(hostEnvironment.ContentRootPath, path))}\"",
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory
};
startInfo.EnvironmentVariables.Add("core.machinekey", configuration["core:machinekey"]);
startInfo.EnvironmentVariables.Add("port", port);
var conString = configurationExtension.GetConnectionStrings()["default"].ConnectionString;
var dict = new Dictionary<string, string>
{
{"Server", "host"},
{"Database", "database"},
{"User ID", "user"},
{"Password", "password"}
};
foreach (var conf in conString.Split(';'))
{
var splited = conf.Split('=');
if (splited.Length < 2) continue;
if (dict.TryGetValue(splited[0], out var value))
{
startInfo.EnvironmentVariables.Add("sql:" + dict[value], splited[1]);
}
}
startInfo.EnvironmentVariables.Add("logPath", CrossPlatform.PathCombine(log.LogDirectory, "web.urlshortener.log"));
return startInfo;
}
}
}

View File

@ -1,52 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2020
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
namespace ASC.UrlShortener.Svc
{
[Singletone]
public class UrlShortenerServiceLauncher : IHostedService
{
private UrlShortenerService UrlShortenerService { get; }
public UrlShortenerServiceLauncher(UrlShortenerService urlShortenerService)
{
UrlShortenerService = urlShortenerService;
}
public Task StartAsync(CancellationToken cancellationToken)
{
UrlShortenerService.Start();
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
UrlShortenerService.Stop();
return Task.CompletedTask;
}
}
}

View File

@ -1,3 +0,0 @@
{
"pathToConf": "..\\..\\..\\config"
}

View File

@ -5,9 +5,5 @@
"subfolder": "Server"
}
},
"urlshortener": {
"path": "../../ASC.UrlShortener/index.js",
"port": "9999",
"log": "../../../Logs/urlshortener.log"
}
"logPath": "../../Logs/"
}

View File

@ -54,9 +54,11 @@ global using ASC.FederatedLogin;
global using ASC.FederatedLogin.Helpers;
global using ASC.FederatedLogin.LoginProviders;
global using ASC.FederatedLogin.Profile;
global using ASC.Files.Core;
global using ASC.Files.Core;
global using ASC.Files.Core.ApiModels.RequestDto;
global using ASC.Files.Core.ApiModels.ResponseDto;
global using ASC.Files.Core.Data;
global using ASC.Files.Core.EF;
global using ASC.Files.Core.EF;
global using ASC.Files.Core.Mapping;
global using ASC.Files.Core.Core.Entries;
global using ASC.Files.Core.ApiModels.RequestDto;

View File

@ -6,12 +6,4 @@
[ControllerName("files")]
public abstract class ApiControllerBase : ControllerBase
{
protected readonly FilesControllerHelper<int> _filesControllerHelperInt;
protected readonly FilesControllerHelper<string> _filesControllerHelperString;
public ApiControllerBase(FilesControllerHelper<int> filesControllerHelperInt, FilesControllerHelper<string> filesControllerHelperString)
{
_filesControllerHelperInt = filesControllerHelperInt;
_filesControllerHelperString = filesControllerHelperString;
}
}

View File

@ -6,22 +6,23 @@ public class EditorController : ApiControllerBase
private readonly MessageService _messageService;
private readonly DocumentServiceConnector _documentServiceConnector;
private readonly CommonLinkUtility _commonLinkUtility;
private readonly EditorControllerHelper<int> _editorControllerHelperInt;
private readonly EditorControllerHelper<string> _editorControllerHelperString;
public EditorController(
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString,
FilesLinkUtility filesLinkUtility,
MessageService messageService,
DocumentServiceConnector documentServiceConnector,
CommonLinkUtility commonLinkUtility)
: base(
filesControllerHelperInt,
filesControllerHelperString)
CommonLinkUtility commonLinkUtility,
EditorControllerHelper<int> editorControllerHelperInt,
EditorControllerHelper<string> editorControllerHelperString)
{
_filesLinkUtility = filesLinkUtility;
_messageService = messageService;
_documentServiceConnector = documentServiceConnector;
_commonLinkUtility = commonLinkUtility;
_editorControllerHelperInt = editorControllerHelperInt;
_editorControllerHelperString = editorControllerHelperString;
}
/// <summary>
@ -36,19 +37,19 @@ public class EditorController : ApiControllerBase
/// <category>Files</category>
/// <returns></returns>
[Update("file/{fileId}/saveediting")]
public Task<FileDto<string>> SaveEditingFromFormAsync(string fileId, [FromForm] SaveEditingRequestDto requestDto)
public Task<FileDto<string>> SaveEditingFromFormAsync(string fileId, [FromForm] SaveEditingRequestDto inDto)
{
using var stream = _filesControllerHelperInt.GetFileFromRequest(requestDto).OpenReadStream();
using var stream = _editorControllerHelperInt.GetFileFromRequest(inDto).OpenReadStream();
return _filesControllerHelperString.SaveEditingAsync(fileId, requestDto.FileExtension, requestDto.DownloadUri, stream, requestDto.Doc, requestDto.Forcesave);
return _editorControllerHelperString.SaveEditingAsync(fileId, inDto.FileExtension, inDto.DownloadUri, stream, inDto.Doc, inDto.Forcesave);
}
[Update("file/{fileId:int}/saveediting")]
public Task<FileDto<int>> SaveEditingFromFormAsync(int fileId, [FromForm] SaveEditingRequestDto requestDto)
public Task<FileDto<int>> SaveEditingFromFormAsync(int fileId, [FromForm] SaveEditingRequestDto inDto)
{
using var stream = _filesControllerHelperInt.GetFileFromRequest(requestDto).OpenReadStream();
using var stream = _editorControllerHelperInt.GetFileFromRequest(inDto).OpenReadStream();
return _filesControllerHelperInt.SaveEditingAsync(fileId, requestDto.FileExtension, requestDto.DownloadUri, stream, requestDto.Doc, requestDto.Forcesave);
return _editorControllerHelperInt.SaveEditingAsync(fileId, inDto.FileExtension, inDto.DownloadUri, stream, inDto.Doc, inDto.Forcesave);
}
/// <summary>
@ -61,36 +62,36 @@ public class EditorController : ApiControllerBase
/// <returns></returns>
[Create("file/{fileId}/startedit")]
[Consumes("application/json")]
public async Task<object> StartEditFromBodyAsync(string fileId, [FromBody] StartEditRequestDto requestDto)
public async Task<object> StartEditFromBodyAsync(string fileId, [FromBody] StartEditRequestDto inDto)
{
return await _filesControllerHelperString.StartEditAsync(fileId, requestDto.EditingAlone, requestDto.Doc);
return await _editorControllerHelperString.StartEditAsync(fileId, inDto.EditingAlone, inDto.Doc);
}
[Create("file/{fileId}/startedit")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<object> StartEditFromFormAsync(string fileId, [FromForm] StartEditRequestDto requestDto)
public async Task<object> StartEditFromFormAsync(string fileId, [FromForm] StartEditRequestDto inDto)
{
return await _filesControllerHelperString.StartEditAsync(fileId, requestDto.EditingAlone, requestDto.Doc);
return await _editorControllerHelperString.StartEditAsync(fileId, inDto.EditingAlone, inDto.Doc);
}
[Create("file/{fileId:int}/startedit")]
[Consumes("application/json")]
public async Task<object> StartEditFromBodyAsync(int fileId, [FromBody] StartEditRequestDto requestDto)
public async Task<object> StartEditFromBodyAsync(int fileId, [FromBody] StartEditRequestDto inDto)
{
return await _filesControllerHelperInt.StartEditAsync(fileId, requestDto.EditingAlone, requestDto.Doc);
return await _editorControllerHelperInt.StartEditAsync(fileId, inDto.EditingAlone, inDto.Doc);
}
[Create("file/{fileId:int}/startedit")]
public async Task<object> StartEditAsync(int fileId)
{
return await _filesControllerHelperInt.StartEditAsync(fileId, false, null);
return await _editorControllerHelperInt.StartEditAsync(fileId, false, null);
}
[Create("file/{fileId:int}/startedit")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<object> StartEditFromFormAsync(int fileId, [FromForm] StartEditRequestDto requestDto)
public async Task<object> StartEditFromFormAsync(int fileId, [FromForm] StartEditRequestDto inDto)
{
return await _filesControllerHelperInt.StartEditAsync(fileId, requestDto.EditingAlone, requestDto.Doc);
return await _editorControllerHelperInt.StartEditAsync(fileId, inDto.EditingAlone, inDto.Doc);
}
/// <summary>
@ -106,13 +107,13 @@ public class EditorController : ApiControllerBase
[Read("file/{fileId}/trackeditfile")]
public Task<KeyValuePair<bool, string>> TrackEditFileAsync(string fileId, Guid tabId, string docKeyForTrack, string doc, bool isFinish)
{
return _filesControllerHelperString.TrackEditFileAsync(fileId, tabId, docKeyForTrack, doc, isFinish);
return _editorControllerHelperString.TrackEditFileAsync(fileId, tabId, docKeyForTrack, doc, isFinish);
}
[Read("file/{fileId:int}/trackeditfile")]
public Task<KeyValuePair<bool, string>> TrackEditFileAsync(int fileId, Guid tabId, string docKeyForTrack, string doc, bool isFinish)
{
return _filesControllerHelperInt.TrackEditFileAsync(fileId, tabId, docKeyForTrack, doc, isFinish);
return _editorControllerHelperInt.TrackEditFileAsync(fileId, tabId, docKeyForTrack, doc, isFinish);
}
/// <summary>
@ -127,14 +128,14 @@ public class EditorController : ApiControllerBase
[Read("file/{fileId}/openedit", Check = false)]
public Task<Configuration<string>> OpenEditAsync(string fileId, int version, string doc, bool view)
{
return _filesControllerHelperString.OpenEditAsync(fileId, version, doc, view);
return _editorControllerHelperString.OpenEditAsync(fileId, version, doc, view);
}
[AllowAnonymous]
[Read("file/{fileId:int}/openedit", Check = false)]
public Task<Configuration<int>> OpenEditAsync(int fileId, int version, string doc, bool view)
{
return _filesControllerHelperInt.OpenEditAsync(fileId, version, doc, view);
return _editorControllerHelperInt.OpenEditAsync(fileId, version, doc, view);
}
/// <summary>
@ -145,16 +146,16 @@ public class EditorController : ApiControllerBase
/// <param name="docServiceUrlPortal">Community Server Address</param>
/// <returns></returns>
[Update("docservice")]
public Task<IEnumerable<string>> CheckDocServiceUrlFromBodyAsync([FromBody] CheckDocServiceUrlRequestDto requestDto)
public Task<IEnumerable<string>> CheckDocServiceUrlFromBodyAsync([FromBody] CheckDocServiceUrlRequestDto inDto)
{
return CheckDocServiceUrlAsync(requestDto);
return CheckDocServiceUrlAsync(inDto);
}
[Update("docservice")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<string>> CheckDocServiceUrlFromFormAsync([FromForm] CheckDocServiceUrlRequestDto requestDto)
public Task<IEnumerable<string>> CheckDocServiceUrlFromFormAsync([FromForm] CheckDocServiceUrlRequestDto inDto)
{
return CheckDocServiceUrlAsync(requestDto);
return CheckDocServiceUrlAsync(inDto);
}
/// <visible>false</visible>
@ -174,13 +175,13 @@ public class EditorController : ApiControllerBase
[Read("file/{fileId}/presigned")]
public Task<DocumentService.FileLink> GetPresignedUriAsync(string fileId)
{
return _filesControllerHelperString.GetPresignedUriAsync(fileId);
return _editorControllerHelperString.GetPresignedUriAsync(fileId);
}
[Read("file/{fileId:int}/presigned")]
public Task<DocumentService.FileLink> GetPresignedUriAsync(int fileId)
{
return _filesControllerHelperInt.GetPresignedUriAsync(fileId);
return _editorControllerHelperInt.GetPresignedUriAsync(fileId);
}
private async Task<object> InternalGetDocServiceUrlAsync(string url)
@ -194,11 +195,11 @@ public class EditorController : ApiControllerBase
};
}
private Task<IEnumerable<string>> CheckDocServiceUrlAsync(CheckDocServiceUrlRequestDto requestDto)
private Task<IEnumerable<string>> CheckDocServiceUrlAsync(CheckDocServiceUrlRequestDto inDto)
{
_filesLinkUtility.DocServiceUrl = requestDto.DocServiceUrl;
_filesLinkUtility.DocServiceUrlInternal = requestDto.DocServiceUrlInternal;
_filesLinkUtility.DocServicePortalUrl = requestDto.DocServiceUrlPortal;
_filesLinkUtility.DocServiceUrl = inDto.DocServiceUrl;
_filesLinkUtility.DocServiceUrlInternal = inDto.DocServiceUrlInternal;
_filesLinkUtility.DocServicePortalUrl = inDto.DocServiceUrlPortal;
_messageService.Send(MessageAction.DocumentServiceLocationSetting);

View File

@ -1,22 +1,25 @@
namespace ASC.Files.Api;
public class FileController : ApiControllerBase
public class FilesController : ApiControllerBase
{
private readonly IServiceProvider _serviceProvider;
private readonly GlobalFolderHelper _globalFolderHelper;
private readonly FileStorageService<string> _fileStorageServiceString;
private readonly FilesControllerHelper<int> _filesControllerHelperInt;
private readonly FilesControllerHelper<string> _filesControllerHelperString;
public FileController(
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString,
public FilesController(
IServiceProvider serviceProvider,
GlobalFolderHelper globalFolderHelper,
FileStorageService<string> fileStorageServiceString)
: base(filesControllerHelperInt, filesControllerHelperString)
FileStorageService<string> fileStorageServiceString,
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString)
{
_serviceProvider = serviceProvider;
_globalFolderHelper = globalFolderHelper;
_fileStorageServiceString = fileStorageServiceString;
_filesControllerHelperInt = filesControllerHelperInt;
_filesControllerHelperString = filesControllerHelperString;
}
/// <summary>
@ -28,29 +31,29 @@ public class FileController : ApiControllerBase
/// <category>Files</category>
/// <returns></returns>
[Update("file/{fileId}/history")]
public Task<IEnumerable<FileDto<string>>> ChangeHistoryFromBodyAsync(string fileId, [FromBody] ChangeHistoryRequestDto requestDto)
public Task<IEnumerable<FileDto<string>>> ChangeHistoryFromBodyAsync(string fileId, [FromBody] ChangeHistoryRequestDto inDto)
{
return _filesControllerHelperString.ChangeHistoryAsync(fileId, requestDto.Version, requestDto.ContinueVersion);
return _filesControllerHelperString.ChangeHistoryAsync(fileId, inDto.Version, inDto.ContinueVersion);
}
[Update("file/{fileId:int}/history")]
public Task<IEnumerable<FileDto<int>>> ChangeHistoryFromBodyAsync(int fileId, [FromBody] ChangeHistoryRequestDto requestDto)
public Task<IEnumerable<FileDto<int>>> ChangeHistoryFromBodyAsync(int fileId, [FromBody] ChangeHistoryRequestDto inDto)
{
return _filesControllerHelperInt.ChangeHistoryAsync(fileId, requestDto.Version, requestDto.ContinueVersion);
return _filesControllerHelperInt.ChangeHistoryAsync(fileId, inDto.Version, inDto.ContinueVersion);
}
[Update("file/{fileId}/history")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileDto<string>>> ChangeHistoryFromFormAsync(string fileId, [FromForm] ChangeHistoryRequestDto requestDto)
public Task<IEnumerable<FileDto<string>>> ChangeHistoryFromFormAsync(string fileId, [FromForm] ChangeHistoryRequestDto inDto)
{
return _filesControllerHelperString.ChangeHistoryAsync(fileId, requestDto.Version, requestDto.ContinueVersion);
return _filesControllerHelperString.ChangeHistoryAsync(fileId, inDto.Version, inDto.ContinueVersion);
}
[Update("file/{fileId:int}/history")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileDto<int>>> ChangeHistoryFromFormAsync(int fileId, [FromForm] ChangeHistoryRequestDto requestDto)
public Task<IEnumerable<FileDto<int>>> ChangeHistoryFromFormAsync(int fileId, [FromForm] ChangeHistoryRequestDto inDto)
{
return _filesControllerHelperInt.ChangeHistoryAsync(fileId, requestDto.Version, requestDto.ContinueVersion);
return _filesControllerHelperInt.ChangeHistoryAsync(fileId, inDto.Version, inDto.ContinueVersion);
}
/// <summary>
@ -82,29 +85,29 @@ public class FileController : ApiControllerBase
}
[Create("file/{fileId:int}/copyas", order: int.MaxValue - 1)]
public object CopyFileAsFromBody(int fileId, [FromBody] CopyAsRequestDto<JsonElement> requestDto)
public object CopyFileAsFromBody(int fileId, [FromBody] CopyAsRequestDto<JsonElement> inDto)
{
return CopyFile(fileId, requestDto);
return CopyFile(fileId, inDto);
}
[Create("file/{fileId}/copyas", order: int.MaxValue)]
public object CopyFileAsFromBody(string fileId, [FromBody] CopyAsRequestDto<JsonElement> requestDto)
public object CopyFileAsFromBody(string fileId, [FromBody] CopyAsRequestDto<JsonElement> inDto)
{
return CopyFile(fileId, requestDto);
return CopyFile(fileId, inDto);
}
[Create("file/{fileId:int}/copyas", order: int.MaxValue - 1)]
[Consumes("application/x-www-form-urlencoded")]
public object CopyFileAsFromForm(int fileId, [FromForm] CopyAsRequestDto<JsonElement> requestDto)
public object CopyFileAsFromForm(int fileId, [FromForm] CopyAsRequestDto<JsonElement> inDto)
{
return CopyFile(fileId, requestDto);
return CopyFile(fileId, inDto);
}
[Create("file/{fileId}/copyas", order: int.MaxValue)]
[Consumes("application/x-www-form-urlencoded")]
public object CopyFileAsFromForm(string fileId, [FromForm] CopyAsRequestDto<JsonElement> requestDto)
public object CopyFileAsFromForm(string fileId, [FromForm] CopyAsRequestDto<JsonElement> inDto)
{
return CopyFile(fileId, requestDto);
return CopyFile(fileId, inDto);
}
/// <summary>
@ -116,9 +119,9 @@ public class FileController : ApiControllerBase
/// <remarks>In case the extension for the file title differs from DOCX/XLSX/PPTX and belongs to one of the known text, spreadsheet or presentation formats, it will be changed to DOCX/XLSX/PPTX accordingly. If the file extension is not set or is unknown, the DOCX extension will be added to the file title.</remarks>
/// <returns>New file info</returns>
[Create("@my/file")]
public Task<FileDto<int>> CreateFileFromBodyAsync([FromBody] CreateFileRequestDto<JsonElement> requestDto)
public Task<FileDto<int>> CreateFileFromBodyAsync([FromBody] CreateFileRequestDto<JsonElement> inDto)
{
return _filesControllerHelperInt.CreateFileAsync(_globalFolderHelper.FolderMy, requestDto.Title, requestDto.TemplateId, requestDto.EnableExternalExt);
return _filesControllerHelperInt.CreateFileAsync(_globalFolderHelper.FolderMy, inDto.Title, inDto.TemplateId, inDto.EnableExternalExt);
}
/// <summary>
@ -131,36 +134,36 @@ public class FileController : ApiControllerBase
/// <remarks>In case the extension for the file title differs from DOCX/XLSX/PPTX and belongs to one of the known text, spreadsheet or presentation formats, it will be changed to DOCX/XLSX/PPTX accordingly. If the file extension is not set or is unknown, the DOCX extension will be added to the file title.</remarks>
/// <returns>New file info</returns>
[Create("{folderId}/file")]
public Task<FileDto<string>> CreateFileFromBodyAsync(string folderId, [FromBody] CreateFileRequestDto<JsonElement> requestDto)
public Task<FileDto<string>> CreateFileFromBodyAsync(string folderId, [FromBody] CreateFileRequestDto<JsonElement> inDto)
{
return _filesControllerHelperString.CreateFileAsync(folderId, requestDto.Title, requestDto.TemplateId, requestDto.EnableExternalExt);
return _filesControllerHelperString.CreateFileAsync(folderId, inDto.Title, inDto.TemplateId, inDto.EnableExternalExt);
}
[Create("{folderId:int}/file")]
public Task<FileDto<int>> CreateFileFromBodyAsync(int folderId, [FromBody] CreateFileRequestDto<JsonElement> requestDto)
public Task<FileDto<int>> CreateFileFromBodyAsync(int folderId, [FromBody] CreateFileRequestDto<JsonElement> inDto)
{
return _filesControllerHelperInt.CreateFileAsync(folderId, requestDto.Title, requestDto.TemplateId, requestDto.EnableExternalExt);
return _filesControllerHelperInt.CreateFileAsync(folderId, inDto.Title, inDto.TemplateId, inDto.EnableExternalExt);
}
[Create("@my/file")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<int>> CreateFileFromFormAsync([FromForm] CreateFileRequestDto<JsonElement> requestDto)
public Task<FileDto<int>> CreateFileFromFormAsync([FromForm] CreateFileRequestDto<JsonElement> inDto)
{
return _filesControllerHelperInt.CreateFileAsync(_globalFolderHelper.FolderMy, requestDto.Title, requestDto.TemplateId, requestDto.EnableExternalExt);
return _filesControllerHelperInt.CreateFileAsync(_globalFolderHelper.FolderMy, inDto.Title, inDto.TemplateId, inDto.EnableExternalExt);
}
[Create("{folderId}/file")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<string>> CreateFileFromFormAsync(string folderId, [FromForm] CreateFileRequestDto<JsonElement> requestDto)
public Task<FileDto<string>> CreateFileFromFormAsync(string folderId, [FromForm] CreateFileRequestDto<JsonElement> inDto)
{
return _filesControllerHelperString.CreateFileAsync(folderId, requestDto.Title, requestDto.TemplateId, requestDto.EnableExternalExt);
return _filesControllerHelperString.CreateFileAsync(folderId, inDto.Title, inDto.TemplateId, inDto.EnableExternalExt);
}
[Create("{folderId:int}/file")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<int>> CreateFileFromFormAsync(int folderId, [FromForm] CreateFileRequestDto<JsonElement> requestDto)
public Task<FileDto<int>> CreateFileFromFormAsync(int folderId, [FromForm] CreateFileRequestDto<JsonElement> inDto)
{
return _filesControllerHelperInt.CreateFileAsync(folderId, requestDto.Title, requestDto.TemplateId, requestDto.EnableExternalExt);
return _filesControllerHelperInt.CreateFileAsync(folderId, inDto.Title, inDto.TemplateId, inDto.EnableExternalExt);
}
/// <summary>
@ -173,29 +176,29 @@ public class FileController : ApiControllerBase
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("{folderId}/html")]
public Task<FileDto<string>> CreateHtmlFileFromBodyAsync(string folderId, [FromBody] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<string>> CreateHtmlFileFromBodyAsync(string folderId, [FromBody] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperString.CreateHtmlFileAsync(folderId, requestDto.Title, requestDto.Content);
return _filesControllerHelperString.CreateHtmlFileAsync(folderId, inDto.Title, inDto.Content);
}
[Create("{folderId:int}/html")]
public Task<FileDto<int>> CreateHtmlFileFromBodyAsync(int folderId, [FromBody] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<int>> CreateHtmlFileFromBodyAsync(int folderId, [FromBody] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperInt.CreateHtmlFileAsync(folderId, requestDto.Title, requestDto.Content);
return _filesControllerHelperInt.CreateHtmlFileAsync(folderId, inDto.Title, inDto.Content);
}
[Create("{folderId}/html")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<string>> CreateHtmlFileFromFormAsync(string folderId, [FromForm] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<string>> CreateHtmlFileFromFormAsync(string folderId, [FromForm] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperString.CreateHtmlFileAsync(folderId, requestDto.Title, requestDto.Content);
return _filesControllerHelperString.CreateHtmlFileAsync(folderId, inDto.Title, inDto.Content);
}
[Create("{folderId:int}/html")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<int>> CreateHtmlFileFromFormAsync(int folderId, [FromForm] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<int>> CreateHtmlFileFromFormAsync(int folderId, [FromForm] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperInt.CreateHtmlFileAsync(folderId, requestDto.Title, requestDto.Content);
return _filesControllerHelperInt.CreateHtmlFileAsync(folderId, inDto.Title, inDto.Content);
}
/// <summary>
@ -207,16 +210,16 @@ public class FileController : ApiControllerBase
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("@common/html")]
public async Task<FileDto<int>> CreateHtmlFileInCommonFromBodyAsync([FromBody] CreateTextOrHtmlFileRequestDto requestDto)
public async Task<FileDto<int>> CreateHtmlFileInCommonFromBodyAsync([FromBody] CreateTextOrHtmlFileRequestDto inDto)
{
return await _filesControllerHelperInt.CreateHtmlFileAsync(await _globalFolderHelper.FolderCommonAsync, requestDto.Title, requestDto.Content);
return await _filesControllerHelperInt.CreateHtmlFileAsync(await _globalFolderHelper.FolderCommonAsync, inDto.Title, inDto.Content);
}
[Create("@common/html")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<FileDto<int>> CreateHtmlFileInCommonFromFormAsync([FromForm] CreateTextOrHtmlFileRequestDto requestDto)
public async Task<FileDto<int>> CreateHtmlFileInCommonFromFormAsync([FromForm] CreateTextOrHtmlFileRequestDto inDto)
{
return await _filesControllerHelperInt.CreateHtmlFileAsync(await _globalFolderHelper.FolderCommonAsync, requestDto.Title, requestDto.Content);
return await _filesControllerHelperInt.CreateHtmlFileAsync(await _globalFolderHelper.FolderCommonAsync, inDto.Title, inDto.Content);
}
/// <summary>
@ -228,16 +231,16 @@ public class FileController : ApiControllerBase
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("@my/html")]
public Task<FileDto<int>> CreateHtmlFileInMyFromBodyAsync([FromBody] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<int>> CreateHtmlFileInMyFromBodyAsync([FromBody] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperInt.CreateHtmlFileAsync(_globalFolderHelper.FolderMy, requestDto.Title, requestDto.Content);
return _filesControllerHelperInt.CreateHtmlFileAsync(_globalFolderHelper.FolderMy, inDto.Title, inDto.Content);
}
[Create("@my/html")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<int>> CreateHtmlFileInMyFromFormAsync([FromForm] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<int>> CreateHtmlFileInMyFromFormAsync([FromForm] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperInt.CreateHtmlFileAsync(_globalFolderHelper.FolderMy, requestDto.Title, requestDto.Content);
return _filesControllerHelperInt.CreateHtmlFileAsync(_globalFolderHelper.FolderMy, inDto.Title, inDto.Content);
}
/// <summary>
@ -250,29 +253,29 @@ public class FileController : ApiControllerBase
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("{folderId}/text")]
public Task<FileDto<string>> CreateTextFileFromBodyAsync(string folderId, [FromBody] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<string>> CreateTextFileFromBodyAsync(string folderId, [FromBody] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperString.CreateTextFileAsync(folderId, requestDto.Title, requestDto.Content);
return _filesControllerHelperString.CreateTextFileAsync(folderId, inDto.Title, inDto.Content);
}
[Create("{folderId:int}/text")]
public Task<FileDto<int>> CreateTextFileFromBodyAsync(int folderId, [FromBody] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<int>> CreateTextFileFromBodyAsync(int folderId, [FromBody] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperInt.CreateTextFileAsync(folderId, requestDto.Title, requestDto.Content);
return _filesControllerHelperInt.CreateTextFileAsync(folderId, inDto.Title, inDto.Content);
}
[Create("{folderId}/text")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<string>> CreateTextFileFromFormAsync(string folderId, [FromForm] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<string>> CreateTextFileFromFormAsync(string folderId, [FromForm] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperString.CreateTextFileAsync(folderId, requestDto.Title, requestDto.Content);
return _filesControllerHelperString.CreateTextFileAsync(folderId, inDto.Title, inDto.Content);
}
[Create("{folderId:int}/text")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<int>> CreateTextFileFromFormAsync(int folderId, [FromForm] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<int>> CreateTextFileFromFormAsync(int folderId, [FromForm] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperInt.CreateTextFileAsync(folderId, requestDto.Title, requestDto.Content);
return _filesControllerHelperInt.CreateTextFileAsync(folderId, inDto.Title, inDto.Content);
}
/// <summary>
@ -284,16 +287,16 @@ public class FileController : ApiControllerBase
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("@common/text")]
public async Task<FileDto<int>> CreateTextFileInCommonFromBodyAsync([FromBody] CreateTextOrHtmlFileRequestDto requestDto)
public async Task<FileDto<int>> CreateTextFileInCommonFromBodyAsync([FromBody] CreateTextOrHtmlFileRequestDto inDto)
{
return await _filesControllerHelperInt.CreateTextFileAsync(await _globalFolderHelper.FolderCommonAsync, requestDto.Title, requestDto.Content);
return await _filesControllerHelperInt.CreateTextFileAsync(await _globalFolderHelper.FolderCommonAsync, inDto.Title, inDto.Content);
}
[Create("@common/text")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<FileDto<int>> CreateTextFileInCommonFromFormAsync([FromForm] CreateTextOrHtmlFileRequestDto requestDto)
public async Task<FileDto<int>> CreateTextFileInCommonFromFormAsync([FromForm] CreateTextOrHtmlFileRequestDto inDto)
{
return await _filesControllerHelperInt.CreateTextFileAsync(await _globalFolderHelper.FolderCommonAsync, requestDto.Title, requestDto.Content);
return await _filesControllerHelperInt.CreateTextFileAsync(await _globalFolderHelper.FolderCommonAsync, inDto.Title, inDto.Content);
}
/// <summary>
@ -305,29 +308,29 @@ public class FileController : ApiControllerBase
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("@my/text")]
public Task<FileDto<int>> CreateTextFileInMyFromBodyAsync([FromBody] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<int>> CreateTextFileInMyFromBodyAsync([FromBody] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperInt.CreateTextFileAsync(_globalFolderHelper.FolderMy, requestDto.Title, requestDto.Content);
return _filesControllerHelperInt.CreateTextFileAsync(_globalFolderHelper.FolderMy, inDto.Title, inDto.Content);
}
[Create("@my/text")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<int>> CreateTextFileInMyFromFormAsync([FromForm] CreateTextOrHtmlFileRequestDto requestDto)
public Task<FileDto<int>> CreateTextFileInMyFromFormAsync([FromForm] CreateTextOrHtmlFileRequestDto inDto)
{
return _filesControllerHelperInt.CreateTextFileAsync(_globalFolderHelper.FolderMy, requestDto.Title, requestDto.Content);
return _filesControllerHelperInt.CreateTextFileAsync(_globalFolderHelper.FolderMy, inDto.Title, inDto.Content);
}
[Create("thumbnails")]
public Task<IEnumerable<JsonElement>> CreateThumbnailsFromBodyAsync([FromBody] BaseBatchRequestDto requestDto)
public Task<IEnumerable<JsonElement>> CreateThumbnailsFromBodyAsync([FromBody] BaseBatchRequestDto inDto)
{
return _fileStorageServiceString.CreateThumbnailsAsync(requestDto.FileIds.ToList());
return _fileStorageServiceString.CreateThumbnailsAsync(inDto.FileIds.ToList());
}
[Create("thumbnails")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<IEnumerable<JsonElement>> CreateThumbnailsFromFormAsync([FromForm][ModelBinder(BinderType = typeof(BaseBatchModelBinder))] BaseBatchRequestDto requestDto)
public async Task<IEnumerable<JsonElement>> CreateThumbnailsFromFormAsync([FromForm][ModelBinder(BinderType = typeof(BaseBatchModelBinder))] BaseBatchRequestDto inDto)
{
return await _fileStorageServiceString.CreateThumbnailsAsync(requestDto.FileIds.ToList());
return await _fileStorageServiceString.CreateThumbnailsAsync(inDto.FileIds.ToList());
}
/// <summary>
@ -340,15 +343,15 @@ public class FileController : ApiControllerBase
/// <param name="immediately">Don't move to the Recycle Bin</param>
/// <returns>Operation result</returns>
[Delete("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
public Task<IEnumerable<FileOperationDto>> DeleteFile(string fileId, [FromBody] DeleteRequestDto requestDto)
public Task<IEnumerable<FileOperationDto>> DeleteFile(string fileId, [FromBody] DeleteRequestDto inDto)
{
return _filesControllerHelperString.DeleteFileAsync(fileId, requestDto.DeleteAfter, requestDto.Immediately);
return _filesControllerHelperString.DeleteFileAsync(fileId, inDto.DeleteAfter, inDto.Immediately);
}
[Delete("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
public Task<IEnumerable<FileOperationDto>> DeleteFile(int fileId, [FromBody] DeleteRequestDto requestDto)
public Task<IEnumerable<FileOperationDto>> DeleteFile(int fileId, [FromBody] DeleteRequestDto inDto)
{
return _filesControllerHelperInt.DeleteFileAsync(fileId, requestDto.DeleteAfter, requestDto.Immediately);
return _filesControllerHelperInt.DeleteFileAsync(fileId, inDto.DeleteAfter, inDto.Immediately);
}
[AllowAnonymous]
@ -417,29 +420,29 @@ public class FileController : ApiControllerBase
}
[Update("file/{fileId}/lock")]
public Task<FileDto<string>> LockFileFromBodyAsync(string fileId, [FromBody] LockFileRequestDto requestDto)
public Task<FileDto<string>> LockFileFromBodyAsync(string fileId, [FromBody] LockFileRequestDto inDto)
{
return _filesControllerHelperString.LockFileAsync(fileId, requestDto.LockFile);
return _filesControllerHelperString.LockFileAsync(fileId, inDto.LockFile);
}
[Update("file/{fileId:int}/lock")]
public Task<FileDto<int>> LockFileFromBodyAsync(int fileId, [FromBody] LockFileRequestDto requestDto)
public Task<FileDto<int>> LockFileFromBodyAsync(int fileId, [FromBody] LockFileRequestDto inDto)
{
return _filesControllerHelperInt.LockFileAsync(fileId, requestDto.LockFile);
return _filesControllerHelperInt.LockFileAsync(fileId, inDto.LockFile);
}
[Update("file/{fileId}/lock")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<string>> LockFileFromFormAsync(string fileId, [FromForm] LockFileRequestDto requestDto)
public Task<FileDto<string>> LockFileFromFormAsync(string fileId, [FromForm] LockFileRequestDto inDto)
{
return _filesControllerHelperString.LockFileAsync(fileId, requestDto.LockFile);
return _filesControllerHelperString.LockFileAsync(fileId, inDto.LockFile);
}
[Update("file/{fileId:int}/lock")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<int>> LockFileFromFormAsync(int fileId, [FromForm] LockFileRequestDto requestDto)
public Task<FileDto<int>> LockFileFromFormAsync(int fileId, [FromForm] LockFileRequestDto inDto)
{
return _filesControllerHelperInt.LockFileAsync(fileId, requestDto.LockFile);
return _filesControllerHelperInt.LockFileAsync(fileId, inDto.LockFile);
}
[AllowAnonymous]
@ -464,51 +467,52 @@ public class FileController : ApiControllerBase
/// <param name="fileId"></param>
/// <returns>Operation result</returns>
[Update("file/{fileId}/checkconversion")]
public IAsyncEnumerable<ConversationResultDto<string>> StartConversion(string fileId, [FromBody(EmptyBodyBehavior = Microsoft.AspNetCore.Mvc.ModelBinding.EmptyBodyBehavior.Allow)] CheckConversionRequestDto<string> requestDto)
public IAsyncEnumerable<ConversationResultDto<string>> StartConversion(string fileId, [FromBody(EmptyBodyBehavior = Microsoft.AspNetCore.Mvc.ModelBinding.EmptyBodyBehavior.Allow)] CheckConversionRequestDto<string> inDto)
{
if (requestDto == null)
if (inDto == null)
{
requestDto = new CheckConversionRequestDto<string>();
inDto = new CheckConversionRequestDto<string>();
}
requestDto.FileId = fileId;
return _filesControllerHelperString.StartConversionAsync(requestDto);
inDto.FileId = fileId;
return _filesControllerHelperString.StartConversionAsync(inDto);
}
[Update("file/{fileId:int}/checkconversion")]
public IAsyncEnumerable<ConversationResultDto<int>> StartConversion(int fileId, [FromBody(EmptyBodyBehavior = Microsoft.AspNetCore.Mvc.ModelBinding.EmptyBodyBehavior.Allow)] CheckConversionRequestDto<int> requestDto)
public IAsyncEnumerable<ConversationResultDto<int>> StartConversion(int fileId, [FromBody(EmptyBodyBehavior = Microsoft.AspNetCore.Mvc.ModelBinding.EmptyBodyBehavior.Allow)] CheckConversionRequestDto<int> inDto)
{
if (requestDto == null)
if (inDto == null)
{
requestDto = new CheckConversionRequestDto<int>();
inDto = new CheckConversionRequestDto<int>();
}
requestDto.FileId = fileId;
return _filesControllerHelperInt.StartConversionAsync(requestDto);
inDto.FileId = fileId;
return _filesControllerHelperInt.StartConversionAsync(inDto);
}
[Update("file/{fileId}/comment")]
public async Task<object> UpdateCommentFromBodyAsync(string fileId, [FromBody] UpdateCommentRequestDto requestDto)
public async Task<object> UpdateCommentFromBodyAsync(string fileId, [FromBody] UpdateCommentRequestDto inDto)
{
return await _filesControllerHelperString.UpdateCommentAsync(fileId, requestDto.Version, requestDto.Comment);
return await _filesControllerHelperString.UpdateCommentAsync(fileId, inDto.Version, inDto.Comment);
}
[Update("file/{fileId:int}/comment")]
public async Task<object> UpdateCommentFromBodyAsync(int fileId, [FromBody] UpdateCommentRequestDto requestDto)
public async Task<object> UpdateCommentFromBodyAsync(int fileId, [FromBody] UpdateCommentRequestDto inDto)
{
return await _filesControllerHelperInt.UpdateCommentAsync(fileId, requestDto.Version, requestDto.Comment);
return await _filesControllerHelperInt.UpdateCommentAsync(fileId, inDto.Version, inDto.Comment);
}
[Update("file/{fileId}/comment")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<object> UpdateCommentFromFormAsync(string fileId, [FromForm] UpdateCommentRequestDto requestDto)
public async Task<object> UpdateCommentFromFormAsync(string fileId, [FromForm] UpdateCommentRequestDto inDto)
{
return await _filesControllerHelperString.UpdateCommentAsync(fileId, requestDto.Version, requestDto.Comment);
return await _filesControllerHelperString.UpdateCommentAsync(fileId, inDto.Version, inDto.Comment);
}
[Update("file/{fileId:int}/comment")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<object> UpdateCommentFromFormAsync(int fileId, [FromForm] UpdateCommentRequestDto requestDto)
public async Task<object> UpdateCommentFromFormAsync(int fileId, [FromForm] UpdateCommentRequestDto inDto)
{
return await _filesControllerHelperInt.UpdateCommentAsync(fileId, requestDto.Version, requestDto.Comment);
return await _filesControllerHelperInt.UpdateCommentAsync(fileId, inDto.Version, inDto.Comment);
}
/// <summary>
@ -521,29 +525,29 @@ public class FileController : ApiControllerBase
/// <param name="lastVersion">File last version number</param>
/// <returns>File info</returns>
[Update("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
public Task<FileDto<string>> UpdateFileFromBodyAsync(string fileId, [FromBody] UpdateFileRequestDto requestDto)
public Task<FileDto<string>> UpdateFileFromBodyAsync(string fileId, [FromBody] UpdateFileRequestDto inDto)
{
return _filesControllerHelperString.UpdateFileAsync(fileId, requestDto.Title, requestDto.LastVersion);
return _filesControllerHelperString.UpdateFileAsync(fileId, inDto.Title, inDto.LastVersion);
}
[Update("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
public Task<FileDto<int>> UpdateFileFromBodyAsync(int fileId, [FromBody] UpdateFileRequestDto requestDto)
public Task<FileDto<int>> UpdateFileFromBodyAsync(int fileId, [FromBody] UpdateFileRequestDto inDto)
{
return _filesControllerHelperInt.UpdateFileAsync(fileId, requestDto.Title, requestDto.LastVersion);
return _filesControllerHelperInt.UpdateFileAsync(fileId, inDto.Title, inDto.LastVersion);
}
[Update("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<string>> UpdateFileFromFormAsync(string fileId, [FromForm] UpdateFileRequestDto requestDto)
public Task<FileDto<string>> UpdateFileFromFormAsync(string fileId, [FromForm] UpdateFileRequestDto inDto)
{
return _filesControllerHelperString.UpdateFileAsync(fileId, requestDto.Title, requestDto.LastVersion);
return _filesControllerHelperString.UpdateFileAsync(fileId, inDto.Title, inDto.LastVersion);
}
[Update("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
public Task<FileDto<int>> UpdateFileFromFormAsync(int fileId, [FromForm] UpdateFileRequestDto requestDto)
public Task<FileDto<int>> UpdateFileFromFormAsync(int fileId, [FromForm] UpdateFileRequestDto inDto)
{
return _filesControllerHelperInt.UpdateFileAsync(fileId, requestDto.Title, requestDto.LastVersion);
return _filesControllerHelperInt.UpdateFileAsync(fileId, inDto.Title, inDto.LastVersion);
}
/// <summary>
@ -555,27 +559,27 @@ public class FileController : ApiControllerBase
/// <returns></returns>
/// <visible>false</visible>
[Update("{fileId}/update")]
public Task<FileDto<string>> UpdateFileStreamFromFormAsync(string fileId, [FromForm] FileStreamRequestDto requestDto)
public Task<FileDto<string>> UpdateFileStreamFromFormAsync(string fileId, [FromForm] FileStreamRequestDto inDto)
{
return _filesControllerHelperString.UpdateFileStreamAsync(_filesControllerHelperInt.GetFileFromRequest(requestDto).OpenReadStream(), fileId, requestDto.FileExtension, requestDto.Encrypted, requestDto.Forcesave);
return _filesControllerHelperString.UpdateFileStreamAsync(_filesControllerHelperInt.GetFileFromRequest(inDto).OpenReadStream(), fileId, inDto.FileExtension, inDto.Encrypted, inDto.Forcesave);
}
[Update("{fileId:int}/update")]
public Task<FileDto<int>> UpdateFileStreamFromFormAsync(int fileId, [FromForm] FileStreamRequestDto requestDto)
public Task<FileDto<int>> UpdateFileStreamFromFormAsync(int fileId, [FromForm] FileStreamRequestDto inDto)
{
return _filesControllerHelperInt.UpdateFileStreamAsync(_filesControllerHelperInt.GetFileFromRequest(requestDto).OpenReadStream(), fileId, requestDto.FileExtension, requestDto.Encrypted, requestDto.Forcesave);
return _filesControllerHelperInt.UpdateFileStreamAsync(_filesControllerHelperInt.GetFileFromRequest(inDto).OpenReadStream(), fileId, inDto.FileExtension, inDto.Encrypted, inDto.Forcesave);
}
private object CopyFile<T>(T fileId, CopyAsRequestDto<JsonElement> requestDto)
private object CopyFile<T>(T fileId, CopyAsRequestDto<JsonElement> inDto)
{
var helper = _serviceProvider.GetService<FilesControllerHelper<T>>();
if (requestDto.DestFolderId.ValueKind == JsonValueKind.Number)
if (inDto.DestFolderId.ValueKind == JsonValueKind.Number)
{
return helper.CopyFileAsAsync(fileId, requestDto.DestFolderId.GetInt32(), requestDto.DestTitle, requestDto.Password);
return helper.CopyFileAsAsync(fileId, inDto.DestFolderId.GetInt32(), inDto.DestTitle, inDto.Password);
}
else if (requestDto.DestFolderId.ValueKind == JsonValueKind.String)
else if (inDto.DestFolderId.ValueKind == JsonValueKind.String)
{
return helper.CopyFileAsAsync(fileId, requestDto.DestFolderId.GetString(), requestDto.DestTitle, requestDto.Password);
return helper.CopyFileAsAsync(fileId, inDto.DestFolderId.GetString(), inDto.DestTitle, inDto.Password);
}
return null;

View File

@ -4,16 +4,19 @@ public class FoldersController : ApiControllerBase
{
private readonly GlobalFolderHelper _globalFolderHelper;
private readonly TenantManager _tenantManager;
private readonly FoldersControllerHelper<int> _foldersControllerHelperInt;
private readonly FoldersControllerHelper<string> _foldersControllerHelperString;
public FoldersController(
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString,
GlobalFolderHelper globalFolderHelper,
TenantManager tenantManage)
: base(filesControllerHelperInt, filesControllerHelperString)
TenantManager tenantManager,
FoldersControllerHelper<int> foldersControllerHelperInt,
FoldersControllerHelper<string> foldersControllerHelperString)
{
_globalFolderHelper = globalFolderHelper;
_tenantManager = tenantManage;
_tenantManager = tenantManager;
_foldersControllerHelperInt = foldersControllerHelperInt;
_foldersControllerHelperString = foldersControllerHelperString;
}
/// <summary>
@ -27,29 +30,29 @@ public class FoldersController : ApiControllerBase
/// <param name="title">Title of new folder</param>
/// <returns>New folder contents</returns>
[Create("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
public Task<FolderDto<string>> CreateFolderFromBodyAsync(string folderId, [FromBody] CreateFolderRequestDto folderRequestDto)
public Task<FolderDto<string>> CreateFolderFromBodyAsync(string folderId, [FromBody] CreateFolderRequestDto inDto)
{
return _filesControllerHelperString.CreateFolderAsync(folderId, folderRequestDto.Title);
return _foldersControllerHelperString.CreateFolderAsync(folderId, inDto.Title);
}
[Create("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
public Task<FolderDto<int>> CreateFolderFromBodyAsync(int folderId, [FromBody] CreateFolderRequestDto folderRequestDto)
public Task<FolderDto<int>> CreateFolderFromBodyAsync(int folderId, [FromBody] CreateFolderRequestDto inDto)
{
return _filesControllerHelperInt.CreateFolderAsync(folderId, folderRequestDto.Title);
return _foldersControllerHelperInt.CreateFolderAsync(folderId, inDto.Title);
}
[Create("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
public Task<FolderDto<string>> CreateFolderFromFormAsync(string folderId, [FromForm] CreateFolderRequestDto folderRequestDto)
public Task<FolderDto<string>> CreateFolderFromFormAsync(string folderId, [FromForm] CreateFolderRequestDto inDto)
{
return _filesControllerHelperString.CreateFolderAsync(folderId, folderRequestDto.Title);
return _foldersControllerHelperString.CreateFolderAsync(folderId, inDto.Title);
}
[Create("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
public Task<FolderDto<int>> CreateFolderFromFormAsync(int folderId, [FromForm] CreateFolderRequestDto folderRequestDto)
public Task<FolderDto<int>> CreateFolderFromFormAsync(int folderId, [FromForm] CreateFolderRequestDto inDto)
{
return _filesControllerHelperInt.CreateFolderAsync(folderId, folderRequestDto.Title);
return _foldersControllerHelperInt.CreateFolderAsync(folderId, inDto.Title);
}
/// <summary>
@ -64,13 +67,13 @@ public class FoldersController : ApiControllerBase
[Delete("folder/{folderId}", order: int.MaxValue - 1, DisableFormat = true)]
public Task<IEnumerable<FileOperationDto>> DeleteFolder(string folderId, bool deleteAfter, bool immediately)
{
return _filesControllerHelperString.DeleteFolder(folderId, deleteAfter, immediately);
return _foldersControllerHelperString.DeleteFolder(folderId, deleteAfter, immediately);
}
[Delete("folder/{folderId:int}")]
public Task<IEnumerable<FileOperationDto>> DeleteFolder(int folderId, bool deleteAfter, bool immediately)
{
return _filesControllerHelperInt.DeleteFolder(folderId, deleteAfter, immediately);
return _foldersControllerHelperInt.DeleteFolder(folderId, deleteAfter, immediately);
}
/// <summary>
@ -84,7 +87,7 @@ public class FoldersController : ApiControllerBase
[Read("@common")]
public async Task<FolderContentDto<int>> GetCommonFolderAsync(Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
return await _filesControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderCommonAsync, userIdOrGroupId, filterType, withsubfolders);
return await _foldersControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderCommonAsync, userIdOrGroupId, filterType, withsubfolders);
}
/// <summary>
@ -96,7 +99,7 @@ public class FoldersController : ApiControllerBase
[Read("@favorites")]
public async Task<FolderContentDto<int>> GetFavoritesFolderAsync(Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
return await _filesControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderFavoritesAsync, userIdOrGroupId, filterType, withsubfolders);
return await _foldersControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderFavoritesAsync, userIdOrGroupId, filterType, withsubfolders);
}
/// <summary>
@ -113,14 +116,15 @@ public class FoldersController : ApiControllerBase
[Read("{folderId}", order: int.MaxValue, DisableFormat = true)]
public async Task<FolderContentDto<string>> GetFolderAsync(string folderId, Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
var folder = await _filesControllerHelperString.GetFolderAsync(folderId, userIdOrGroupId, filterType, withsubfolders);
var folder = await _foldersControllerHelperString.GetFolderAsync(folderId, userIdOrGroupId, filterType, withsubfolders);
return folder.NotFoundIfNull();
}
[Read("{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
public Task<FolderContentDto<int>> GetFolderAsync(int folderId, Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
return _filesControllerHelperInt.GetFolderAsync(folderId, userIdOrGroupId, filterType, withsubfolders);
return _foldersControllerHelperInt.GetFolderAsync(folderId, userIdOrGroupId, filterType, withsubfolders);
}
/// <summary>
@ -132,13 +136,13 @@ public class FoldersController : ApiControllerBase
[Read("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
public Task<FolderDto<string>> GetFolderInfoAsync(string folderId)
{
return _filesControllerHelperString.GetFolderInfoAsync(folderId);
return _foldersControllerHelperString.GetFolderInfoAsync(folderId);
}
[Read("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
public Task<FolderDto<int>> GetFolderInfoAsync(int folderId)
{
return _filesControllerHelperInt.GetFolderInfoAsync(folderId);
return _foldersControllerHelperInt.GetFolderInfoAsync(folderId);
}
/// <summary>
@ -150,25 +154,25 @@ public class FoldersController : ApiControllerBase
[Read("folder/{folderId}/path")]
public IAsyncEnumerable<FileEntryDto> GetFolderPathAsync(string folderId)
{
return _filesControllerHelperString.GetFolderPathAsync(folderId);
return _foldersControllerHelperString.GetFolderPathAsync(folderId);
}
[Read("folder/{folderId:int}/path")]
public IAsyncEnumerable<FileEntryDto> GetFolderPathAsync(int folderId)
{
return _filesControllerHelperInt.GetFolderPathAsync(folderId);
return _foldersControllerHelperInt.GetFolderPathAsync(folderId);
}
[Read("{folderId}/subfolders")]
public IAsyncEnumerable<FileEntryDto> GetFoldersAsync(string folderId)
{
return _filesControllerHelperString.GetFoldersAsync(folderId);
return _foldersControllerHelperString.GetFoldersAsync(folderId);
}
[Read("{folderId:int}/subfolders")]
public IAsyncEnumerable<FileEntryDto> GetFoldersAsync(int folderId)
{
return _filesControllerHelperInt.GetFoldersAsync(folderId);
return _foldersControllerHelperInt.GetFoldersAsync(folderId);
}
/// <summary>
@ -182,19 +186,19 @@ public class FoldersController : ApiControllerBase
[Read("@my")]
public Task<FolderContentDto<int>> GetMyFolderAsync(Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
return _filesControllerHelperInt.GetFolderAsync(_globalFolderHelper.FolderMy, userIdOrGroupId, filterType, withsubfolders);
return _foldersControllerHelperInt.GetFolderAsync(_globalFolderHelper.FolderMy, userIdOrGroupId, filterType, withsubfolders);
}
[Read("{folderId}/news")]
public Task<List<FileEntryDto>> GetNewItemsAsync(string folderId)
{
return _filesControllerHelperString.GetNewItemsAsync(folderId);
return _foldersControllerHelperString.GetNewItemsAsync(folderId);
}
[Read("{folderId:int}/news")]
public Task<List<FileEntryDto>> GetNewItemsAsync(int folderId)
{
return _filesControllerHelperInt.GetNewItemsAsync(folderId);
return _foldersControllerHelperInt.GetNewItemsAsync(folderId);
}
[Read("@privacy")]
@ -219,7 +223,7 @@ public class FoldersController : ApiControllerBase
[Read("@projects")]
public async Task<FolderContentDto<string>> GetProjectsFolderAsync(Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
return await _filesControllerHelperString.GetFolderAsync(await _globalFolderHelper.GetFolderProjectsAsync<string>(), userIdOrGroupId, filterType, withsubfolders);
return await _foldersControllerHelperString.GetFolderAsync(await _globalFolderHelper.GetFolderProjectsAsync<string>(), userIdOrGroupId, filterType, withsubfolders);
}
/// <summary>
@ -231,19 +235,19 @@ public class FoldersController : ApiControllerBase
[Read("@recent")]
public async Task<FolderContentDto<int>> GetRecentFolderAsync(Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
return await _filesControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderRecentAsync, userIdOrGroupId, filterType, withsubfolders);
return await _foldersControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderRecentAsync, userIdOrGroupId, filterType, withsubfolders);
}
[Read("@root")]
public async Task<IEnumerable<FolderContentDto<int>>> GetRootFoldersAsync(Guid userIdOrGroupId, FilterType filterType, bool withsubfolders, bool withoutTrash, bool withoutAdditionalFolder)
{
var foldersIds = await _filesControllerHelperInt.GetRootFoldersIdsAsync(withoutTrash, withoutAdditionalFolder);
var foldersIds = await _foldersControllerHelperInt.GetRootFoldersIdsAsync(withoutTrash, withoutAdditionalFolder);
var result = new List<FolderContentDto<int>>();
foreach (var folder in foldersIds)
{
result.Add(await _filesControllerHelperInt.GetFolderAsync(folder, userIdOrGroupId, filterType, withsubfolders));
result.Add(await _foldersControllerHelperInt.GetFolderAsync(folder, userIdOrGroupId, filterType, withsubfolders));
}
return result;
@ -259,7 +263,7 @@ public class FoldersController : ApiControllerBase
[Read("@share")]
public async Task<FolderContentDto<int>> GetShareFolderAsync(Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
return await _filesControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderShareAsync, userIdOrGroupId, filterType, withsubfolders);
return await _foldersControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderShareAsync, userIdOrGroupId, filterType, withsubfolders);
}
/// <summary>
@ -271,7 +275,7 @@ public class FoldersController : ApiControllerBase
[Read("@templates")]
public async Task<FolderContentDto<int>> GetTemplatesFolderAsync(Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
return await _filesControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderTemplatesAsync, userIdOrGroupId, filterType, withsubfolders);
return await _foldersControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderTemplatesAsync, userIdOrGroupId, filterType, withsubfolders);
}
/// <summary>
@ -285,7 +289,7 @@ public class FoldersController : ApiControllerBase
[Read("@trash")]
public Task<FolderContentDto<int>> GetTrashFolderAsync(Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
return _filesControllerHelperInt.GetFolderAsync(Convert.ToInt32(_globalFolderHelper.FolderTrash), userIdOrGroupId, filterType, withsubfolders);
return _foldersControllerHelperInt.GetFolderAsync(Convert.ToInt32(_globalFolderHelper.FolderTrash), userIdOrGroupId, filterType, withsubfolders);
}
/// <summary>
@ -299,33 +303,33 @@ public class FoldersController : ApiControllerBase
/// <param name="title">New title</param>
/// <returns>Folder contents</returns>
[Update("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
public Task<FolderDto<string>> RenameFolderFromBodyAsync(string folderId, [FromBody] CreateFolderRequestDto folderRequestDto)
public Task<FolderDto<string>> RenameFolderFromBodyAsync(string folderId, [FromBody] CreateFolderRequestDto inDto)
{
return _filesControllerHelperString.RenameFolderAsync(folderId, folderRequestDto.Title);
return _foldersControllerHelperString.RenameFolderAsync(folderId, inDto.Title);
}
[Update("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
public Task<FolderDto<int>> RenameFolderFromBodyAsync(int folderId, [FromBody] CreateFolderRequestDto folderRequestDto)
public Task<FolderDto<int>> RenameFolderFromBodyAsync(int folderId, [FromBody] CreateFolderRequestDto inDto)
{
return _filesControllerHelperInt.RenameFolderAsync(folderId, folderRequestDto.Title);
return _foldersControllerHelperInt.RenameFolderAsync(folderId, inDto.Title);
}
[Update("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
public Task<FolderDto<string>> RenameFolderFromFormAsync(string folderId, [FromForm] CreateFolderRequestDto folderRequestDto)
public Task<FolderDto<string>> RenameFolderFromFormAsync(string folderId, [FromForm] CreateFolderRequestDto inDto)
{
return _filesControllerHelperString.RenameFolderAsync(folderId, folderRequestDto.Title);
return _foldersControllerHelperString.RenameFolderAsync(folderId, inDto.Title);
}
[Update("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
public Task<FolderDto<int>> RenameFolderFromFormAsync(int folderId, [FromForm] CreateFolderRequestDto folderRequestDto)
public Task<FolderDto<int>> RenameFolderFromFormAsync(int folderId, [FromForm] CreateFolderRequestDto inDto)
{
return _filesControllerHelperInt.RenameFolderAsync(folderId, folderRequestDto.Title);
return _foldersControllerHelperInt.RenameFolderAsync(folderId, inDto.Title);
}
private async Task<FolderContentDto<int>> InternalGetPrivacyFolderAsync(Guid userIdOrGroupId, FilterType filterType, bool withsubfolders)
{
return await _filesControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderPrivacyAsync, userIdOrGroupId, filterType, withsubfolders);
return await _foldersControllerHelperInt.GetFolderAsync(await _globalFolderHelper.FolderPrivacyAsync, userIdOrGroupId, filterType, withsubfolders);
}
}

View File

@ -2,36 +2,38 @@
public class MasterFormController : ApiControllerBase
{
public MasterFormController(
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString)
: base(filesControllerHelperInt, filesControllerHelperString)
private readonly FileStorageService<int> _fileStorageServiceInt;
private readonly FileStorageService<string> _fileStorageServiceString;
public MasterFormController(FileStorageService<int> fileStorageServiceInt, FileStorageService<string> fileStorageServiceString)
{
_fileStorageServiceInt = fileStorageServiceInt;
_fileStorageServiceString = fileStorageServiceString;
}
[Create("masterform/{fileId}/checkfillformdraft")]
public async Task<object> CheckFillFormDraftFromBodyAsync(string fileId, [FromBody] CheckFillFormDraftRequestDto requestDto)
public async Task<object> CheckFillFormDraftFromBodyAsync(string fileId, [FromBody] CheckFillFormDraftRequestDto inDto)
{
return await _filesControllerHelperString.CheckFillFormDraftAsync(fileId, requestDto.Version, requestDto.Doc, !requestDto.RequestEmbedded, requestDto.RequestView);
return await _fileStorageServiceString.CheckFillFormDraftAsync(fileId, inDto.Version, inDto.Doc, !inDto.RequestEmbedded, inDto.RequestView);
}
[Create("masterform/{fileId}/checkfillformdraft")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<object> CheckFillFormDraftFromFormAsync(string fileId, [FromForm] CheckFillFormDraftRequestDto requestDto)
public async Task<object> CheckFillFormDraftFromFormAsync(string fileId, [FromForm] CheckFillFormDraftRequestDto inDto)
{
return await _filesControllerHelperString.CheckFillFormDraftAsync(fileId, requestDto.Version, requestDto.Doc, !requestDto.RequestEmbedded, requestDto.RequestView);
return await _fileStorageServiceString.CheckFillFormDraftAsync(fileId, inDto.Version, inDto.Doc, !inDto.RequestEmbedded, inDto.RequestView);
}
[Create("masterform/{fileId:int}/checkfillformdraft")]
public async Task<object> CheckFillFormDraftFromBodyAsync(int fileId, [FromBody] CheckFillFormDraftRequestDto requestDto)
public async Task<object> CheckFillFormDraftFromBodyAsync(int fileId, [FromBody] CheckFillFormDraftRequestDto inDto)
{
return await _filesControllerHelperInt.CheckFillFormDraftAsync(fileId, requestDto.Version, requestDto.Doc, !requestDto.RequestEmbedded, requestDto.RequestView);
return await _fileStorageServiceInt.CheckFillFormDraftAsync(fileId, inDto.Version, inDto.Doc, !inDto.RequestEmbedded, inDto.RequestView);
}
[Create("masterform/{fileId:int}/checkfillformdraft")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<object> CheckFillFormDraftFromFormAsync(int fileId, [FromForm] CheckFillFormDraftRequestDto requestDto)
public async Task<object> CheckFillFormDraftFromFormAsync(int fileId, [FromForm] CheckFillFormDraftRequestDto inDto)
{
return await _filesControllerHelperInt.CheckFillFormDraftAsync(fileId, requestDto.Version, requestDto.Doc, !requestDto.RequestEmbedded, requestDto.RequestView);
return await _fileStorageServiceInt.CheckFillFormDraftAsync(fileId, inDto.Version, inDto.Doc, !inDto.RequestEmbedded, inDto.RequestView);
}
}

View File

@ -4,16 +4,19 @@ public class OperationController : ApiControllerBase
{
private readonly FileOperationDtoHelper _fileOperationWraperHelper;
private readonly FileStorageService<string> _fileStorageServiceString;
private readonly OperationControllerHelper<string> _operationControllerHelperString;
private readonly OperationControllerHelper<int> _operationControllerHelperInt;
public OperationController(
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString,
FileOperationDtoHelper fileOperationWraperHelper,
FileStorageService<string> fileStorageServiceString)
: base(filesControllerHelperInt, filesControllerHelperString)
FileStorageService<string> fileStorageServiceString,
OperationControllerHelper<string> operationControllerHelperString,
OperationControllerHelper<int> operationControllerHelperInt)
{
_fileOperationWraperHelper = fileOperationWraperHelper;
_fileStorageServiceString = fileStorageServiceString;
_operationControllerHelperString = operationControllerHelperString;
_operationControllerHelperInt = operationControllerHelperInt;
}
/// <summary>
@ -26,16 +29,16 @@ public class OperationController : ApiControllerBase
/// <category>File operations</category>
/// <returns>Operation result</returns>
[Update("fileops/bulkdownload")]
public Task<IEnumerable<FileOperationDto>> BulkDownload([FromBody] DownloadRequestDto requestDto)
public Task<IEnumerable<FileOperationDto>> BulkDownload([FromBody] DownloadRequestDto inDto)
{
return _filesControllerHelperString.BulkDownloadAsync(requestDto);
return _operationControllerHelperString.BulkDownloadAsync(inDto);
}
[Update("fileops/bulkdownload")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileOperationDto>> BulkDownloadFromForm([FromForm] DownloadRequestDto requestDto)
public Task<IEnumerable<FileOperationDto>> BulkDownloadFromForm([FromForm] DownloadRequestDto inDto)
{
return _filesControllerHelperString.BulkDownloadAsync(requestDto);
return _operationControllerHelperString.BulkDownloadAsync(inDto);
}
/// <summary>
@ -50,16 +53,16 @@ public class OperationController : ApiControllerBase
/// <param name="deleteAfter">Delete after finished</param>
/// <returns>Operation result</returns>
[Update("fileops/copy")]
public Task<IEnumerable<FileOperationDto>> CopyBatchItemsFromBody([FromBody] BatchRequestDto requestDto)
public Task<IEnumerable<FileOperationDto>> CopyBatchItemsFromBody([FromBody] BatchRequestDto inDto)
{
return _filesControllerHelperString.CopyBatchItemsAsync(requestDto);
return _operationControllerHelperString.CopyBatchItemsAsync(inDto);
}
[Update("fileops/copy")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileOperationDto>> CopyBatchItemsFromForm([FromForm][ModelBinder(BinderType = typeof(BatchModelBinder))] BatchRequestDto requestDto)
public Task<IEnumerable<FileOperationDto>> CopyBatchItemsFromForm([FromForm][ModelBinder(BinderType = typeof(BatchModelBinder))] BatchRequestDto inDto)
{
return _filesControllerHelperString.CopyBatchItemsAsync(requestDto);
return _operationControllerHelperString.CopyBatchItemsAsync(inDto);
}
/// <summary>
@ -73,9 +76,9 @@ public class OperationController : ApiControllerBase
/// <category>File operations</category>
/// <returns>Operation result</returns>
[Update("fileops/delete")]
public async IAsyncEnumerable<FileOperationDto> DeleteBatchItemsFromBody([FromBody] DeleteBatchRequestDto requestDto)
public async IAsyncEnumerable<FileOperationDto> DeleteBatchItemsFromBody([FromBody] DeleteBatchRequestDto inDto)
{
var tasks = _fileStorageServiceString.DeleteItems("delete", requestDto.FileIds.ToList(), requestDto.FolderIds.ToList(), false, requestDto.DeleteAfter, requestDto.Immediately);
var tasks = _fileStorageServiceString.DeleteItems("delete", inDto.FileIds.ToList(), inDto.FolderIds.ToList(), false, inDto.DeleteAfter, inDto.Immediately);
foreach (var e in tasks)
{
@ -85,9 +88,9 @@ public class OperationController : ApiControllerBase
[Update("fileops/delete")]
[Consumes("application/x-www-form-urlencoded")]
public async IAsyncEnumerable<FileOperationDto> DeleteBatchItemsFromForm([FromForm][ModelBinder(BinderType = typeof(DeleteBatchModelBinder))] DeleteBatchRequestDto requestDto)
public async IAsyncEnumerable<FileOperationDto> DeleteBatchItemsFromForm([FromForm][ModelBinder(BinderType = typeof(DeleteBatchModelBinder))] DeleteBatchRequestDto inDto)
{
var tasks = _fileStorageServiceString.DeleteItems("delete", requestDto.FileIds.ToList(), requestDto.FolderIds.ToList(), false, requestDto.DeleteAfter, requestDto.Immediately);
var tasks = _fileStorageServiceString.DeleteItems("delete", inDto.FileIds.ToList(), inDto.FolderIds.ToList(), false, inDto.DeleteAfter, inDto.Immediately);
foreach (var e in tasks)
{
@ -104,7 +107,7 @@ public class OperationController : ApiControllerBase
[Update("fileops/emptytrash")]
public Task<IEnumerable<FileOperationDto>> EmptyTrashAsync()
{
return _filesControllerHelperInt.EmptyTrashAsync();
return _operationControllerHelperInt.EmptyTrashAsync();
}
/// <summary>
@ -133,16 +136,16 @@ public class OperationController : ApiControllerBase
/// <category>File operations</category>
/// <returns>Operation result</returns>
[Update("fileops/markasread")]
public Task<IEnumerable<FileOperationDto>> MarkAsReadFromBody([FromBody] BaseBatchRequestDto requestDto)
public Task<IEnumerable<FileOperationDto>> MarkAsReadFromBody([FromBody] BaseBatchRequestDto inDto)
{
return _filesControllerHelperString.MarkAsReadAsync(requestDto);
return _operationControllerHelperString.MarkAsReadAsync(inDto);
}
[Update("fileops/markasread")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileOperationDto>> MarkAsReadFromForm([FromForm][ModelBinder(BinderType = typeof(BaseBatchModelBinder))] BaseBatchRequestDto requestDto)
public Task<IEnumerable<FileOperationDto>> MarkAsReadFromForm([FromForm][ModelBinder(BinderType = typeof(BaseBatchModelBinder))] BaseBatchRequestDto inDto)
{
return _filesControllerHelperString.MarkAsReadAsync(requestDto);
return _operationControllerHelperString.MarkAsReadAsync(inDto);
}
/// <summary>
@ -157,16 +160,16 @@ public class OperationController : ApiControllerBase
/// <param name="deleteAfter">Delete after finished</param>
/// <returns>Operation result</returns>
[Update("fileops/move")]
public Task<IEnumerable<FileOperationDto>> MoveBatchItemsFromBody([FromBody] BatchRequestDto requestDto)
public Task<IEnumerable<FileOperationDto>> MoveBatchItemsFromBody([FromBody] BatchRequestDto inDto)
{
return _filesControllerHelperString.MoveBatchItemsAsync(requestDto);
return _operationControllerHelperString.MoveBatchItemsAsync(inDto);
}
[Update("fileops/move")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileOperationDto>> MoveBatchItemsFromForm([FromForm][ModelBinder(BinderType = typeof(BatchModelBinder))] BatchRequestDto requestDto)
public Task<IEnumerable<FileOperationDto>> MoveBatchItemsFromForm([FromForm][ModelBinder(BinderType = typeof(BatchModelBinder))] BatchRequestDto inDto)
{
return _filesControllerHelperString.MoveBatchItemsAsync(requestDto);
return _operationControllerHelperString.MoveBatchItemsAsync(inDto);
}
/// <summary>
@ -178,9 +181,9 @@ public class OperationController : ApiControllerBase
/// <param name="fileIds">File ID list</param>
/// <returns>Conflicts file ids</returns>
[Read("fileops/move")]
public IAsyncEnumerable<FileEntryDto> MoveOrCopyBatchCheckAsync([ModelBinder(BinderType = typeof(BatchModelBinder))] BatchRequestDto requestDto)
public IAsyncEnumerable<FileEntryDto> MoveOrCopyBatchCheckAsync([ModelBinder(BinderType = typeof(BatchModelBinder))] BatchRequestDto inDto)
{
return _filesControllerHelperString.MoveOrCopyBatchCheckAsync(requestDto);
return _operationControllerHelperString.MoveOrCopyBatchCheckAsync(inDto);
}
/// <summary>
/// Finishes all the active file operations

View File

@ -71,7 +71,10 @@ public class PrivacyRoomController : ControllerBase
{
_permissionContext.DemandPermissions(new UserSecurityProvider(_authContext.CurrentAccount.ID), Constants.Action_EditUser);
if (!PrivacyRoomSettings.GetEnabled(_settingsManager)) throw new System.Security.SecurityException();
if (!PrivacyRoomSettings.GetEnabled(_settingsManager))
{
throw new System.Security.SecurityException();
}
return _encryptionKeyPairHelper.GetKeyPair();
}
@ -83,7 +86,10 @@ public class PrivacyRoomController : ControllerBase
[Read("access/{fileId}")]
public Task<IEnumerable<EncryptionKeyPairDto>> GetPublicKeysWithAccess(string fileId)
{
if (!PrivacyRoomSettings.GetEnabled(_settingsManager)) throw new System.Security.SecurityException();
if (!PrivacyRoomSettings.GetEnabled(_settingsManager))
{
throw new System.Security.SecurityException();
}
return _encryptionKeyPairHelper.GetKeyPairAsync(fileId, _fileStorageService);
}
@ -91,7 +97,10 @@ public class PrivacyRoomController : ControllerBase
[Read("access/{fileId:int}")]
public Task<IEnumerable<EncryptionKeyPairDto>> GetPublicKeysWithAccess(int fileId)
{
if (!PrivacyRoomSettings.GetEnabled(_settingsManager)) throw new System.Security.SecurityException();
if (!PrivacyRoomSettings.GetEnabled(_settingsManager))
{
throw new System.Security.SecurityException();
}
return _encryptionKeyPairHelper.GetKeyPairAsync(fileId, _fileStorageServiceInt);
}
@ -114,16 +123,16 @@ public class PrivacyRoomController : ControllerBase
/// </summary>
/// <visible>false</visible>
[Update("keys")]
public object SetKeysFromBody([FromBody] PrivacyRoomRequestDto requestDto)
public object SetKeysFromBody([FromBody] PrivacyRoomRequestDto inDto)
{
return SetKeys(requestDto);
return SetKeys(inDto);
}
[Update("keys")]
[Consumes("application/x-www-form-urlencoded")]
public object SetKeysFromForm([FromForm] PrivacyRoomRequestDto requestDto)
public object SetKeysFromForm([FromForm] PrivacyRoomRequestDto inDto)
{
return SetKeys(requestDto);
return SetKeys(inDto);
}
/// <summary>
@ -133,28 +142,31 @@ public class PrivacyRoomController : ControllerBase
/// <returns></returns>
/// <visible>false</visible>
[Update("")]
public bool SetPrivacyRoomFromBody([FromBody] PrivacyRoomRequestDto requestDto)
public bool SetPrivacyRoomFromBody([FromBody] PrivacyRoomRequestDto inDto)
{
return SetPrivacyRoom(requestDto);
return SetPrivacyRoom(inDto);
}
[Update("")]
[Consumes("application/x-www-form-urlencoded")]
public bool SetPrivacyRoomFromForm([FromForm] PrivacyRoomRequestDto requestDto)
public bool SetPrivacyRoomFromForm([FromForm] PrivacyRoomRequestDto inDto)
{
return SetPrivacyRoom(requestDto);
return SetPrivacyRoom(inDto);
}
private object SetKeys(PrivacyRoomRequestDto requestDto)
private object SetKeys(PrivacyRoomRequestDto inDto)
{
_permissionContext.DemandPermissions(new UserSecurityProvider(_authContext.CurrentAccount.ID), Constants.Action_EditUser);
if (!PrivacyRoomSettings.GetEnabled(_settingsManager)) throw new System.Security.SecurityException();
if (!PrivacyRoomSettings.GetEnabled(_settingsManager))
{
throw new System.Security.SecurityException();
}
var keyPair = _encryptionKeyPairHelper.GetKeyPair();
if (keyPair != null)
{
if (!string.IsNullOrEmpty(keyPair.PublicKey) && !requestDto.Update)
if (!string.IsNullOrEmpty(keyPair.PublicKey) && !inDto.Update)
{
return new { isset = true };
}
@ -162,7 +174,7 @@ public class PrivacyRoomController : ControllerBase
_logger.InfoFormat("User {0} updates address", _authContext.CurrentAccount.ID);
}
_encryptionKeyPairHelper.SetKeyPair(requestDto.PublicKey, requestDto.PrivateKeyEnc);
_encryptionKeyPairHelper.SetKeyPair(inDto.PublicKey, inDto.PrivateKeyEnc);
return new
{
@ -170,11 +182,11 @@ public class PrivacyRoomController : ControllerBase
};
}
private bool SetPrivacyRoom(PrivacyRoomRequestDto requestDto)
private bool SetPrivacyRoom(PrivacyRoomRequestDto inDto)
{
_permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
if (requestDto.Enable)
if (inDto.Enable)
{
if (!PrivacyRoomSettings.IsAvailable(_tenantManager))
{
@ -182,10 +194,10 @@ public class PrivacyRoomController : ControllerBase
}
}
PrivacyRoomSettings.SetEnabled(_tenantManager, _settingsManager, requestDto.Enable);
PrivacyRoomSettings.SetEnabled(_tenantManager, _settingsManager, inDto.Enable);
_messageService.Send(requestDto.Enable ? MessageAction.PrivacyRoomEnable : MessageAction.PrivacyRoomDisable);
_messageService.Send(inDto.Enable ? MessageAction.PrivacyRoomEnable : MessageAction.PrivacyRoomDisable);
return requestDto.Enable;
return inDto.Enable;
}
}

View File

@ -4,29 +4,32 @@ public class SecutiryController : ApiControllerBase
{
private readonly FileStorageService<int> _fileStorageServiceInt;
private readonly FileStorageService<string> _fileStorageServiceString;
private readonly SecurityControllerHelper<int> _securityControllerHelperInt;
private readonly SecurityControllerHelper<string> _securityControllerHelperString;
public SecutiryController(
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString,
FileStorageService<int> fileStorageServiceInt,
FileStorageService<string> fileStorageServiceString)
: base(filesControllerHelperInt, filesControllerHelperString)
FileStorageService<string> fileStorageServiceString,
SecurityControllerHelper<int> securityControllerHelperInt,
SecurityControllerHelper<string> securityControllerHelperString)
{
_fileStorageServiceString = fileStorageServiceString;
_fileStorageServiceInt = fileStorageServiceInt;
_fileStorageServiceString = fileStorageServiceString;
_securityControllerHelperInt = securityControllerHelperInt;
_securityControllerHelperString = securityControllerHelperString;
}
[Create("owner")]
public IAsyncEnumerable<FileEntryDto> ChangeOwnerFromBodyAsync([FromBody] ChangeOwnerRequestDto requestDto)
public IAsyncEnumerable<FileEntryDto> ChangeOwnerFromBodyAsync([FromBody] ChangeOwnerRequestDto inDto)
{
return ChangeOwnerAsync(requestDto);
return ChangeOwnerAsync(inDto);
}
[Create("owner")]
[Consumes("application/x-www-form-urlencoded")]
public IAsyncEnumerable<FileEntryDto> ChangeOwnerFromFormAsync([FromForm] ChangeOwnerRequestDto requestDto)
public IAsyncEnumerable<FileEntryDto> ChangeOwnerFromFormAsync([FromForm] ChangeOwnerRequestDto inDto)
{
return ChangeOwnerAsync(requestDto);
return ChangeOwnerAsync(inDto);
}
/// <summary>
@ -40,29 +43,29 @@ public class SecutiryController : ApiControllerBase
/// <category>Files</category>
/// <returns>Shared file link</returns>
[Update("{fileId}/sharedlinkAsync")]
public async Task<object> GenerateSharedLinkFromBodyAsync(string fileId, [FromBody] GenerateSharedLinkRequestDto requestDto)
public async Task<object> GenerateSharedLinkFromBodyAsync(string fileId, [FromBody] GenerateSharedLinkRequestDto inDto)
{
return await _filesControllerHelperString.GenerateSharedLinkAsync(fileId, requestDto.Share);
return await _securityControllerHelperString.GenerateSharedLinkAsync(fileId, inDto.Share);
}
[Update("{fileId:int}/sharedlinkAsync")]
public async Task<object> GenerateSharedLinkFromBodyAsync(int fileId, [FromBody] GenerateSharedLinkRequestDto requestDto)
public async Task<object> GenerateSharedLinkFromBodyAsync(int fileId, [FromBody] GenerateSharedLinkRequestDto inDto)
{
return await _filesControllerHelperInt.GenerateSharedLinkAsync(fileId, requestDto.Share);
return await _securityControllerHelperInt.GenerateSharedLinkAsync(fileId, inDto.Share);
}
[Update("{fileId}/sharedlinkAsync")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<object> GenerateSharedLinkFromFormAsync(string fileId, [FromForm] GenerateSharedLinkRequestDto requestDto)
public async Task<object> GenerateSharedLinkFromFormAsync(string fileId, [FromForm] GenerateSharedLinkRequestDto inDto)
{
return await _filesControllerHelperString.GenerateSharedLinkAsync(fileId, requestDto.Share);
return await _securityControllerHelperString.GenerateSharedLinkAsync(fileId, inDto.Share);
}
[Update("{fileId:int}/sharedlinkAsync")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<object> GenerateSharedLinkFromFormAsync(int fileId, [FromForm] GenerateSharedLinkRequestDto requestDto)
public async Task<object> GenerateSharedLinkFromFormAsync(int fileId, [FromForm] GenerateSharedLinkRequestDto inDto)
{
return await _filesControllerHelperInt.GenerateSharedLinkAsync(fileId, requestDto.Share);
return await _securityControllerHelperInt.GenerateSharedLinkAsync(fileId, inDto.Share);
}
/// <summary>
@ -75,13 +78,13 @@ public class SecutiryController : ApiControllerBase
[Read("file/{fileId}/share")]
public Task<IEnumerable<FileShareDto>> GetFileSecurityInfoAsync(string fileId)
{
return _filesControllerHelperString.GetFileSecurityInfoAsync(fileId);
return _securityControllerHelperString.GetFileSecurityInfoAsync(fileId);
}
[Read("file/{fileId:int}/share")]
public Task<IEnumerable<FileShareDto>> GetFileSecurityInfoAsync(int fileId)
{
return _filesControllerHelperInt.GetFileSecurityInfoAsync(fileId);
return _securityControllerHelperInt.GetFileSecurityInfoAsync(fileId);
}
/// <summary>
@ -94,38 +97,38 @@ public class SecutiryController : ApiControllerBase
[Read("folder/{folderId}/share")]
public Task<IEnumerable<FileShareDto>> GetFolderSecurityInfoAsync(string folderId)
{
return _filesControllerHelperString.GetFolderSecurityInfoAsync(folderId);
return _securityControllerHelperString.GetFolderSecurityInfoAsync(folderId);
}
[Read("folder/{folderId:int}/share")]
public Task<IEnumerable<FileShareDto>> GetFolderSecurityInfoAsync(int folderId)
{
return _filesControllerHelperInt.GetFolderSecurityInfoAsync(folderId);
return _securityControllerHelperInt.GetFolderSecurityInfoAsync(folderId);
}
[Create("share")]
public async Task<IEnumerable<FileShareDto>> GetSecurityInfoFromBodyAsync([FromBody] BaseBatchRequestDto requestDto)
public async Task<IEnumerable<FileShareDto>> GetSecurityInfoFromBodyAsync([FromBody] BaseBatchRequestDto inDto)
{
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(requestDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(requestDto.FileIds);
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(inDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(inDto.FileIds);
var result = new List<FileShareDto>();
result.AddRange(await _filesControllerHelperInt.GetSecurityInfoAsync(fileIntIds, folderIntIds));
result.AddRange(await _filesControllerHelperString.GetSecurityInfoAsync(fileStringIds, folderStringIds));
result.AddRange(await _securityControllerHelperInt.GetSecurityInfoAsync(fileIntIds, folderIntIds));
result.AddRange(await _securityControllerHelperString.GetSecurityInfoAsync(fileStringIds, folderStringIds));
return result;
}
[Create("share")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<IEnumerable<FileShareDto>> GetSecurityInfoFromFormAsync([FromForm][ModelBinder(BinderType = typeof(BaseBatchModelBinder))] BaseBatchRequestDto requestDto)
public async Task<IEnumerable<FileShareDto>> GetSecurityInfoFromFormAsync([FromForm][ModelBinder(BinderType = typeof(BaseBatchModelBinder))] BaseBatchRequestDto inDto)
{
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(requestDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(requestDto.FileIds);
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(inDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(inDto.FileIds);
var result = new List<FileShareDto>();
result.AddRange(await _filesControllerHelperInt.GetSecurityInfoAsync(fileIntIds, folderIntIds));
result.AddRange(await _filesControllerHelperString.GetSecurityInfoAsync(fileStringIds, folderStringIds));
result.AddRange(await _securityControllerHelperInt.GetSecurityInfoAsync(fileIntIds, folderIntIds));
result.AddRange(await _securityControllerHelperString.GetSecurityInfoAsync(fileStringIds, folderStringIds));
return result;
}
@ -139,27 +142,27 @@ public class SecutiryController : ApiControllerBase
/// <category>Sharing</category>
/// <returns>Shared file information</returns>
[Delete("share")]
public async Task<bool> RemoveSecurityInfoAsync(BaseBatchRequestDto requestDto)
public async Task<bool> RemoveSecurityInfoAsync(BaseBatchRequestDto inDto)
{
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(requestDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(requestDto.FileIds);
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(inDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(inDto.FileIds);
await _filesControllerHelperInt.RemoveSecurityInfoAsync(fileIntIds, folderIntIds);
await _filesControllerHelperString.RemoveSecurityInfoAsync(fileStringIds, folderStringIds);
await _securityControllerHelperInt.RemoveSecurityInfoAsync(fileIntIds, folderIntIds);
await _securityControllerHelperString.RemoveSecurityInfoAsync(fileStringIds, folderStringIds);
return true;
}
[Update("{fileId:int}/setacelink")]
public Task<bool> SetAceLinkAsync(int fileId, [FromBody] GenerateSharedLinkRequestDto requestDto)
public Task<bool> SetAceLinkAsync(int fileId, [FromBody] GenerateSharedLinkRequestDto inDto)
{
return _filesControllerHelperInt.SetAceLinkAsync(fileId, requestDto.Share);
return _fileStorageServiceInt.SetAceLinkAsync(fileId, inDto.Share);
}
[Update("{fileId}/setacelink")]
public Task<bool> SetAceLinkAsync(string fileId, [FromBody] GenerateSharedLinkRequestDto requestDto)
public Task<bool> SetAceLinkAsync(string fileId, [FromBody] GenerateSharedLinkRequestDto inDto)
{
return _filesControllerHelperString.SetAceLinkAsync(fileId, requestDto.Share);
return _fileStorageServiceString.SetAceLinkAsync(fileId, inDto.Share);
}
/// <summary>
@ -176,29 +179,29 @@ public class SecutiryController : ApiControllerBase
/// </remarks>
/// <returns>Shared file information</returns>
[Update("file/{fileId}/share")]
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoFromBodyAsync(string fileId, [FromBody] SecurityInfoRequestDto requestDto)
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoFromBodyAsync(string fileId, [FromBody] SecurityInfoRequestDto inDto)
{
return _filesControllerHelperString.SetFileSecurityInfoAsync(fileId, requestDto.Share, requestDto.Notify, requestDto.SharingMessage);
return _securityControllerHelperString.SetFileSecurityInfoAsync(fileId, inDto.Share, inDto.Notify, inDto.SharingMessage);
}
[Update("file/{fileId:int}/share")]
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoFromBodyAsync(int fileId, [FromBody] SecurityInfoRequestDto requestDto)
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoFromBodyAsync(int fileId, [FromBody] SecurityInfoRequestDto inDto)
{
return _filesControllerHelperInt.SetFileSecurityInfoAsync(fileId, requestDto.Share, requestDto.Notify, requestDto.SharingMessage);
return _securityControllerHelperInt.SetFileSecurityInfoAsync(fileId, inDto.Share, inDto.Notify, inDto.SharingMessage);
}
[Update("file/{fileId}/share")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoFromFormAsync(string fileId, [FromForm] SecurityInfoRequestDto requestDto)
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoFromFormAsync(string fileId, [FromForm] SecurityInfoRequestDto inDto)
{
return _filesControllerHelperString.SetFileSecurityInfoAsync(fileId, requestDto.Share, requestDto.Notify, requestDto.SharingMessage);
return _securityControllerHelperString.SetFileSecurityInfoAsync(fileId, inDto.Share, inDto.Notify, inDto.SharingMessage);
}
[Update("file/{fileId:int}/share")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoFromFormAsync(int fileId, [FromForm] SecurityInfoRequestDto requestDto)
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoFromFormAsync(int fileId, [FromForm] SecurityInfoRequestDto inDto)
{
return _filesControllerHelperInt.SetFileSecurityInfoAsync(fileId, requestDto.Share, requestDto.Notify, requestDto.SharingMessage);
return _securityControllerHelperInt.SetFileSecurityInfoAsync(fileId, inDto.Share, inDto.Notify, inDto.SharingMessage);
}
/// <summary>
@ -215,67 +218,67 @@ public class SecutiryController : ApiControllerBase
/// <category>Sharing</category>
/// <returns>Shared folder information</returns>
[Update("folder/{folderId}/share")]
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoFromBodyAsync(string folderId, [FromBody] SecurityInfoRequestDto requestDto)
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoFromBodyAsync(string folderId, [FromBody] SecurityInfoRequestDto inDto)
{
return _filesControllerHelperString.SetFolderSecurityInfoAsync(folderId, requestDto.Share, requestDto.Notify, requestDto.SharingMessage);
return _securityControllerHelperString.SetFolderSecurityInfoAsync(folderId, inDto.Share, inDto.Notify, inDto.SharingMessage);
}
[Update("folder/{folderId:int}/share")]
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoFromBodyAsync(int folderId, [FromBody] SecurityInfoRequestDto requestDto)
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoFromBodyAsync(int folderId, [FromBody] SecurityInfoRequestDto inDto)
{
return _filesControllerHelperInt.SetFolderSecurityInfoAsync(folderId, requestDto.Share, requestDto.Notify, requestDto.SharingMessage);
return _securityControllerHelperInt.SetFolderSecurityInfoAsync(folderId, inDto.Share, inDto.Notify, inDto.SharingMessage);
}
[Update("folder/{folderId}/share")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoFromFormAsync(string folderId, [FromForm] SecurityInfoRequestDto requestDto)
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoFromFormAsync(string folderId, [FromForm] SecurityInfoRequestDto inDto)
{
return _filesControllerHelperString.SetFolderSecurityInfoAsync(folderId, requestDto.Share, requestDto.Notify, requestDto.SharingMessage);
return _securityControllerHelperString.SetFolderSecurityInfoAsync(folderId, inDto.Share, inDto.Notify, inDto.SharingMessage);
}
[Update("folder/{folderId:int}/share")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoFromFormAsync(int folderId, [FromForm] SecurityInfoRequestDto requestDto)
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoFromFormAsync(int folderId, [FromForm] SecurityInfoRequestDto inDto)
{
return _filesControllerHelperInt.SetFolderSecurityInfoAsync(folderId, requestDto.Share, requestDto.Notify, requestDto.SharingMessage);
return _securityControllerHelperInt.SetFolderSecurityInfoAsync(folderId, inDto.Share, inDto.Notify, inDto.SharingMessage);
}
[Update("share")]
public Task<IEnumerable<FileShareDto>> SetSecurityInfoFromBodyAsync([FromBody] SecurityInfoRequestDto requestDto)
public Task<IEnumerable<FileShareDto>> SetSecurityInfoFromBodyAsync([FromBody] SecurityInfoRequestDto inDto)
{
return SetSecurityInfoAsync(requestDto);
return SetSecurityInfoAsync(inDto);
}
[Update("share")]
[Consumes("application/x-www-form-urlencoded")]
public Task<IEnumerable<FileShareDto>> SetSecurityInfoFromFormAsync([FromForm] SecurityInfoRequestDto requestDto)
public Task<IEnumerable<FileShareDto>> SetSecurityInfoFromFormAsync([FromForm] SecurityInfoRequestDto inDto)
{
return SetSecurityInfoAsync(requestDto);
return SetSecurityInfoAsync(inDto);
}
private async IAsyncEnumerable<FileEntryDto> ChangeOwnerAsync(ChangeOwnerRequestDto requestDto)
private async IAsyncEnumerable<FileEntryDto> ChangeOwnerAsync(ChangeOwnerRequestDto inDto)
{
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(requestDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(requestDto.FileIds);
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(inDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(inDto.FileIds);
var result = AsyncEnumerable.Empty<FileEntry>();
result.Concat(_fileStorageServiceInt.ChangeOwnerAsync(folderIntIds, fileIntIds, requestDto.UserId));
result.Concat(_fileStorageServiceString.ChangeOwnerAsync(folderStringIds, fileStringIds, requestDto.UserId));
result.Concat(_fileStorageServiceInt.ChangeOwnerAsync(folderIntIds, fileIntIds, inDto.UserId));
result.Concat(_fileStorageServiceString.ChangeOwnerAsync(folderStringIds, fileStringIds, inDto.UserId));
await foreach (var e in result)
{
yield return await _filesControllerHelperInt.GetFileEntryWrapperAsync(e);
yield return await _securityControllerHelperInt.GetFileEntryWrapperAsync(e);
}
}
private async Task<IEnumerable<FileShareDto>> SetSecurityInfoAsync(SecurityInfoRequestDto requestDto)
private async Task<IEnumerable<FileShareDto>> SetSecurityInfoAsync(SecurityInfoRequestDto inDto)
{
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(requestDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(requestDto.FileIds);
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(inDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(inDto.FileIds);
var result = new List<FileShareDto>();
result.AddRange(await _filesControllerHelperInt.SetSecurityInfoAsync(fileIntIds, folderIntIds, requestDto.Share, requestDto.Notify, requestDto.SharingMessage));
result.AddRange(await _filesControllerHelperString.SetSecurityInfoAsync(fileStringIds, folderStringIds, requestDto.Share, requestDto.Notify, requestDto.SharingMessage));
result.AddRange(await _securityControllerHelperInt.SetSecurityInfoAsync(fileIntIds, folderIntIds, inDto.Share, inDto.Notify, inDto.SharingMessage));
result.AddRange(await _securityControllerHelperString.SetSecurityInfoAsync(fileStringIds, folderStringIds, inDto.Share, inDto.Notify, inDto.SharingMessage));
return result;
}

View File

@ -10,13 +10,10 @@ public class SettingsController : ApiControllerBase
private readonly ProductEntryPoint _productEntryPoint;
public SettingsController(
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString,
FileStorageService<string> fileStorageServiceString,
FilesSettingsHelper filesSettingsHelper,
TenantManager tenantManager,
ProductEntryPoint productEntryPoint)
: base(filesControllerHelperInt, filesControllerHelperString)
ProductEntryPoint productEntryPoint)
{
_fileStorageServiceString = fileStorageServiceString;
_filesSettingsHelper = filesSettingsHelper;
@ -30,16 +27,16 @@ public class SettingsController : ApiControllerBase
/// <param name="set"></param>
/// <returns></returns>
[Update(@"thirdparty")]
public bool ChangeAccessToThirdpartyFromBody([FromBody] SettingsRequestDto requestDto)
public bool ChangeAccessToThirdpartyFromBody([FromBody] SettingsRequestDto inDto)
{
return _fileStorageServiceString.ChangeAccessToThirdparty(requestDto.Set);
return _fileStorageServiceString.ChangeAccessToThirdparty(inDto.Set);
}
[Update(@"thirdparty")]
[Consumes("application/x-www-form-urlencoded")]
public bool ChangeAccessToThirdpartyFromForm([FromForm] SettingsRequestDto requestDto)
public bool ChangeAccessToThirdpartyFromForm([FromForm] SettingsRequestDto inDto)
{
return _fileStorageServiceString.ChangeAccessToThirdparty(requestDto.Set);
return _fileStorageServiceString.ChangeAccessToThirdparty(inDto.Set);
}
/// <summary>
@ -48,16 +45,16 @@ public class SettingsController : ApiControllerBase
/// <param name="set"></param>
/// <returns></returns>
[Update(@"changedeleteconfrim")]
public bool ChangeDeleteConfrimFromBody([FromBody] SettingsRequestDto requestDto)
public bool ChangeDeleteConfrimFromBody([FromBody] SettingsRequestDto inDto)
{
return _fileStorageServiceString.ChangeDeleteConfrim(requestDto.Set);
return _fileStorageServiceString.ChangeDeleteConfrim(inDto.Set);
}
[Update(@"changedeleteconfrim")]
[Consumes("application/x-www-form-urlencoded")]
public bool ChangeDeleteConfrimFromForm([FromForm] SettingsRequestDto requestDto)
public bool ChangeDeleteConfrimFromForm([FromForm] SettingsRequestDto inDto)
{
return _fileStorageServiceString.ChangeDeleteConfrim(requestDto.Set);
return _fileStorageServiceString.ChangeDeleteConfrim(inDto.Set);
}
/// <summary>
@ -67,15 +64,15 @@ public class SettingsController : ApiControllerBase
/// <category>Settings</category>
/// <returns></returns>
[Update(@"settings/downloadtargz")]
public ICompress ChangeDownloadZipFromBody([FromBody] DisplayRequestDto requestDto)
public ICompress ChangeDownloadZipFromBody([FromBody] DisplayRequestDto inDto)
{
return _fileStorageServiceString.ChangeDownloadTarGz(requestDto.Set);
return _fileStorageServiceString.ChangeDownloadTarGz(inDto.Set);
}
[Update(@"settings/downloadtargz")]
public ICompress ChangeDownloadZipFromForm([FromForm] DisplayRequestDto requestDto)
public ICompress ChangeDownloadZipFromForm([FromForm] DisplayRequestDto inDto)
{
return _fileStorageServiceString.ChangeDownloadTarGz(requestDto.Set);
return _fileStorageServiceString.ChangeDownloadTarGz(inDto.Set);
}
/// <summary>
@ -85,16 +82,16 @@ public class SettingsController : ApiControllerBase
/// <category>Settings</category>
/// <returns></returns>
[Update(@"settings/favorites")]
public bool DisplayFavoriteFromBody([FromBody] DisplayRequestDto requestDto)
public bool DisplayFavoriteFromBody([FromBody] DisplayRequestDto inDto)
{
return _fileStorageServiceString.DisplayFavorite(requestDto.Set);
return _fileStorageServiceString.DisplayFavorite(inDto.Set);
}
[Update(@"settings/favorites")]
[Consumes("application/x-www-form-urlencoded")]
public bool DisplayFavoriteFromForm([FromForm] DisplayRequestDto requestDto)
public bool DisplayFavoriteFromForm([FromForm] DisplayRequestDto inDto)
{
return _fileStorageServiceString.DisplayFavorite(requestDto.Set);
return _fileStorageServiceString.DisplayFavorite(inDto.Set);
}
/// <summary>
@ -104,16 +101,16 @@ public class SettingsController : ApiControllerBase
/// <category>Settings</category>
/// <returns></returns>
[Update(@"displayRecent")]
public bool DisplayRecentFromBody([FromBody] DisplayRequestDto requestDto)
public bool DisplayRecentFromBody([FromBody] DisplayRequestDto inDto)
{
return _fileStorageServiceString.DisplayRecent(requestDto.Set);
return _fileStorageServiceString.DisplayRecent(inDto.Set);
}
[Update(@"displayRecent")]
[Consumes("application/x-www-form-urlencoded")]
public bool DisplayRecentFromForm([FromForm] DisplayRequestDto requestDto)
public bool DisplayRecentFromForm([FromForm] DisplayRequestDto inDto)
{
return _fileStorageServiceString.DisplayRecent(requestDto.Set);
return _fileStorageServiceString.DisplayRecent(inDto.Set);
}
/// <summary>
@ -123,16 +120,16 @@ public class SettingsController : ApiControllerBase
/// <category>Settings</category>
/// <returns></returns>
[Update(@"settings/templates")]
public bool DisplayTemplatesFromBody([FromBody] DisplayRequestDto requestDto)
public bool DisplayTemplatesFromBody([FromBody] DisplayRequestDto inDto)
{
return _fileStorageServiceString.DisplayTemplates(requestDto.Set);
return _fileStorageServiceString.DisplayTemplates(inDto.Set);
}
[Update(@"settings/templates")]
[Consumes("application/x-www-form-urlencoded")]
public bool DisplayTemplatesFromForm([FromForm] DisplayRequestDto requestDto)
public bool DisplayTemplatesFromForm([FromForm] DisplayRequestDto inDto)
{
return _fileStorageServiceString.DisplayTemplates(requestDto.Set);
return _fileStorageServiceString.DisplayTemplates(inDto.Set);
}
/// <summary>
@ -141,16 +138,16 @@ public class SettingsController : ApiControllerBase
/// <param name="set"></param>
/// <returns></returns>
[Update(@"forcesave")]
public bool ForcesaveFromBody([FromBody] SettingsRequestDto requestDto)
public bool ForcesaveFromBody([FromBody] SettingsRequestDto inDto)
{
return _fileStorageServiceString.Forcesave(requestDto.Set);
return _fileStorageServiceString.Forcesave(inDto.Set);
}
[Update(@"forcesave")]
[Consumes("application/x-www-form-urlencoded")]
public bool ForcesaveFromForm([FromForm] SettingsRequestDto requestDto)
public bool ForcesaveFromForm([FromForm] SettingsRequestDto inDto)
{
return _fileStorageServiceString.Forcesave(requestDto.Set);
return _fileStorageServiceString.Forcesave(inDto.Set);
}
/// <summary>
@ -177,16 +174,16 @@ public class SettingsController : ApiControllerBase
/// <visible>false</visible>
/// <returns></returns>
[Update(@"hideconfirmconvert")]
public bool HideConfirmConvertFromBody([FromBody] HideConfirmConvertRequestDto requestDto)
public bool HideConfirmConvertFromBody([FromBody] HideConfirmConvertRequestDto inDto)
{
return _fileStorageServiceString.HideConfirmConvert(requestDto.Save);
return _fileStorageServiceString.HideConfirmConvert(inDto.Save);
}
[Update(@"hideconfirmconvert")]
[Consumes("application/x-www-form-urlencoded")]
public bool HideConfirmConvertFromForm([FromForm] HideConfirmConvertRequestDto requestDto)
public bool HideConfirmConvertFromForm([FromForm] HideConfirmConvertRequestDto inDto)
{
return _fileStorageServiceString.HideConfirmConvert(requestDto.Save);
return _fileStorageServiceString.HideConfirmConvert(inDto.Save);
}
[Read("@privacy/available")]
@ -201,16 +198,16 @@ public class SettingsController : ApiControllerBase
/// <param name="set"></param>
/// <returns></returns>
[Update(@"storeforcesave")]
public bool StoreForcesaveFromBody([FromBody] SettingsRequestDto requestDto)
public bool StoreForcesaveFromBody([FromBody] SettingsRequestDto inDto)
{
return _fileStorageServiceString.StoreForcesave(requestDto.Set);
return _fileStorageServiceString.StoreForcesave(inDto.Set);
}
[Update(@"storeforcesave")]
[Consumes("application/x-www-form-urlencoded")]
public bool StoreForcesaveFromForm([FromForm] SettingsRequestDto requestDto)
public bool StoreForcesaveFromForm([FromForm] SettingsRequestDto inDto)
{
return _fileStorageServiceString.StoreForcesave(requestDto.Set);
return _fileStorageServiceString.StoreForcesave(inDto.Set);
}
/// <summary>
@ -219,16 +216,16 @@ public class SettingsController : ApiControllerBase
/// <param name="set"></param>
/// <returns></returns>
[Update(@"storeoriginal")]
public bool StoreOriginalFromBody([FromBody] SettingsRequestDto requestDto)
public bool StoreOriginalFromBody([FromBody] SettingsRequestDto inDto)
{
return _fileStorageServiceString.StoreOriginal(requestDto.Set);
return _fileStorageServiceString.StoreOriginal(inDto.Set);
}
[Update(@"storeoriginal")]
[Consumes("application/x-www-form-urlencoded")]
public bool StoreOriginalFromForm([FromForm] SettingsRequestDto requestDto)
public bool StoreOriginalFromForm([FromForm] SettingsRequestDto inDto)
{
return _fileStorageServiceString.StoreOriginal(requestDto.Set);
return _fileStorageServiceString.StoreOriginal(inDto.Set);
}
/// <summary>
///
@ -236,15 +233,15 @@ public class SettingsController : ApiControllerBase
/// <param name="set"></param>
/// <returns></returns>
[Update(@"updateifexist")]
public bool UpdateIfExistFromBody([FromBody] SettingsRequestDto requestDto)
public bool UpdateIfExistFromBody([FromBody] SettingsRequestDto inDto)
{
return _fileStorageServiceString.UpdateIfExist(requestDto.Set);
return _fileStorageServiceString.UpdateIfExist(inDto.Set);
}
[Update(@"updateifexist")]
[Consumes("application/x-www-form-urlencoded")]
public bool UpdateIfExistFromForm([FromForm] SettingsRequestDto requestDto)
public bool UpdateIfExistFromForm([FromForm] SettingsRequestDto inDto)
{
return _fileStorageServiceString.UpdateIfExist(requestDto.Set);
return _fileStorageServiceString.UpdateIfExist(inDto.Set);
}
}

View File

@ -4,16 +4,19 @@ public class TagsController : ApiControllerBase
{
private readonly FileStorageService<int> _fileStorageServiceInt;
private readonly FileStorageService<string> _fileStorageServiceString;
private readonly EntryManager _entryManager;
private readonly FileDtoHelper _fileDtoHelper;
public TagsController(
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString,
FileStorageService<int> fileStorageServiceInt,
FileStorageService<string> fileStorageServiceString)
: base(filesControllerHelperInt, filesControllerHelperString)
FileStorageService<string> fileStorageServiceString,
EntryManager entryManager,
FileDtoHelper fileDtoHelper)
{
_fileStorageServiceString = fileStorageServiceString;
_fileStorageServiceInt = fileStorageServiceInt;
_fileStorageServiceString = fileStorageServiceString;
_entryManager = entryManager;
_fileDtoHelper = fileDtoHelper;
}
/// <summary>
@ -25,16 +28,16 @@ public class TagsController : ApiControllerBase
/// <param name="fileIds">File IDs</param>
/// <returns></returns>
[Create("favorites")]
public Task<bool> AddFavoritesFromBodyAsync([FromBody] BaseBatchRequestDto requestDto)
public Task<bool> AddFavoritesFromBodyAsync([FromBody] BaseBatchRequestDto inDto)
{
return AddFavoritesAsync(requestDto);
return AddFavoritesAsync(inDto);
}
[Create("favorites")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<bool> AddFavoritesFromFormAsync([FromForm][ModelBinder(BinderType = typeof(BaseBatchModelBinder))] BaseBatchRequestDto requestDto)
public async Task<bool> AddFavoritesFromFormAsync([FromForm][ModelBinder(BinderType = typeof(BaseBatchModelBinder))] BaseBatchRequestDto inDto)
{
return await AddFavoritesAsync(requestDto);
return await AddFavoritesAsync(inDto);
}
/// <summary>
@ -45,18 +48,18 @@ public class TagsController : ApiControllerBase
/// <param name="fileIds">File IDs</param>
/// <returns></returns>
[Create("templates")]
public async Task<bool> AddTemplatesFromBodyAsync([FromBody] TemplatesRequestDto requestDto)
public async Task<bool> AddTemplatesFromBodyAsync([FromBody] TemplatesRequestDto inDto)
{
await _fileStorageServiceInt.AddToTemplatesAsync(requestDto.FileIds);
await _fileStorageServiceInt.AddToTemplatesAsync(inDto.FileIds);
return true;
}
[Create("templates")]
[Consumes("application/x-www-form-urlencoded")]
public async Task<bool> AddTemplatesFromFormAsync([FromForm] TemplatesRequestDto requestDto)
public async Task<bool> AddTemplatesFromFormAsync([FromForm] TemplatesRequestDto inDto)
{
await _fileStorageServiceInt.AddToTemplatesAsync(requestDto.FileIds);
await _fileStorageServiceInt.AddToTemplatesAsync(inDto.FileIds);
return true;
}
@ -64,14 +67,15 @@ public class TagsController : ApiControllerBase
[Create("file/{fileId}/recent", order: int.MaxValue)]
public Task<FileDto<string>> AddToRecentAsync(string fileId)
{
return _filesControllerHelperString.AddToRecentAsync(fileId);
return AddToRecentStringAsync(fileId);
}
[Create("file/{fileId:int}/recent", order: int.MaxValue - 1)]
public Task<FileDto<int>> AddToRecentAsync(int fileId)
{
return _filesControllerHelperInt.AddToRecentAsync(fileId);
return AddToRecentIntAsync(fileId);
}
/// <summary>
/// Removing files from favorite list
/// </summary>
@ -82,15 +86,15 @@ public class TagsController : ApiControllerBase
/// <returns></returns>
[Delete("favorites")]
[Consumes("application/json")]
public Task<bool> DeleteFavoritesFromBodyAsync([FromBody] BaseBatchRequestDto requestDto)
public Task<bool> DeleteFavoritesFromBodyAsync([FromBody] BaseBatchRequestDto inDto)
{
return DeleteFavoritesAsync(requestDto);
return DeleteFavoritesAsync(inDto);
}
[Delete("favorites")]
public async Task<bool> DeleteFavoritesFromQueryAsync([FromQuery][ModelBinder(BinderType = typeof(BaseBatchModelBinder))] BaseBatchRequestDto requestDto)
public async Task<bool> DeleteFavoritesFromQueryAsync([FromQuery][ModelBinder(BinderType = typeof(BaseBatchModelBinder))] BaseBatchRequestDto inDto)
{
return await DeleteFavoritesAsync(requestDto);
return await DeleteFavoritesAsync(inDto);
}
/// <summary>
@ -120,10 +124,10 @@ public class TagsController : ApiControllerBase
return _fileStorageServiceString.ToggleFileFavoriteAsync(fileId, favorite);
}
private async Task<bool> AddFavoritesAsync(BaseBatchRequestDto requestDto)
private async Task<bool> AddFavoritesAsync(BaseBatchRequestDto inDto)
{
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(requestDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(requestDto.FileIds);
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(inDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(inDto.FileIds);
await _fileStorageServiceInt.AddToFavoritesAsync(folderIntIds, fileIntIds);
await _fileStorageServiceString.AddToFavoritesAsync(folderStringIds, fileStringIds);
@ -131,14 +135,30 @@ public class TagsController : ApiControllerBase
return true;
}
private async Task<bool> DeleteFavoritesAsync(BaseBatchRequestDto requestDto)
private async Task<bool> DeleteFavoritesAsync(BaseBatchRequestDto inDto)
{
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(requestDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(requestDto.FileIds);
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(inDto.FolderIds);
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(inDto.FileIds);
await _fileStorageServiceInt.DeleteFavoritesAsync(folderIntIds, fileIntIds);
await _fileStorageServiceString.DeleteFavoritesAsync(folderStringIds, fileStringIds);
return true;
}
private async Task<FileDto<string>> AddToRecentStringAsync(string fileId)
{
var file = await _fileStorageServiceString.GetFileAsync(fileId, -1).NotFoundIfNull("File not found");
_entryManager.MarkAsRecent(file);
return await _fileDtoHelper.GetAsync(file);
}
private async Task<FileDto<int>> AddToRecentIntAsync(int fileId)
{
var file = await _fileStorageServiceInt.GetFileAsync(fileId, -1).NotFoundIfNull("File not found");
_entryManager.MarkAsRecent(file);
return await _fileDtoHelper.GetAsync(file);
}
}

View File

@ -3,7 +3,6 @@
public class ThirdpartyController : ApiControllerBase
{
private readonly CoreBaseSettings _coreBaseSettings;
private readonly EasyBibHelper _easyBibHelper;
private readonly EntryManager _entryManager;
private readonly FilesSettingsHelper _filesSettingsHelper;
private readonly FileStorageService<int> _fileStorageServiceInt;
@ -17,37 +16,31 @@ public class ThirdpartyController : ApiControllerBase
private readonly WordpressToken _wordpressToken;
public ThirdpartyController(
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString,
CoreBaseSettings coreBaseSettings,
ConsumerFactory consumerFactory,
EntryManager entryManager,
FilesSettingsHelper filesSettingsHelper,
FileStorageService<int> fileStorageServiceInt,
FileStorageService<string> fileStorageServiceString,
FolderDtoHelper folderWrapperHelper,
FolderDtoHelper folderDtoHelper,
GlobalFolderHelper globalFolderHelper,
SecurityContext securityContext,
ThirdpartyConfiguration thirdpartyConfiguration,
UserManager userManager,
WordpressHelper wordpressHelper,
WordpressToken wordpressToken
)
: base(filesControllerHelperInt, filesControllerHelperString)
WordpressToken wordpressToken)
{
_userManager = userManager;
_wordpressHelper = wordpressHelper;
_wordpressToken = wordpressToken;
_folderDtoHelper = folderWrapperHelper;
_coreBaseSettings = coreBaseSettings;
_entryManager = entryManager;
_filesSettingsHelper = filesSettingsHelper;
_fileStorageServiceInt = fileStorageServiceInt;
_fileStorageServiceString = fileStorageServiceString;
_folderDtoHelper = folderDtoHelper;
_globalFolderHelper = globalFolderHelper;
_securityContext = securityContext;
_thirdpartyConfiguration = thirdpartyConfiguration;
_coreBaseSettings = coreBaseSettings;
_entryManager = entryManager;
_fileStorageServiceInt = fileStorageServiceInt;
_fileStorageServiceString = fileStorageServiceString;
_filesSettingsHelper = filesSettingsHelper;
_easyBibHelper = consumerFactory.Get<EasyBibHelper>();
_userManager = userManager;
_wordpressHelper = wordpressHelper;
_wordpressToken = wordpressToken;
}
/// <summary>
@ -74,16 +67,16 @@ public class ThirdpartyController : ApiControllerBase
/// <visible>false</visible>
[Create("wordpress")]
public bool CreateWordpressPostFromBody([FromBody] CreateWordpressPostRequestDto requestDto)
public bool CreateWordpressPostFromBody([FromBody] CreateWordpressPostRequestDto inDto)
{
return CreateWordpressPost(requestDto);
return CreateWordpressPost(inDto);
}
[Create("wordpress")]
[Consumes("application/x-www-form-urlencoded")]
public bool CreateWordpressPostFromForm([FromForm] CreateWordpressPostRequestDto requestDto)
public bool CreateWordpressPostFromForm([FromForm] CreateWordpressPostRequestDto inDto)
{
return CreateWordpressPost(requestDto);
return CreateWordpressPost(inDto);
}
/// <summary>
@ -122,20 +115,6 @@ public class ThirdpartyController : ApiControllerBase
};
}
/// <visible>false</visible>
[Create("easybib-citation")]
public object EasyBibCitationBookFromBody([FromBody] EasyBibCitationBookRequestDto requestDto)
{
return EasyBibCitationBook(requestDto);
}
[Create("easybib-citation")]
[Consumes("application/x-www-form-urlencoded")]
public object EasyBibCitationBookFromForm([FromForm] EasyBibCitationBookRequestDto requestDto)
{
return EasyBibCitationBook(requestDto);
}
/// <summary>
/// Returns the list of third party services connected in the 'Common Documents' section
/// </summary>
@ -156,51 +135,6 @@ public class ThirdpartyController : ApiControllerBase
return result;
}
/// <visible>false</visible>
[Read("easybib-citation-list")]
public object GetEasybibCitationList(int source, string data)
{
try
{
var citationList = EasyBibHelper.GetEasyBibCitationsList(source, data);
return new
{
success = true,
citations = citationList
};
}
catch (Exception)
{
return new
{
success = false
};
}
}
/// <visible>false</visible>
[Read("easybib-styles")]
public object GetEasybibStyles()
{
try
{
var data = EasyBibHelper.GetEasyBibStyles();
return new
{
success = true,
styles = data
};
}
catch (Exception)
{
return new
{
success = false
};
}
}
/// <summary>
/// Returns the list of all connected third party services
/// </summary>
@ -258,47 +192,53 @@ public class ThirdpartyController : ApiControllerBase
/// <remarks>List of provider key: DropboxV2, Box, WebDav, Yandex, OneDrive, SharePoint, GoogleDrive</remarks>
/// <exception cref="ArgumentException"></exception>
[Create("thirdparty")]
public Task<FolderDto<string>> SaveThirdPartyFromBodyAsync([FromBody] ThirdPartyRequestDto requestDto)
public Task<FolderDto<string>> SaveThirdPartyFromBodyAsync([FromBody] ThirdPartyRequestDto inDto)
{
return SaveThirdPartyAsync(requestDto);
return SaveThirdPartyAsync(inDto);
}
[Create("thirdparty")]
[Consumes("application/x-www-form-urlencoded")]
public Task<FolderDto<string>> SaveThirdPartyFromFormAsync([FromForm] ThirdPartyRequestDto requestDto)
public Task<FolderDto<string>> SaveThirdPartyFromFormAsync([FromForm] ThirdPartyRequestDto inDto)
{
return SaveThirdPartyAsync(requestDto);
return SaveThirdPartyAsync(inDto);
}
/// <visible>false</visible>
[Create("wordpress-save")]
public object WordpressSaveFromBody([FromBody] WordpressSaveRequestDto requestDto)
public object WordpressSaveFromBody([FromBody] WordpressSaveRequestDto inDto)
{
return WordpressSave(requestDto);
return WordpressSave(inDto);
}
[Create("wordpress-save")]
[Consumes("application/x-www-form-urlencoded")]
public object WordpressSaveFromForm([FromForm] WordpressSaveRequestDto requestDto)
public object WordpressSaveFromForm([FromForm] WordpressSaveRequestDto inDto)
{
return WordpressSave(requestDto);
return WordpressSave(inDto);
}
private bool CreateWordpressPost(CreateWordpressPostRequestDto requestDto)
private bool CreateWordpressPost(CreateWordpressPostRequestDto inDto)
{
try
{
var token = _wordpressToken.GetToken();
var meInfo = _wordpressHelper.GetWordpressMeInfo(token.AccessToken);
var parser = JObject.Parse(meInfo);
if (parser == null) return false;
if (parser == null)
{
return false;
}
var blogId = parser.Value<string>("token_site_id");
if (blogId != null)
{
var createPost = _wordpressHelper.CreateWordpressPost(requestDto.Title, requestDto.Content, requestDto.Status, blogId, token);
var createPost = _wordpressHelper.CreateWordpressPost(inDto.Title, inDto.Content, inDto.Status, blogId, token);
return createPost;
}
return false;
}
catch (Exception)
@ -307,46 +247,15 @@ public class ThirdpartyController : ApiControllerBase
}
}
private object EasyBibCitationBook(EasyBibCitationBookRequestDto requestDto)
{
try
{
var citat = _easyBibHelper.GetEasyBibCitation(requestDto.CitationData);
if (citat != null)
{
return new
{
success = true,
citation = citat
};
}
else
{
return new
{
success = false
};
}
}
catch (Exception)
{
return new
{
success = false
};
}
}
private async Task<FolderDto<string>> SaveThirdPartyAsync(ThirdPartyRequestDto requestDto)
private async Task<FolderDto<string>> SaveThirdPartyAsync(ThirdPartyRequestDto inDto)
{
var thirdPartyParams = new ThirdPartyParams
{
AuthData = new AuthData(requestDto.Url, requestDto.Login, requestDto.Password, requestDto.Token),
Corporate = requestDto.IsCorporate,
CustomerTitle = requestDto.CustomerTitle,
ProviderId = requestDto.ProviderId,
ProviderKey = requestDto.ProviderKey,
AuthData = new AuthData(inDto.Url, inDto.Login, inDto.Password, inDto.Token),
Corporate = inDto.IsCorporate,
CustomerTitle = inDto.CustomerTitle,
ProviderId = inDto.ProviderId,
ProviderKey = inDto.ProviderKey,
};
var folder = await _fileStorageServiceString.SaveThirdPartyAsync(thirdPartyParams);
@ -354,9 +263,9 @@ public class ThirdpartyController : ApiControllerBase
return await _folderDtoHelper.GetAsync(folder);
}
private object WordpressSave(WordpressSaveRequestDto model)
private object WordpressSave(WordpressSaveRequestDto inDto)
{
if (model.Code.Length == 0)
if (inDto.Code.Length == 0)
{
return new
{
@ -365,7 +274,7 @@ public class ThirdpartyController : ApiControllerBase
}
try
{
var token = _wordpressToken.SaveTokenFromCode(model.Code);
var token = _wordpressToken.SaveTokenFromCode(inDto.Code);
var meInfo = _wordpressHelper.GetWordpressMeInfo(token.AccessToken);
var blogId = JObject.Parse(meInfo).Value<string>("token_site_id");

View File

@ -3,14 +3,17 @@
public class UploadController : ApiControllerBase
{
private readonly GlobalFolderHelper _globalFolderHelper;
private readonly UploadControllerHelper<string> _filesControllerHelperString;
private readonly UploadControllerHelper<int> _filesControllerHelperInt;
public UploadController(
FilesControllerHelper<int> filesControllerHelperInt,
FilesControllerHelper<string> filesControllerHelperString,
GlobalFolderHelper globalFolderHelper)
: base(filesControllerHelperInt, filesControllerHelperString)
GlobalFolderHelper globalFolderHelper,
UploadControllerHelper<string> filesControllerHelperString,
UploadControllerHelper<int> filesControllerHelperInt)
{
_globalFolderHelper = globalFolderHelper;
_filesControllerHelperString = filesControllerHelperString;
_filesControllerHelperInt = filesControllerHelperInt;
}
/// <summary>
@ -46,29 +49,29 @@ public class UploadController : ApiControllerBase
/// ]]>
/// </returns>
[Create("{folderId}/upload/create_session")]
public Task<object> CreateUploadSessionFromBodyAsync(string folderId, [FromBody] SessionRequestDto sessionRequestDto)
public Task<object> CreateUploadSessionFromBodyAsync(string folderId, [FromBody] SessionRequestDto inDto)
{
return _filesControllerHelperString.CreateUploadSessionAsync(folderId, sessionRequestDto.FileName, sessionRequestDto.FileSize, sessionRequestDto.RelativePath, sessionRequestDto.LastModified, sessionRequestDto.Encrypted);
return _filesControllerHelperString.CreateUploadSessionAsync(folderId, inDto.FileName, inDto.FileSize, inDto.RelativePath, inDto.LastModified, inDto.Encrypted);
}
[Create("{folderId:int}/upload/create_session")]
public Task<object> CreateUploadSessionFromBodyAsync(int folderId, [FromBody] SessionRequestDto sessionRequestDto)
public Task<object> CreateUploadSessionFromBodyAsync(int folderId, [FromBody] SessionRequestDto inDto)
{
return _filesControllerHelperInt.CreateUploadSessionAsync(folderId, sessionRequestDto.FileName, sessionRequestDto.FileSize, sessionRequestDto.RelativePath, sessionRequestDto.LastModified, sessionRequestDto.Encrypted);
return _filesControllerHelperInt.CreateUploadSessionAsync(folderId, inDto.FileName, inDto.FileSize, inDto.RelativePath, inDto.LastModified, inDto.Encrypted);
}
[Create("{folderId}/upload/create_session")]
[Consumes("application/x-www-form-urlencoded")]
public Task<object> CreateUploadSessionFromFormAsync(string folderId, [FromForm] SessionRequestDto sessionRequestDto)
public Task<object> CreateUploadSessionFromFormAsync(string folderId, [FromForm] SessionRequestDto inDto)
{
return _filesControllerHelperString.CreateUploadSessionAsync(folderId, sessionRequestDto.FileName, sessionRequestDto.FileSize, sessionRequestDto.RelativePath, sessionRequestDto.LastModified, sessionRequestDto.Encrypted);
return _filesControllerHelperString.CreateUploadSessionAsync(folderId, inDto.FileName, inDto.FileSize, inDto.RelativePath, inDto.LastModified, inDto.Encrypted);
}
[Create("{folderId:int}/upload/create_session")]
[Consumes("application/x-www-form-urlencoded")]
public Task<object> CreateUploadSessionFromFormAsync(int folderId, [FromForm] SessionRequestDto sessionRequestDto)
public Task<object> CreateUploadSessionFromFormAsync(int folderId, [FromForm] SessionRequestDto inDto)
{
return _filesControllerHelperInt.CreateUploadSessionAsync(folderId, sessionRequestDto.FileName, sessionRequestDto.FileSize, sessionRequestDto.RelativePath, sessionRequestDto.LastModified, sessionRequestDto.Encrypted);
return _filesControllerHelperInt.CreateUploadSessionAsync(folderId, inDto.FileName, inDto.FileSize, inDto.RelativePath, inDto.LastModified, inDto.Encrypted);
}
/// <summary>
@ -82,15 +85,15 @@ public class UploadController : ApiControllerBase
/// <category>Uploads</category>
/// <returns></returns>
[Create("{folderId}/insert", order: int.MaxValue)]
public Task<FileDto<string>> InsertFileAsync(string folderId, [FromForm][ModelBinder(BinderType = typeof(InsertFileModelBinder))] InsertFileRequestDto requestDto)
public Task<FileDto<string>> InsertFileAsync(string folderId, [FromForm][ModelBinder(BinderType = typeof(InsertFileModelBinder))] InsertFileRequestDto inDto)
{
return _filesControllerHelperString.InsertFileAsync(folderId, requestDto.Stream, requestDto.Title, requestDto.CreateNewIfExist, requestDto.KeepConvertStatus);
return _filesControllerHelperString.InsertFileAsync(folderId, inDto.Stream, inDto.Title, inDto.CreateNewIfExist, inDto.KeepConvertStatus);
}
[Create("{folderId:int}/insert", order: int.MaxValue - 1)]
public Task<FileDto<int>> InsertFileFromFormAsync(int folderId, [FromForm][ModelBinder(BinderType = typeof(InsertFileModelBinder))] InsertFileRequestDto requestDto)
public Task<FileDto<int>> InsertFileFromFormAsync(int folderId, [FromForm][ModelBinder(BinderType = typeof(InsertFileModelBinder))] InsertFileRequestDto inDto)
{
return _filesControllerHelperInt.InsertFileAsync(folderId, requestDto.Stream, requestDto.Title, requestDto.CreateNewIfExist, requestDto.KeepConvertStatus);
return _filesControllerHelperInt.InsertFileAsync(folderId, inDto.Stream, inDto.Title, inDto.CreateNewIfExist, inDto.KeepConvertStatus);
}
/// <summary>
@ -103,9 +106,9 @@ public class UploadController : ApiControllerBase
/// <category>Uploads</category>
/// <returns></returns>
[Create("@common/insert")]
public async Task<FileDto<int>> InsertFileToCommonFromBodyAsync([FromForm][ModelBinder(BinderType = typeof(InsertFileModelBinder))] InsertFileRequestDto requestDto)
public async Task<FileDto<int>> InsertFileToCommonFromBodyAsync([FromForm][ModelBinder(BinderType = typeof(InsertFileModelBinder))] InsertFileRequestDto inDto)
{
return await _filesControllerHelperInt.InsertFileAsync(await _globalFolderHelper.FolderCommonAsync, requestDto.Stream, requestDto.Title, requestDto.CreateNewIfExist, requestDto.KeepConvertStatus);
return await _filesControllerHelperInt.InsertFileAsync(await _globalFolderHelper.FolderCommonAsync, inDto.Stream, inDto.Title, inDto.CreateNewIfExist, inDto.KeepConvertStatus);
}
/// <summary>
@ -118,9 +121,9 @@ public class UploadController : ApiControllerBase
/// <category>Uploads</category>
/// <returns></returns>
[Create("@my/insert")]
public Task<FileDto<int>> InsertFileToMyFromBodyAsync([FromForm][ModelBinder(BinderType = typeof(InsertFileModelBinder))] InsertFileRequestDto requestDto)
public Task<FileDto<int>> InsertFileToMyFromBodyAsync([FromForm][ModelBinder(BinderType = typeof(InsertFileModelBinder))] InsertFileRequestDto inDto)
{
return _filesControllerHelperInt.InsertFileAsync(_globalFolderHelper.FolderMy, requestDto.Stream, requestDto.Title, requestDto.CreateNewIfExist, requestDto.KeepConvertStatus);
return _filesControllerHelperInt.InsertFileAsync(_globalFolderHelper.FolderMy, inDto.Stream, inDto.Title, inDto.CreateNewIfExist, inDto.KeepConvertStatus);
}
/// <summary>
@ -146,15 +149,15 @@ public class UploadController : ApiControllerBase
/// <param name="keepConvertStatus" visible="false">Keep status conversation after finishing</param>
/// <returns>Uploaded file</returns>
[Create("{folderId}/upload", order: int.MaxValue)]
public Task<object> UploadFileAsync(string folderId, [ModelBinder(BinderType = typeof(UploadModelBinder))] UploadRequestDto uploadRequestDto)
public Task<object> UploadFileAsync(string folderId, [ModelBinder(BinderType = typeof(UploadModelBinder))] UploadRequestDto inDto)
{
return _filesControllerHelperString.UploadFileAsync(folderId, uploadRequestDto);
return _filesControllerHelperString.UploadFileAsync(folderId, inDto);
}
[Create("{folderId:int}/upload", order: int.MaxValue - 1)]
public Task<object> UploadFileAsync(int folderId, [ModelBinder(BinderType = typeof(UploadModelBinder))] UploadRequestDto uploadRequestDto)
public Task<object> UploadFileAsync(int folderId, [ModelBinder(BinderType = typeof(UploadModelBinder))] UploadRequestDto inDto)
{
return _filesControllerHelperInt.UploadFileAsync(folderId, uploadRequestDto);
return _filesControllerHelperInt.UploadFileAsync(folderId, inDto);
}
/// <summary>
@ -176,11 +179,11 @@ public class UploadController : ApiControllerBase
/// <param name="files" visible="false">List of files when posted as multipart/form-data</param>
/// <returns>Uploaded file</returns>
[Create("@common/upload")]
public async Task<object> UploadFileToCommonAsync([ModelBinder(BinderType = typeof(UploadModelBinder))] UploadRequestDto uploadRequestDto)
public async Task<object> UploadFileToCommonAsync([ModelBinder(BinderType = typeof(UploadModelBinder))] UploadRequestDto inDto)
{
uploadRequestDto.CreateNewIfExist = false;
inDto.CreateNewIfExist = false;
return await _filesControllerHelperInt.UploadFileAsync(await _globalFolderHelper.FolderCommonAsync, uploadRequestDto);
return await _filesControllerHelperInt.UploadFileAsync(await _globalFolderHelper.FolderCommonAsync, inDto);
}
/// <summary>
@ -202,9 +205,10 @@ public class UploadController : ApiControllerBase
/// <param name="files" visible="false">List of files when posted as multipart/form-data</param>
/// <returns>Uploaded file</returns>
[Create("@my/upload")]
public Task<object> UploadFileToMyAsync([ModelBinder(BinderType = typeof(UploadModelBinder))] UploadRequestDto uploadRequestDto)
public Task<object> UploadFileToMyAsync([ModelBinder(BinderType = typeof(UploadModelBinder))] UploadRequestDto inDto)
{
uploadRequestDto.CreateNewIfExist = false;
return _filesControllerHelperInt.UploadFileAsync(_globalFolderHelper.FolderMy, uploadRequestDto);
inDto.CreateNewIfExist = false;
return _filesControllerHelperInt.UploadFileAsync(_globalFolderHelper.FolderMy, inDto);
}
}

View File

@ -54,4 +54,4 @@ global using Microsoft.AspNetCore.Mvc;
global using Microsoft.Extensions.Options;
global using Microsoft.Extensions.Hosting.WindowsServices;
global using Newtonsoft.Json.Linq;
global using Newtonsoft.Json.Linq;

View File

@ -0,0 +1,104 @@
using FileShare = ASC.Files.Core.Security.FileShare;
namespace ASC.Files.Helpers;
public class EditorControllerHelper<T> : FilesHelperBase<T>
{
private readonly DocumentServiceHelper _documentServiceHelper;
private readonly DocumentServiceTrackerHelper _documentServiceTrackerHelper;
private readonly EncryptionKeyPairDtoHelper _encryptionKeyPairDtoHelper;
private readonly SettingsManager _settingsManager;
private readonly EntryManager _entryManager;
public EditorControllerHelper(
FilesSettingsHelper filesSettingsHelper,
FileUploader fileUploader,
SocketManager socketManager,
FileDtoHelper fileDtoHelper,
ApiContext apiContext,
FileStorageService<T> fileStorageService,
FolderContentDtoHelper folderContentDtoHelper,
IHttpContextAccessor httpContextAccessor,
FolderDtoHelper folderDtoHelper,
DocumentServiceHelper documentServiceHelper,
DocumentServiceTrackerHelper documentServiceTrackerHelper,
EncryptionKeyPairDtoHelper encryptionKeyPairDtoHelper,
SettingsManager settingsManager,
EntryManager entryManager)
: base(
filesSettingsHelper,
fileUploader,
socketManager,
fileDtoHelper,
apiContext,
fileStorageService,
folderContentDtoHelper,
httpContextAccessor,
folderDtoHelper)
{
_documentServiceHelper = documentServiceHelper;
_documentServiceTrackerHelper = documentServiceTrackerHelper;
_encryptionKeyPairDtoHelper = encryptionKeyPairDtoHelper;
_settingsManager = settingsManager;
_entryManager = entryManager;
}
public async Task<FileDto<T>> SaveEditingAsync(T fileId, string fileExtension, string downloadUri, Stream stream, string doc, bool forcesave)
{
return await _fileDtoHelper.GetAsync(await _fileStorageService.SaveEditingAsync(fileId, fileExtension, downloadUri, stream, doc, forcesave));
}
public Task<string> StartEditAsync(T fileId, bool editingAlone, string doc)
{
return _fileStorageService.StartEditAsync(fileId, editingAlone, doc);
}
public Task<KeyValuePair<bool, string>> TrackEditFileAsync(T fileId, Guid tabId, string docKeyForTrack, string doc, bool isFinish)
{
return _fileStorageService.TrackEditFileAsync(fileId, tabId, docKeyForTrack, doc, isFinish);
}
public async Task<Configuration<T>> OpenEditAsync(T fileId, int version, string doc, bool view)
{
var docParams = await _documentServiceHelper.GetParamsAsync(fileId, version, doc, true, !view, true);
var configuration = docParams.Configuration;
configuration.EditorType = EditorType.External;
if (configuration.EditorConfig.ModeWrite)
{
configuration.EditorConfig.CallbackUrl = _documentServiceTrackerHelper.GetCallbackUrl(configuration.Document.Info.GetFile().Id.ToString());
}
if (configuration.Document.Info.GetFile().RootFolderType == FolderType.Privacy && PrivacyRoomSettings.GetEnabled(_settingsManager))
{
var keyPair = _encryptionKeyPairDtoHelper.GetKeyPair();
if (keyPair != null)
{
configuration.EditorConfig.EncryptionKeys = new EncryptionKeysConfig
{
PrivateKeyEnc = keyPair.PrivateKeyEnc,
PublicKey = keyPair.PublicKey,
};
}
}
if (!configuration.Document.Info.GetFile().Encrypted && !configuration.Document.Info.GetFile().ProviderEntry)
{
_entryManager.MarkAsRecent(configuration.Document.Info.GetFile());
}
configuration.Token = _documentServiceHelper.GetSignature(configuration);
return configuration;
}
public Task<DocumentService.FileLink> GetPresignedUriAsync(T fileId)
{
return _fileStorageService.GetPresignedUriAsync(fileId);
}
public Task<bool> SetAceLinkAsync(T fileId, FileShare share)
{
return _fileStorageService.SetAceLinkAsync(fileId, share);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,99 @@
namespace ASC.Files.Helpers;
[Scope]
public abstract class FilesHelperBase<T>
{
protected readonly FilesSettingsHelper _filesSettingsHelper;
protected readonly FileUploader _fileUploader;
protected readonly SocketManager _socketManager;
protected readonly FileDtoHelper _fileDtoHelper;
protected readonly ApiContext _apiContext;
protected readonly FileStorageService<T> _fileStorageService;
protected readonly FolderContentDtoHelper _folderContentDtoHelper;
protected readonly IHttpContextAccessor _httpContextAccessor;
protected readonly FolderDtoHelper _folderDtoHelper;
protected FilesHelperBase(
FilesSettingsHelper filesSettingsHelper,
FileUploader fileUploader,
SocketManager socketManager,
FileDtoHelper fileDtoHelper,
ApiContext apiContext,
FileStorageService<T> fileStorageService,
FolderContentDtoHelper folderContentDtoHelper,
IHttpContextAccessor httpContextAccessor,
FolderDtoHelper folderDtoHelper)
{
_filesSettingsHelper = filesSettingsHelper;
_fileUploader = fileUploader;
_socketManager = socketManager;
_fileDtoHelper = fileDtoHelper;
_apiContext = apiContext;
_fileStorageService = fileStorageService;
_folderContentDtoHelper = folderContentDtoHelper;
_httpContextAccessor = httpContextAccessor;
_folderDtoHelper = folderDtoHelper;
}
public async Task<FileDto<T>> InsertFileAsync(T folderId, Stream file, string title, bool? createNewIfExist, bool keepConvertStatus = false)
{
try
{
var resultFile = await _fileUploader.ExecAsync(folderId, title, file.Length, file, createNewIfExist ?? !_filesSettingsHelper.UpdateIfExist, !keepConvertStatus);
await _socketManager.CreateFileAsync(resultFile);
return await _fileDtoHelper.GetAsync(resultFile);
}
catch (FileNotFoundException e)
{
throw new ItemNotFoundException("File not found", e);
}
catch (DirectoryNotFoundException e)
{
throw new ItemNotFoundException("Folder not found", e);
}
}
public IFormFile GetFileFromRequest(IModelWithFile model)
{
IEnumerable<IFormFile> files = _httpContextAccessor.HttpContext.Request.Form.Files;
if (files != null && files.Any())
{
return files.First();
}
return model.File;
}
public async Task<FileDto<T>> GetFileInfoAsync(T fileId, int version = -1)
{
var file = await _fileStorageService.GetFileAsync(fileId, version);
file = file.NotFoundIfNull("File not found");
return await _fileDtoHelper.GetAsync(file);
}
public async Task<FileEntryDto> GetFileEntryWrapperAsync(FileEntry r)
{
FileEntryDto wrapper = null;
if (r is Folder<int> fol1)
{
wrapper = await _folderDtoHelper.GetAsync(fol1);
}
else if (r is Folder<string> fol2)
{
wrapper = await _folderDtoHelper.GetAsync(fol2);
}
else if (r is File<int> file1)
{
wrapper = await _fileDtoHelper.GetAsync(file1);
}
else if (r is File<string> file2)
{
wrapper = await _fileDtoHelper.GetAsync(file2);
}
return wrapper;
}
}

View File

@ -0,0 +1,199 @@
namespace ASC.Files.Helpers;
public class FoldersControllerHelper<T> : FilesHelperBase<T>
{
private readonly FileOperationDtoHelper _fileOperationDtoHelper;
private readonly EntryManager _entryManager;
private readonly UserManager _userManager;
private readonly SecurityContext _securityContext;
private readonly GlobalFolderHelper _globalFolderHelper;
private readonly CoreBaseSettings _coreBaseSettings;
private readonly FileUtility _fileUtility;
private readonly TenantManager _tenantManager;
public FoldersControllerHelper(
FilesSettingsHelper filesSettingsHelper,
FileUploader fileUploader,
SocketManager socketManager,
FileDtoHelper fileDtoHelper,
ApiContext apiContext,
FileStorageService<T> fileStorageService,
FolderContentDtoHelper folderContentDtoHelper,
IHttpContextAccessor httpContextAccessor,
FolderDtoHelper folderDtoHelper,
FileOperationDtoHelper fileOperationDtoHelper,
EntryManager entryManager,
UserManager userManager,
SecurityContext securityContext,
GlobalFolderHelper globalFolderHelper,
CoreBaseSettings coreBaseSettings,
FileUtility fileUtility,
TenantManager tenantManager)
: base(
filesSettingsHelper,
fileUploader,
socketManager,
fileDtoHelper,
apiContext,
fileStorageService,
folderContentDtoHelper,
httpContextAccessor,
folderDtoHelper)
{
_fileOperationDtoHelper = fileOperationDtoHelper;
_globalFolderHelper = globalFolderHelper;
_coreBaseSettings = coreBaseSettings;
_fileUtility = fileUtility;
_tenantManager = tenantManager;
_securityContext = securityContext;
_entryManager = entryManager;
_userManager = userManager;
}
public async Task<FolderDto<T>> CreateFolderAsync(T folderId, string title)
{
var folder = await _fileStorageService.CreateNewFolderAsync(folderId, title);
return await _folderDtoHelper.GetAsync(folder);
}
public async Task<IEnumerable<FileOperationDto>> DeleteFolder(T folderId, bool deleteAfter, bool immediately)
{
var result = new List<FileOperationDto>();
foreach (var e in _fileStorageService.DeleteFolder("delete", folderId, false, deleteAfter, immediately))
{
result.Add(await _fileOperationDtoHelper.GetAsync(e));
}
return result;
}
public async Task<FolderContentDto<T>> GetFolderAsync(T folderId, Guid userIdOrGroupId, FilterType filterType, bool withSubFolders)
{
var folderContentWrapper = await ToFolderContentWrapperAsync(folderId, userIdOrGroupId, filterType, withSubFolders);
return folderContentWrapper.NotFoundIfNull();
}
public async Task<FolderDto<T>> GetFolderInfoAsync(T folderId)
{
var folder = await _fileStorageService.GetFolderAsync(folderId).NotFoundIfNull("Folder not found");
return await _folderDtoHelper.GetAsync(folder);
}
public async IAsyncEnumerable<FileEntryDto> GetFolderPathAsync(T folderId)
{
var breadCrumbs = await _entryManager.GetBreadCrumbsAsync(folderId);
foreach (var e in breadCrumbs)
{
yield return await GetFileEntryWrapperAsync(e);
}
}
public async IAsyncEnumerable<FileEntryDto> GetFoldersAsync(T folderId)
{
var folders = await _fileStorageService.GetFoldersAsync(folderId);
foreach (var folder in folders)
{
yield return await GetFileEntryWrapperAsync(folder);
}
}
public async Task<List<FileEntryDto>> GetNewItemsAsync(T folderId)
{
var newItems = await _fileStorageService.GetNewItemsAsync(folderId);
var result = new List<FileEntryDto>();
foreach (var e in newItems)
{
result.Add(await GetFileEntryWrapperAsync(e));
}
return result;
}
public async Task<SortedSet<int>> GetRootFoldersIdsAsync(bool withoutTrash, bool withoutAdditionalFolder)
{
var IsVisitor = _userManager.GetUsers(_securityContext.CurrentAccount.ID).IsVisitor(_userManager);
var IsOutsider = _userManager.GetUsers(_securityContext.CurrentAccount.ID).IsOutsider(_userManager);
var folders = new SortedSet<int>();
if (IsOutsider)
{
withoutTrash = true;
withoutAdditionalFolder = true;
}
if (!IsVisitor)
{
folders.Add(_globalFolderHelper.FolderMy);
}
if (!_coreBaseSettings.Personal && !_userManager.GetUsers(_securityContext.CurrentAccount.ID).IsOutsider(_userManager))
{
folders.Add(await _globalFolderHelper.FolderShareAsync);
}
if (!IsVisitor && !withoutAdditionalFolder)
{
if (_filesSettingsHelper.FavoritesSection)
{
folders.Add(await _globalFolderHelper.FolderFavoritesAsync);
}
if (_filesSettingsHelper.RecentSection)
{
folders.Add(await _globalFolderHelper.FolderRecentAsync);
}
if (!_coreBaseSettings.Personal && PrivacyRoomSettings.IsAvailable(_tenantManager))
{
folders.Add(await _globalFolderHelper.FolderPrivacyAsync);
}
}
if (!_coreBaseSettings.Personal)
{
folders.Add(await _globalFolderHelper.FolderCommonAsync);
}
if (!IsVisitor
&& !withoutAdditionalFolder
&& _fileUtility.ExtsWebTemplate.Count > 0
&& _filesSettingsHelper.TemplatesSection)
{
folders.Add(await _globalFolderHelper.FolderTemplatesAsync);
}
if (!withoutTrash)
{
folders.Add((int)_globalFolderHelper.FolderTrash);
}
return folders;
}
public async Task<FolderDto<T>> RenameFolderAsync(T folderId, string title)
{
var folder = await _fileStorageService.FolderRenameAsync(folderId, title);
return await _folderDtoHelper.GetAsync(folder);
}
private async Task<FolderContentDto<T>> ToFolderContentWrapperAsync(T folderId, Guid userIdOrGroupId, FilterType filterType, bool withSubFolders)
{
OrderBy orderBy = null;
if (Enum.TryParse(_apiContext.SortBy, true, out SortedByType sortBy))
{
orderBy = new OrderBy(sortBy, !_apiContext.SortDescending);
}
var startIndex = Convert.ToInt32(_apiContext.StartIndex);
var items = await _fileStorageService.GetFolderItemsAsync(folderId, startIndex, Convert.ToInt32(_apiContext.Count), filterType,
filterType == FilterType.ByUser, userIdOrGroupId.ToString(), _apiContext.FilterValue, false, withSubFolders, orderBy);
return await _folderContentDtoHelper.GetAsync(items, startIndex);
}
}

View File

@ -0,0 +1,134 @@
namespace ASC.Files.Helpers;
public class OperationControllerHelper<T> : FilesHelperBase<T>
{
private readonly FileOperationDtoHelper _fileOperationDtoHelper;
public OperationControllerHelper(
FilesSettingsHelper filesSettingsHelper,
FileUploader fileUploader,
SocketManager socketManager,
FileDtoHelper fileDtoHelper,
ApiContext apiContext,
FileStorageService<T> fileStorageService,
FolderContentDtoHelper folderContentDtoHelper,
IHttpContextAccessor httpContextAccessor,
FolderDtoHelper folderDtoHelper,
FileOperationDtoHelper fileOperationDtoHelper)
: base(
filesSettingsHelper,
fileUploader,
socketManager,
fileDtoHelper,
apiContext,
fileStorageService,
folderContentDtoHelper,
httpContextAccessor,
folderDtoHelper)
{
_fileOperationDtoHelper = fileOperationDtoHelper;
}
public async Task<IEnumerable<FileOperationDto>> BulkDownloadAsync(DownloadRequestDto model)
{
var folders = new Dictionary<JsonElement, string>();
var files = new Dictionary<JsonElement, string>();
foreach (var fileId in model.FileConvertIds.Where(fileId => !files.ContainsKey(fileId.Key)))
{
files.Add(fileId.Key, fileId.Value);
}
foreach (var fileId in model.FileIds.Where(fileId => !files.ContainsKey(fileId)))
{
files.Add(fileId, string.Empty);
}
foreach (var folderId in model.FolderIds.Where(folderId => !folders.ContainsKey(folderId)))
{
folders.Add(folderId, string.Empty);
}
var result = new List<FileOperationDto>();
foreach (var e in _fileStorageService.BulkDownload(folders, files))
{
result.Add(await _fileOperationDtoHelper.GetAsync(e));
}
return result;
}
public async Task<IEnumerable<FileOperationDto>> CopyBatchItemsAsync(BatchRequestDto batchRequestDto)
{
var result = new List<FileOperationDto>();
foreach (var e in _fileStorageService.MoveOrCopyItems(batchRequestDto.FolderIds.ToList(), batchRequestDto.FileIds.ToList(), batchRequestDto.DestFolderId, batchRequestDto.ConflictResolveType, true, batchRequestDto.DeleteAfter))
{
result.Add(await _fileOperationDtoHelper.GetAsync(e));
}
return result;
}
public async Task<IEnumerable<FileOperationDto>> EmptyTrashAsync()
{
var emptyTrash = await _fileStorageService.EmptyTrashAsync();
var result = new List<FileOperationDto>();
foreach (var e in emptyTrash)
{
result.Add(await _fileOperationDtoHelper.GetAsync(e));
}
return result;
}
public async Task<IEnumerable<FileOperationDto>> MarkAsReadAsync(BaseBatchRequestDto batchRequestDto)
{
var result = new List<FileOperationDto>();
foreach (var e in _fileStorageService.MarkAsRead(batchRequestDto.FolderIds.ToList(), batchRequestDto.FileIds.ToList()))
{
result.Add(await _fileOperationDtoHelper.GetAsync(e));
}
return result;
}
public async Task<IEnumerable<FileOperationDto>> MoveBatchItemsAsync(BatchRequestDto batchRequestDto)
{
var result = new List<FileOperationDto>();
foreach (var e in _fileStorageService.MoveOrCopyItems(batchRequestDto.FolderIds.ToList(), batchRequestDto.FileIds.ToList(), batchRequestDto.DestFolderId, batchRequestDto.ConflictResolveType, false, batchRequestDto.DeleteAfter))
{
result.Add(await _fileOperationDtoHelper.GetAsync(e));
}
return result;
}
public async IAsyncEnumerable<FileEntryDto> MoveOrCopyBatchCheckAsync(BatchRequestDto batchRequestDto)
{
List<object> checkedFiles;
List<object> checkedFolders;
if (batchRequestDto.DestFolderId.ValueKind == JsonValueKind.Number)
{
(checkedFiles, checkedFolders) = await _fileStorageService.MoveOrCopyFilesCheckAsync(batchRequestDto.FileIds.ToList(), batchRequestDto.FolderIds.ToList(), batchRequestDto.DestFolderId.GetInt32());
}
else
{
(checkedFiles, checkedFolders) = await _fileStorageService.MoveOrCopyFilesCheckAsync(batchRequestDto.FileIds.ToList(), batchRequestDto.FolderIds.ToList(), batchRequestDto.DestFolderId.GetString());
}
var entries = await _fileStorageService.GetItemsAsync(checkedFiles.OfType<int>().Select(Convert.ToInt32), checkedFiles.OfType<int>().Select(Convert.ToInt32), FilterType.FilesOnly, false, "", "");
entries.AddRange(await _fileStorageService.GetItemsAsync(checkedFiles.OfType<string>(), checkedFiles.OfType<string>(), FilterType.FilesOnly, false, "", ""));
foreach (var e in entries)
{
yield return await GetFileEntryWrapperAsync(e);
}
}
}

View File

@ -0,0 +1,125 @@
using FileShare = ASC.Files.Core.Security.FileShare;
namespace ASC.Files.Helpers;
public class SecurityControllerHelper<T> : FilesHelperBase<T>
{
private readonly FileShareDtoHelper _fileShareDtoHelper;
private readonly FileShareParamsHelper _fileShareParamsHelper;
public SecurityControllerHelper(
FilesSettingsHelper filesSettingsHelper,
FileUploader fileUploader,
SocketManager socketManager,
FileDtoHelper fileDtoHelper,
ApiContext apiContext,
FileStorageService<T> fileStorageService,
FolderContentDtoHelper folderContentDtoHelper,
IHttpContextAccessor httpContextAccessor,
FolderDtoHelper folderDtoHelper,
FileShareDtoHelper fileShareDtoHelper,
FileShareParamsHelper fileShareParamsHelper)
: base(
filesSettingsHelper,
fileUploader,
socketManager,
fileDtoHelper,
apiContext,
fileStorageService,
folderContentDtoHelper,
httpContextAccessor,
folderDtoHelper)
{
_fileShareDtoHelper = fileShareDtoHelper;
_fileShareParamsHelper = fileShareParamsHelper;
}
public async Task<string> GenerateSharedLinkAsync(T fileId, FileShare share)
{
var file = await GetFileInfoAsync(fileId);
var tmpInfo = await _fileStorageService.GetSharedInfoAsync(new List<T> { fileId }, new List<T> { });
var sharedInfo = tmpInfo.Find(r => r.SubjectId == FileConstant.ShareLinkId);
if (sharedInfo == null || sharedInfo.Share != share)
{
var list = new List<AceWrapper>
{
new AceWrapper
{
SubjectId = FileConstant.ShareLinkId,
SubjectGroup = true,
Share = share
}
};
var aceCollection = new AceCollection<T>
{
Files = new List<T> { fileId },
Folders = new List<T>(0),
Aces = list
};
await _fileStorageService.SetAceObjectAsync(aceCollection, false);
tmpInfo = await _fileStorageService.GetSharedInfoAsync(new List<T> { fileId }, new List<T> { });
sharedInfo = tmpInfo.Find(r => r.SubjectId == FileConstant.ShareLinkId);
}
return sharedInfo.Link;
}
public Task<IEnumerable<FileShareDto>> GetFileSecurityInfoAsync(T fileId)
{
return GetSecurityInfoAsync(new List<T> { fileId }, new List<T> { });
}
public Task<IEnumerable<FileShareDto>> GetFolderSecurityInfoAsync(T folderId)
{
return GetSecurityInfoAsync(new List<T> { }, new List<T> { folderId });
}
public async Task<IEnumerable<FileShareDto>> GetSecurityInfoAsync(IEnumerable<T> fileIds, IEnumerable<T> folderIds)
{
var fileShares = await _fileStorageService.GetSharedInfoAsync(fileIds, folderIds);
return fileShares.Select(_fileShareDtoHelper.Get).ToList();
}
public async Task<bool> RemoveSecurityInfoAsync(List<T> fileIds, List<T> folderIds)
{
await _fileStorageService.RemoveAceAsync(fileIds, folderIds);
return true;
}
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoAsync(T fileId, IEnumerable<FileShareParams> share, bool notify, string sharingMessage)
{
return SetSecurityInfoAsync(new List<T> { fileId }, new List<T>(), share, notify, sharingMessage);
}
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoAsync(T folderId, IEnumerable<FileShareParams> share, bool notify, string sharingMessage)
{
return SetSecurityInfoAsync(new List<T>(), new List<T> { folderId }, share, notify, sharingMessage);
}
public async Task<IEnumerable<FileShareDto>> SetSecurityInfoAsync(IEnumerable<T> fileIds, IEnumerable<T> folderIds, IEnumerable<FileShareParams> share, bool notify, string sharingMessage)
{
if (share != null && share.Any())
{
var list = new List<AceWrapper>(share.Select(_fileShareParamsHelper.ToAceObject));
var aceCollection = new AceCollection<T>
{
Files = fileIds,
Folders = folderIds,
Aces = list,
Message = sharingMessage
};
await _fileStorageService.SetAceObjectAsync(aceCollection, notify);
}
return await GetSecurityInfoAsync(fileIds, folderIds);
}
}

View File

@ -0,0 +1,133 @@
namespace ASC.Files.Helpers;
public class UploadControllerHelper<T> : FilesHelperBase<T>
{
private readonly FilesLinkUtility _filesLinkUtility;
private readonly ChunkedUploadSessionHelper _chunkedUploadSessionHelper;
private readonly TenantManager _tenantManager;
private readonly IHttpClientFactory _httpClientFactory;
private readonly SecurityContext _securityContext;
public UploadControllerHelper(
FilesSettingsHelper filesSettingsHelper,
FileUploader fileUploader,
SocketManager socketManager,
FileDtoHelper fileDtoHelper,
ApiContext apiContext,
FileStorageService<T> fileStorageService,
FolderContentDtoHelper folderContentDtoHelper,
IHttpContextAccessor httpContextAccessor,
FolderDtoHelper folderDtoHelper,
FilesLinkUtility filesLinkUtility,
ChunkedUploadSessionHelper chunkedUploadSessionHelper,
TenantManager tenantManager,
IHttpClientFactory httpClientFactory,
SecurityContext securityContext)
: base(
filesSettingsHelper,
fileUploader,
socketManager,
fileDtoHelper,
apiContext,
fileStorageService,
folderContentDtoHelper,
httpContextAccessor,
folderDtoHelper)
{
_filesLinkUtility = filesLinkUtility;
_chunkedUploadSessionHelper = chunkedUploadSessionHelper;
_tenantManager = tenantManager;
_httpClientFactory = httpClientFactory;
_securityContext = securityContext;
}
public async Task<object> CreateUploadSessionAsync(T folderId, string fileName, long fileSize, string relativePath, ApiDateTime lastModified, bool encrypted)
{
var file = await _fileUploader.VerifyChunkedUploadAsync(folderId, fileName, fileSize, _filesSettingsHelper.UpdateIfExist, lastModified, relativePath);
if (_filesLinkUtility.IsLocalFileUploader)
{
var session = await _fileUploader.InitiateUploadAsync(file.ParentId, file.Id ?? default, file.Title, file.ContentLength, encrypted);
var responseObject = await _chunkedUploadSessionHelper.ToResponseObjectAsync(session, true);
return new
{
success = true,
data = responseObject
};
}
var createSessionUrl = _filesLinkUtility.GetInitiateUploadSessionUrl(_tenantManager.GetCurrentTenant().Id, file.ParentId, file.Id, file.Title, file.ContentLength, encrypted, _securityContext);
var httpClient = _httpClientFactory.CreateClient();
var request = new HttpRequestMessage();
request.RequestUri = new Uri(createSessionUrl);
request.Method = HttpMethod.Post;
// hack for uploader.onlyoffice.com in api requests
var rewriterHeader = _apiContext.HttpContextAccessor.HttpContext.Request.Headers[HttpRequestExtensions.UrlRewriterHeader];
if (!string.IsNullOrEmpty(rewriterHeader))
{
request.Headers.Add(HttpRequestExtensions.UrlRewriterHeader, rewriterHeader.ToString());
}
using var response = await httpClient.SendAsync(request);
using var responseStream = await response.Content.ReadAsStreamAsync();
using var streamReader = new StreamReader(responseStream);
return JObject.Parse(await streamReader.ReadToEndAsync()); //result is json string
}
public async Task<object> UploadFileAsync(T folderId, UploadRequestDto uploadModel)
{
if (uploadModel.StoreOriginalFileFlag.HasValue)
{
_filesSettingsHelper.StoreOriginalFiles = uploadModel.StoreOriginalFileFlag.Value;
}
IEnumerable<IFormFile> files = _httpContextAccessor.HttpContext.Request.Form.Files;
if (files == null || !files.Any())
{
files = uploadModel.Files;
}
if (files != null && files.Any())
{
if (files.Count() == 1)
{
//Only one file. return it
var postedFile = files.First();
return await InsertFileAsync(folderId, postedFile.OpenReadStream(), postedFile.FileName, uploadModel.CreateNewIfExist, uploadModel.KeepConvertStatus);
}
//For case with multiple files
var result = new List<object>();
foreach (var postedFile in uploadModel.Files)
{
result.Add(await InsertFileAsync(folderId, postedFile.OpenReadStream(), postedFile.FileName, uploadModel.CreateNewIfExist, uploadModel.KeepConvertStatus));
}
return result;
}
if (uploadModel.File != null)
{
var fileName = "file" + MimeMapping.GetExtention(uploadModel.ContentType.MediaType);
if (uploadModel.ContentDisposition != null)
{
fileName = uploadModel.ContentDisposition.FileName;
}
return new List<FileDto<T>>
{
await InsertFileAsync(folderId, uploadModel.File.OpenReadStream(), fileName, uploadModel.CreateNewIfExist, uploadModel.KeepConvertStatus)
};
}
throw new InvalidOperationException("No input files");
}
}