diff --git a/Notesnook.API/Controllers/MonographsController.cs b/Notesnook.API/Controllers/MonographsController.cs index 3d0282c..81bd18d 100644 --- a/Notesnook.API/Controllers/MonographsController.cs +++ b/Notesnook.API/Controllers/MonographsController.cs @@ -102,7 +102,7 @@ namespace Notesnook.API.Controllers } [HttpPost] - public async Task PublishAsync([FromQuery] string deviceId, [FromBody] Monograph monograph) + public async Task PublishAsync([FromQuery] string? deviceId, [FromBody] Monograph monograph) { try { @@ -150,7 +150,7 @@ namespace Notesnook.API.Controllers } [HttpPatch] - public async Task UpdateAsync([FromQuery] string deviceId, [FromBody] Monograph monograph) + public async Task UpdateAsync([FromQuery] string? deviceId, [FromBody] Monograph monograph) { try { @@ -265,7 +265,7 @@ namespace Notesnook.API.Controllers } [HttpDelete("{id}")] - public async Task DeleteAsync([FromQuery] string deviceId, [FromRoute] string id) + public async Task DeleteAsync([FromQuery] string? deviceId, [FromRoute] string id) { var monograph = await FindMonographAsync(id); if (monograph == null || monograph.Deleted) diff --git a/Notesnook.API/Controllers/S3Controller.cs b/Notesnook.API/Controllers/S3Controller.cs index 324d763..b027477 100644 --- a/Notesnook.API/Controllers/S3Controller.cs +++ b/Notesnook.API/Controllers/S3Controller.cs @@ -56,6 +56,13 @@ namespace Notesnook.API.Controllers if (!HttpContext.Request.Headers.ContentLength.HasValue) return BadRequest(new { error = "No Content-Length header found." }); long fileSize = HttpContext.Request.Headers.ContentLength.Value; + if (fileSize == 0) + { + var uploadUrl = S3Service.GetUploadObjectUrl(userId, name); + if (uploadUrl == null) return BadRequest(new { error = "Could not create signed url." }); + return Ok(uploadUrl); + } + var subscriptionService = await WampServers.SubscriptionServer.GetServiceAsync(SubscriptionServerTopics.UserSubscriptionServiceTopic); var subscription = await subscriptionService.GetUserSubscriptionAsync(Clients.Notesnook.Id, userId); diff --git a/Notesnook.API/Models/Monograph.cs b/Notesnook.API/Models/Monograph.cs index 1830e4c..bdc5e3f 100644 --- a/Notesnook.API/Models/Monograph.cs +++ b/Notesnook.API/Models/Monograph.cs @@ -75,7 +75,7 @@ namespace Notesnook.API.Models public bool SelfDestruct { get; set; } [JsonPropertyName("encryptedContent")] - public EncryptedData EncryptedContent { get; set; } + public EncryptedData? EncryptedContent { get; set; } [JsonPropertyName("datePublished")] public long DatePublished { get; set; } @@ -85,10 +85,10 @@ namespace Notesnook.API.Models public string Content { get; set; } [JsonIgnore] - public byte[] CompressedContent { get; set; } + public byte[]? CompressedContent { get; set; } [JsonPropertyName("password")] - public EncryptedData Password { get; set; } + public EncryptedData? Password { get; set; } [JsonPropertyName("deleted")] public bool Deleted { get; set; } diff --git a/Notesnook.API/Services/UserService.cs b/Notesnook.API/Services/UserService.cs index f237b8c..cc853b8 100644 --- a/Notesnook.API/Services/UserService.cs +++ b/Notesnook.API/Services/UserService.cs @@ -87,6 +87,7 @@ namespace Notesnook.API.Services Plan = SubscriptionPlan.FREE, UserId = response.UserId, StartTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), + Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), }); }