Compare commits

..
5 changed files with 32 additions and 30 deletions
+19 -19
View File
@@ -210,25 +210,25 @@ namespace Notesnook.API.Controllers
} }
} }
[HttpPost("bulk-delete")] // [HttpPost("bulk-delete")]
public async Task<IActionResult> DeleteBulkAsync([FromBody] DeleteBulkObjectsRequest request) // public async Task<IActionResult> DeleteBulkAsync([FromBody] DeleteBulkObjectsRequest request)
{ // {
try // try
{ // {
if (request.Names == null || request.Names.Length == 0) // if (request.Names == null || request.Names.Length == 0)
{ // {
return BadRequest(new { error = "No files specified for deletion." }); // return BadRequest(new { error = "No files specified for deletion." });
} // }
var userId = this.User.GetUserId(); // var userId = this.User.GetUserId();
await s3Service.DeleteObjectsAsync(userId, request.Names); // await s3Service.DeleteObjectsAsync(userId, request.Names);
return Ok(); // return Ok();
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
logger.LogError(ex, "Error deleting objects for user."); // logger.LogError(ex, "Error deleting objects for user.");
return BadRequest(new { error = "Failed to delete attachments." }); // return BadRequest(new { error = "Failed to delete attachments." });
} // }
} // }
} }
} }
+4 -4
View File
@@ -82,7 +82,7 @@ namespace Notesnook.API.Services
if (chunk != null) if (chunk != null)
{ {
var update = Builders<DeviceIdsChunk>.Update.AddToSetEach(x => x.Ids, ids.Select(i => i.ToString())); var update = Builders<DeviceIdsChunk>.Update.AddToSetEach(x => x.Ids, ids.Select(i => i.ToString()));
await repositories.DeviceIdsChunks.Collection.UpdateOneAsync( await repositories.DeviceIdsChunks.Collection.WithWriteConcern(WriteConcern.W1).UpdateOneAsync(
Builders<DeviceIdsChunk>.Filter.Eq(x => x.Id, chunk.Id), Builders<DeviceIdsChunk>.Filter.Eq(x => x.Id, chunk.Id),
update update
); );
@@ -96,11 +96,11 @@ namespace Notesnook.API.Services
Key = key, Key = key,
Ids = [.. ids.Select(i => i.ToString())] Ids = [.. ids.Select(i => i.ToString())]
}; };
await repositories.DeviceIdsChunks.Collection.InsertOneAsync(newChunk); await repositories.DeviceIdsChunks.Collection.WithWriteConcern(WriteConcern.W1).InsertOneAsync(newChunk);
} }
var emptyChunksFilter = DeviceIdsChunkFilter(userId, deviceId, key) & Builders<DeviceIdsChunk>.Filter.Size(x => x.Ids, 0); var emptyChunksFilter = DeviceIdsChunkFilter(userId, deviceId, key) & Builders<DeviceIdsChunk>.Filter.Size(x => x.Ids, 0);
await repositories.DeviceIdsChunks.Collection.DeleteManyAsync(emptyChunksFilter); await repositories.DeviceIdsChunks.Collection.WithWriteConcern(WriteConcern.W1).DeleteManyAsync(emptyChunksFilter);
} }
public async Task WriteIdsAsync(string userId, string deviceId, string key, IEnumerable<ItemKey> ids) public async Task WriteIdsAsync(string userId, string deviceId, string key, IEnumerable<ItemKey> ids)
@@ -121,7 +121,7 @@ namespace Notesnook.API.Services
}; };
writes.Add(new InsertOneModel<DeviceIdsChunk>(newChunk)); writes.Add(new InsertOneModel<DeviceIdsChunk>(newChunk));
} }
await repositories.DeviceIdsChunks.Collection.BulkWriteAsync(writes); await repositories.DeviceIdsChunks.Collection.WithWriteConcern(WriteConcern.W1).BulkWriteAsync(writes);
} }
public async Task<HashSet<ItemKey>> FetchUnsyncedIdsAsync(string userId, string deviceId) public async Task<HashSet<ItemKey>> FetchUnsyncedIdsAsync(string userId, string deviceId)
+1
View File
@@ -39,6 +39,7 @@ namespace Streetwriters.Common
AppId = ApplicationType.NOTESNOOK, AppId = ApplicationType.NOTESNOOK,
AccountRecoveryRedirectURL = $"{Constants.NOTESNOOK_APP_HOST}/account/recovery", AccountRecoveryRedirectURL = $"{Constants.NOTESNOOK_APP_HOST}/account/recovery",
EmailConfirmedRedirectURL = $"{Constants.NOTESNOOK_APP_HOST}/account/verified", EmailConfirmedRedirectURL = $"{Constants.NOTESNOOK_APP_HOST}/account/verified",
PackageName = "com.streetwriters.notesnook",
OnEmailConfirmed = async (userId) => OnEmailConfirmed = async (userId) =>
{ {
await WampServers.MessengerServer.PublishMessageAsync(MessengerServerTopics.SendSSETopic, new SendSSEMessage await WampServers.MessengerServer.PublishMessageAsync(MessengerServerTopics.SendSSETopic, new SendSSEMessage
+1
View File
@@ -39,6 +39,7 @@ namespace Streetwriters.Common.Models
public required string SenderName { get; set; } public required string SenderName { get; set; }
public required string EmailConfirmedRedirectURL { get; set; } public required string EmailConfirmedRedirectURL { get; set; }
public required string AccountRecoveryRedirectURL { get; set; } public required string AccountRecoveryRedirectURL { get; set; }
public required string PackageName { get; set; }
public Func<string, Task>? OnEmailConfirmed { get; set; } public Func<string, Task>? OnEmailConfirmed { get; set; }
} }
+7 -7
View File
@@ -39,7 +39,7 @@ function isValidUrl(urlString: string): boolean {
// Handle proxied request with redirect support // Handle proxied request with redirect support
async function proxyRequest( async function proxyRequest(
targetUrl: string, targetUrl: string,
redirectCount = 0 redirectCount = 0,
): Promise<Response> { ): Promise<Response> {
if (redirectCount >= MAX_REDIRECTS) { if (redirectCount >= MAX_REDIRECTS) {
return new Response("Too many redirects", { return new Response("Too many redirects", {
@@ -147,7 +147,7 @@ const server = Bun.serve({
method2: "GET /?url=<encoded-url>", method2: "GET /?url=<encoded-url>",
example1: `${url.origin}/https://example.com/image.jpg`, example1: `${url.origin}/https://example.com/image.jpg`,
example2: `${url.origin}/?url=${encodeURIComponent( example2: `${url.origin}/?url=${encodeURIComponent(
"https://example.com/image.jpg" "https://example.com/image.jpg",
)}`, )}`,
}, },
endpoints: { endpoints: {
@@ -190,7 +190,7 @@ const server = Bun.serve({
{ {
status: 400, status: 400,
headers: corsHeaders, headers: corsHeaders,
} },
); );
} }
@@ -218,8 +218,8 @@ const server = Bun.serve({
status: 200, status: 200,
headers: { headers: {
"Content-Type": "text/html; charset=utf-8", "Content-Type": "text/html; charset=utf-8",
"Content-Security-Policy": "frame-ancestors *", // "Content-Security-Policy": "frame-ancestors *",
"X-Frame-Options": "ALLOWALL", // "X-Frame-Options": "ALLOWALL",
}, },
}); });
} }
@@ -239,7 +239,7 @@ const server = Bun.serve({
}); });
console.log( console.log(
`🚀 CORS Proxy Server running on http://${server.hostname}:${server.port}` `🚀 CORS Proxy Server running on http://${server.hostname}:${server.port}`,
); );
console.log(`📋 Health check: http://${server.hostname}:${server.port}/health`); console.log(`📋 Health check: http://${server.hostname}:${server.port}/health`);
console.log(`🌍 Environment: ${Bun.env.NODE_ENV || "development"}`); console.log(`🌍 Environment: ${Bun.env.NODE_ENV || "development"}`);
@@ -280,7 +280,7 @@ function serveYouTubeEmbed(url: string) {
</head> </head>
<body> <body>
<iframe src="${transformYouTubeUrl( <iframe src="${transformYouTubeUrl(
url url,
)}" allow="accelerometer;autoplay;clipboard-write;encrypted-media;gyroscope;picture-in-picture;web-share" allowfullscreen referrerpolicy="strict-origin-when-cross-origin" title="Video player"></iframe> )}" allow="accelerometer;autoplay;clipboard-write;encrypted-media;gyroscope;picture-in-picture;web-share" allowfullscreen referrerpolicy="strict-origin-when-cross-origin" title="Video player"></iframe>
</body> </body>
</html>`; </html>`;