notesnook: add support for user profile

This commit is contained in:
Abdullah Atta
2024-03-05 10:25:54 +05:00
parent 1dcf6557a7
commit 9a98c1afb8
4 changed files with 14 additions and 0 deletions

View File

@@ -31,5 +31,6 @@ namespace Notesnook.API.Interfaces
Task<bool> ResetUserAsync(string userId, bool removeAttachments);
Task<UserResponse> GetUserAsync(bool repair = true);
Task SetUserAttachmentsKeyAsync(string userId, IEncrypted key);
Task SetUserProfileAsync(string userId, IEncrypted profile);
}
}

View File

@@ -15,6 +15,9 @@ namespace Notesnook.API.Models.Responses
[JsonPropertyName("subscription")]
public ISubscription Subscription { get; set; }
[JsonPropertyName("profile")]
public EncryptedData Profile { get; set; }
[JsonIgnore]
public bool Success { get; set; }
public int StatusCode { get; set; }

View File

@@ -34,6 +34,7 @@ namespace Notesnook.API.Models
public string Salt { get; set; }
public EncryptedData VaultKey { get; set; }
public EncryptedData AttachmentsKey { get; set; }
public EncryptedData Profile { get; set; }
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]

View File

@@ -153,6 +153,7 @@ namespace Notesnook.API.Services
response.AttachmentsKey = userSettings.AttachmentsKey;
response.Salt = userSettings.Salt;
response.Subscription = subscription;
response.Profile = userSettings.Profile;
return response;
}
@@ -163,6 +164,13 @@ namespace Notesnook.API.Services
await Repositories.UsersSettings.UpdateAsync(userSettings.Id, userSettings);
}
public async Task SetUserProfileAsync(string userId, IEncrypted profile)
{
var userSettings = await Repositories.UsersSettings.FindOneAsync((u) => u.UserId == userId);
userSettings.Profile = (EncryptedData)profile;
await Repositories.UsersSettings.UpdateAsync(userSettings.Id, userSettings);
}
public async Task<bool> DeleteUserAsync(string userId, string jti)
{
var cc = new CancellationTokenSource();
@@ -220,6 +228,7 @@ namespace Notesnook.API.Services
userSettings.AttachmentsKey = null;
userSettings.VaultKey = null;
userSettings.Profile = null;
userSettings.LastSynced = 0;
await Repositories.UsersSettings.UpsertAsync(userSettings, (s) => s.UserId == userId);