6 Commits

Author SHA1 Message Date
Abdullah Atta
33a189fe91 api: minor refactor 2025-08-18 23:44:22 +05:00
Abdullah Atta
2f361db9df monographs: fix monographs not appearing on clients 2025-08-18 23:44:22 +05:00
Minecon724
bf6cd6cd46 docker: fix the mongo healthcheck (#42) 2025-08-18 23:43:01 +05:00
Abdullah Atta
54266d1ba3 sync: disable SendMonographs on sync since its not supported by clients yet 2025-08-18 18:23:42 +05:00
Abdullah Atta
d3894d2a9f sync: fix StorageLimit does not match any field or property 2025-08-18 17:54:14 +05:00
Abdullah Atta
00c089e677 docker: get rid of initiate-rs0 2025-08-18 14:22:31 +05:00
4 changed files with 17 additions and 47 deletions

View File

@@ -201,7 +201,7 @@ namespace Notesnook.API.Controllers
var monographs = (await Monographs.Collection.FindAsync(
Builders<Monograph>.Filter.And(
Builders<Monograph>.Filter.Eq("UserId", userId),
Builders<Monograph>.Filter.Eq("Deleted", false)
Builders<Monograph>.Filter.Ne("Deleted", true)
)
, new FindOptions<Monograph, ObjectWithId>
{

View File

@@ -101,25 +101,6 @@ namespace Notesnook.API.Hubs
};
}
private Func<string, IEnumerable<string>, bool, int, Task<IAsyncCursor<SyncItem>>> MapTypeToFindItemsAction(string type)
{
return type switch
{
"settingitem" => Repositories.Settings.FindItemsById,
"attachment" => Repositories.Attachments.FindItemsById,
"note" => Repositories.Notes.FindItemsById,
"notebook" => Repositories.Notebooks.FindItemsById,
"content" => Repositories.Contents.FindItemsById,
"shortcut" => Repositories.Shortcuts.FindItemsById,
"reminder" => Repositories.Reminders.FindItemsById,
"relation" => Repositories.Relations.FindItemsById,
"color" => Repositories.Colors.FindItemsById,
"vault" => Repositories.Vaults.FindItemsById,
"tag" => Repositories.Tags.FindItemsById,
_ => null,
};
}
public async Task<int> PushItems(string deviceId, SyncTransferItemV2 pushItem)
{
var userId = Context.User.FindFirstValue("sub");
@@ -270,14 +251,14 @@ namespace Notesnook.API.Hubs
}
}
var unsyncedMonographs = ids.Where((id) => id.EndsWith(":monograph")).ToHashSet();
var unsyncedMonographIds = unsyncedMonographs.Select((id) => id.Split(":")[0]).ToArray();
var userMonographs = isResetSync
? await Repositories.Monographs.FindAsync(m => m.UserId == userId)
: await Repositories.Monographs.FindAsync(m => m.UserId == userId && unsyncedMonographIds.Contains(m.ItemId));
// var unsyncedMonographs = ids.Where((id) => id.EndsWith(":monograph")).ToHashSet();
// var unsyncedMonographIds = unsyncedMonographs.Select((id) => id.Split(":")[0]).ToArray();
// var userMonographs = isResetSync
// ? await Repositories.Monographs.FindAsync(m => m.UserId == userId)
// : await Repositories.Monographs.FindAsync(m => m.UserId == userId && unsyncedMonographIds.Contains(m.ItemId));
if (userMonographs.Any() && !await Clients.Caller.SendMonographs(userMonographs).WaitAsync(TimeSpan.FromMinutes(10)))
throw new HubException("Client rejected monographs.");
// if (userMonographs.Any() && !await Clients.Caller.SendMonographs(userMonographs).WaitAsync(TimeSpan.FromMinutes(10)))
// throw new HubException("Client rejected monographs.");
deviceService.Reset();

View File

@@ -23,6 +23,12 @@ using Notesnook.API.Interfaces;
namespace Notesnook.API.Models
{
public class Limit
{
public long Value { get; set; }
public long UpdatedAt { get; set; }
}
public class UserSettings : IUserSettings
{
public UserSettings()
@@ -35,6 +41,7 @@ namespace Notesnook.API.Models
public EncryptedData VaultKey { get; set; }
public EncryptedData AttachmentsKey { get; set; }
public EncryptedData MonographPasswordsKey { get; set; }
public Limit StorageLimit { get; set; }
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]

View File

@@ -59,30 +59,11 @@ services:
validate:
condition: service_completed_successfully
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh mongodb://localhost:27017 --quiet
test: echo 'try { rs.status() } catch (err) { rs.initiate() }; db.runCommand("ping").ok' | mongosh mongodb://localhost:27017 --quiet
interval: 40s
timeout: 30s
retries: 3
start_period: 60s
# the notesnook sync server requires transactions which only work
# with a MongoDB replica set.
# This job just runs `rs.initiate()` on our mongodb instance
# upgrading it to a replica set. This is only required once but we running
# it multiple times is no issue.
initiate-rs0:
image: mongo:7.0.12
networks:
- notesnook
depends_on:
- notesnook-db
entrypoint: /bin/sh
command:
- -c
- |
mongosh mongodb://notesnook-db:27017 <<EOF
rs.initiate();
rs.status();
EOF
notesnook-s3:
image: minio/minio:RELEASE.2024-07-29T22-14-52Z
@@ -231,3 +212,4 @@ networks:
volumes:
dbdata:
s3data: