Skip to content

Commit 75eb175

Browse files
authored
Merge pull request #118 from mateof/feat/webdav-native-hyperbackup
feat(webdav): native read/write WebDAV endpoint (Hyper Backup); retire Python proxy
2 parents ea34ce7 + 08feb98 commit 75eb175

27 files changed

Lines changed: 1185 additions & 690 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
TelegramDownloader/userData.json
22
TelegramDownloader/.claude/
33
.claude/
4+
plans/

TelegramDownloader/Configuration/config.example.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
"mongo_connection_string": "",
66
"avoid_checking_certificate": false,
77
"open_browser_on_startup": true,
8-
"mobile_api_key": "my_api_key"
8+
"mobile_api_key": "my_api_key",
9+
"webdav_user": "",
10+
"webdav_password": ""
911
}

TelegramDownloader/Controllers/Api/V1/ConfigController.cs

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ public async Task<IActionResult> Update([FromBody] UpdateConfigRequest request)
9090
if (request.MultiConnectionBlockSizeMB.HasValue) c.MultiConnectionBlockSizeMB = Math.Clamp(request.MultiConnectionBlockSizeMB.Value, 1, 16);
9191
if (request.MultiConnectionMinFileSizeMB.HasValue) c.MultiConnectionMinFileSizeMB = request.MultiConnectionMinFileSizeMB.Value;
9292

93-
c.webDav ??= new WebDavModel();
94-
if (!string.IsNullOrWhiteSpace(request.WebDavHost)) c.webDav.Host = request.WebDavHost;
95-
if (request.WebDavInternalPort.HasValue) c.webDav.PuertoEntrada = request.WebDavInternalPort.Value;
96-
if (request.WebDavExternalPort.HasValue) c.webDav.PuertoSalida = request.WebDavExternalPort.Value;
97-
9893
await GeneralConfigStatic.SaveChanges(_db, c);
9994

10095
return OkResult(AppConfigDto.From(GeneralConfigStatic.config), "Configuration saved");
@@ -106,55 +101,5 @@ public async Task<IActionResult> Update([FromBody] UpdateConfigRequest request)
106101
}
107102
}
108103

109-
/// <summary>State of the WebDAV bridge.</summary>
110-
[HttpGet("webdav")]
111-
[ProducesResponseType(typeof(ApiResult<WebDavConfigDto>), StatusCodes.Status200OK)]
112-
public IActionResult WebDav() => OkResult(AppConfigDto.From(GeneralConfigStatic.config).WebDav);
113-
114-
/// <summary>Starts the WebDAV bridge.</summary>
115-
/// <remarks>
116-
/// Once running, channels are reachable as WebDAV shares at
117-
/// <c>http://&lt;host&gt;:&lt;externalPort&gt;/&lt;channelId&gt;/</c>,
118-
/// which is how media servers mount a library.
119-
/// </remarks>
120-
[HttpPost("webdav/start")]
121-
[ProducesResponseType(typeof(ApiResult<WebDavConfigDto>), StatusCodes.Status200OK)]
122-
public IActionResult StartWebDav()
123-
{
124-
try
125-
{
126-
var webDav = GeneralConfigStatic.config.webDav;
127-
if (webDav == null)
128-
return BadRequestResult("WebDAV is not configured");
129-
130-
if (webDav.webDavService?.IsRunning == true)
131-
return ConflictResult("The WebDAV bridge is already running", ApiErrorCodes.AlreadyRunning);
132-
133-
webDav.start();
134-
return OkResult(AppConfigDto.From(GeneralConfigStatic.config).WebDav, "WebDAV bridge started");
135-
}
136-
catch (Exception ex)
137-
{
138-
_logger.LogError(ex, "Error starting the WebDAV bridge");
139-
return ErrorResult("Could not start the WebDAV bridge", ex);
140-
}
141-
}
142-
143-
/// <summary>Stops the WebDAV bridge.</summary>
144-
[HttpPost("webdav/stop")]
145-
[ProducesResponseType(typeof(ApiResult<WebDavConfigDto>), StatusCodes.Status200OK)]
146-
public IActionResult StopWebDav()
147-
{
148-
try
149-
{
150-
GeneralConfigStatic.config.webDav?.stop();
151-
return OkResult(AppConfigDto.From(GeneralConfigStatic.config).WebDav, "WebDAV bridge stopped");
152-
}
153-
catch (Exception ex)
154-
{
155-
_logger.LogError(ex, "Error stopping the WebDAV bridge");
156-
return ErrorResult("Could not stop the WebDAV bridge", ex);
157-
}
158-
}
159104
}
160105
}

TelegramDownloader/Controllers/Api/V1/SystemController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public async Task<IActionResult> Info()
6161
{
6262
Version = typeof(Program).Assembly.GetName().Version?.ToString() ?? "unknown",
6363
TelegramConfigured = _telegram.IsConfigured,
64-
RequiresApiKey = !string.IsNullOrEmpty(GeneralConfigStatic.tlconfig?.mobile_api_key),
65-
WebDavRunning = GeneralConfigStatic.config?.webDav?.webDavService?.IsRunning ?? false
64+
RequiresApiKey = !string.IsNullOrEmpty(GeneralConfigStatic.config?.MobileApiKey)
65+
|| !string.IsNullOrEmpty(GeneralConfigStatic.tlconfig?.mobile_api_key)
6666
};
6767

6868
try

0 commit comments

Comments
 (0)