mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-02-12 19:22:45 +00:00
notesnook: add support for user profile
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user