mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-02-12 19:22:45 +00:00
global: add null safety checks
This commit is contained in:
@@ -40,7 +40,7 @@ namespace Notesnook.API.Models
|
||||
|
||||
[JsonPropertyName("type")]
|
||||
[BsonElement("type")]
|
||||
public string Type { get; set; }
|
||||
public required string Type { get; set; }
|
||||
|
||||
[JsonPropertyName("timestamp")]
|
||||
[BsonElement("timestamp")]
|
||||
@@ -48,7 +48,7 @@ namespace Notesnook.API.Models
|
||||
|
||||
[JsonPropertyName("platforms")]
|
||||
[BsonElement("platforms")]
|
||||
public string[] Platforms { get; set; }
|
||||
public required string[] Platforms { get; set; }
|
||||
|
||||
[JsonPropertyName("isActive")]
|
||||
[BsonElement("isActive")]
|
||||
@@ -56,7 +56,7 @@ namespace Notesnook.API.Models
|
||||
|
||||
[JsonPropertyName("userTypes")]
|
||||
[BsonElement("userTypes")]
|
||||
public string[] UserTypes { get; set; }
|
||||
public required string[] UserTypes { get; set; }
|
||||
|
||||
[JsonPropertyName("appVersion")]
|
||||
[BsonElement("appVersion")]
|
||||
@@ -64,63 +64,63 @@ namespace Notesnook.API.Models
|
||||
|
||||
[JsonPropertyName("body")]
|
||||
[BsonElement("body")]
|
||||
public BodyComponent[] Body { get; set; }
|
||||
public required BodyComponent[] Body { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[BsonElement("userIds")]
|
||||
public string[] UserIds { get; set; }
|
||||
public string[]? UserIds { get; set; }
|
||||
|
||||
|
||||
[Obsolete]
|
||||
[JsonPropertyName("title")]
|
||||
[DataMember(Name = "title")]
|
||||
[BsonElement("title")]
|
||||
public string Title { get; set; }
|
||||
public string? Title { get; set; }
|
||||
|
||||
[Obsolete]
|
||||
[JsonPropertyName("description")]
|
||||
[BsonElement("description")]
|
||||
public string Description { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Obsolete]
|
||||
[JsonPropertyName("callToActions")]
|
||||
[BsonElement("callToActions")]
|
||||
public CallToAction[] CallToActions { get; set; }
|
||||
public CallToAction[]? CallToActions { get; set; }
|
||||
}
|
||||
|
||||
public class BodyComponent
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
[BsonElement("type")]
|
||||
public string Type { get; set; }
|
||||
public required string Type { get; set; }
|
||||
|
||||
[JsonPropertyName("platforms")]
|
||||
[BsonElement("platforms")]
|
||||
public string[] Platforms { get; set; }
|
||||
public string[]? Platforms { get; set; }
|
||||
|
||||
[JsonPropertyName("style")]
|
||||
[BsonElement("style")]
|
||||
public Style Style { get; set; }
|
||||
public Style? Style { get; set; }
|
||||
|
||||
[JsonPropertyName("src")]
|
||||
[BsonElement("src")]
|
||||
public string Src { get; set; }
|
||||
public string? Src { get; set; }
|
||||
|
||||
[JsonPropertyName("text")]
|
||||
[BsonElement("text")]
|
||||
public string Text { get; set; }
|
||||
public string? Text { get; set; }
|
||||
|
||||
[JsonPropertyName("value")]
|
||||
[BsonElement("value")]
|
||||
public string Value { get; set; }
|
||||
public string? Value { get; set; }
|
||||
|
||||
[JsonPropertyName("items")]
|
||||
[BsonElement("items")]
|
||||
public BodyComponent[] Items { get; set; }
|
||||
public BodyComponent[]? Items { get; set; }
|
||||
|
||||
[JsonPropertyName("actions")]
|
||||
[BsonElement("actions")]
|
||||
public CallToAction[] Actions { get; set; }
|
||||
public required CallToAction[] Actions { get; set; }
|
||||
}
|
||||
|
||||
public class Style
|
||||
@@ -135,25 +135,25 @@ namespace Notesnook.API.Models
|
||||
|
||||
[JsonPropertyName("textAlign")]
|
||||
[BsonElement("textAlign")]
|
||||
public string TextAlign { get; set; }
|
||||
public string? TextAlign { get; set; }
|
||||
}
|
||||
|
||||
public class CallToAction
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
[BsonElement("type")]
|
||||
public string Type { get; set; }
|
||||
public required string Type { get; set; }
|
||||
|
||||
[JsonPropertyName("platforms")]
|
||||
[BsonElement("platforms")]
|
||||
public string[] Platforms { get; set; }
|
||||
public string[]? Platforms { get; set; }
|
||||
|
||||
[JsonPropertyName("data")]
|
||||
[BsonElement("data")]
|
||||
public string Data { get; set; }
|
||||
public string? Data { get; set; }
|
||||
|
||||
[JsonPropertyName("title")]
|
||||
[BsonElement("title")]
|
||||
public string Title { get; set; }
|
||||
public string? Title { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ namespace Notesnook.API.Models;
|
||||
|
||||
public class CompleteMultipartUploadRequestWrapper
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public List<PartETagWrapper> PartETags { get; set; }
|
||||
public string UploadId { get; set; }
|
||||
public required string Key { get; set; }
|
||||
public required List<PartETagWrapper> PartETags { get; set; }
|
||||
public required string UploadId { get; set; }
|
||||
|
||||
public CompleteMultipartUploadRequest ToRequest()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Notesnook.API.Models
|
||||
public class DeleteAccountForm
|
||||
{
|
||||
[Required]
|
||||
public string Password
|
||||
public required string Password
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
@@ -26,25 +26,19 @@ using System.Text.Json.Serialization;
|
||||
namespace Notesnook.API.Models
|
||||
{
|
||||
[MessagePack.MessagePackObject]
|
||||
public class EncryptedData : IEncrypted
|
||||
public class EncryptedData
|
||||
{
|
||||
[MessagePack.Key("iv")]
|
||||
[JsonPropertyName("iv")]
|
||||
[BsonElement("iv")]
|
||||
[DataMember(Name = "iv")]
|
||||
public string IV
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public required string IV { get; set; }
|
||||
|
||||
[MessagePack.Key("cipher")]
|
||||
[JsonPropertyName("cipher")]
|
||||
[BsonElement("cipher")]
|
||||
[DataMember(Name = "cipher")]
|
||||
public string Cipher
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public required string Cipher { get; set; }
|
||||
|
||||
[MessagePack.Key("length")]
|
||||
[JsonPropertyName("length")]
|
||||
@@ -56,9 +50,9 @@ namespace Notesnook.API.Models
|
||||
[JsonPropertyName("salt")]
|
||||
[BsonElement("salt")]
|
||||
[DataMember(Name = "salt")]
|
||||
public string Salt { get; set; }
|
||||
public required string Salt { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is EncryptedData encryptedData)
|
||||
{
|
||||
|
||||
@@ -37,16 +37,16 @@ namespace Notesnook.API.Models
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
[JsonIgnore]
|
||||
[MessagePack.IgnoreMember]
|
||||
public string Id { get; set; }
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("userId")]
|
||||
public string UserId { get; set; }
|
||||
public required string UserId { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
public required string Name { get; set; }
|
||||
|
||||
[JsonPropertyName("key")]
|
||||
public string Key { get; set; }
|
||||
public string Key { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("dateCreated")]
|
||||
public long DateCreated { get; set; }
|
||||
|
||||
@@ -31,19 +31,13 @@ namespace Notesnook.API.Models
|
||||
[JsonPropertyName("key")]
|
||||
[MessagePack.Key("key")]
|
||||
[Required]
|
||||
public EncryptedKey Key
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public required EncryptedKey Key { get; set; }
|
||||
|
||||
[DataMember(Name = "salt")]
|
||||
[JsonPropertyName("salt")]
|
||||
[MessagePack.Key("salt")]
|
||||
[Required]
|
||||
public string Salt
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public required string Salt { get; set; }
|
||||
}
|
||||
|
||||
[MessagePack.MessagePackObject]
|
||||
@@ -53,19 +47,13 @@ namespace Notesnook.API.Models
|
||||
[JsonPropertyName("alg")]
|
||||
[MessagePack.Key("alg")]
|
||||
[Required]
|
||||
public string Algorithm
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public required string Algorithm { get; set; }
|
||||
|
||||
[DataMember(Name = "cipher")]
|
||||
[JsonPropertyName("cipher")]
|
||||
[MessagePack.Key("cipher")]
|
||||
[Required]
|
||||
public string Cipher
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public required string Cipher { get; set; }
|
||||
|
||||
[JsonPropertyName("length")]
|
||||
[DataMember(Name = "length")]
|
||||
|
||||
@@ -29,15 +29,9 @@ namespace Notesnook.API.Models
|
||||
[BsonId]
|
||||
[BsonIgnoreIfDefault]
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string Id
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public required string Id { get; set; }
|
||||
|
||||
public string ItemId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public required string ItemId { get; set; }
|
||||
}
|
||||
|
||||
public class Monograph
|
||||
@@ -50,23 +44,17 @@ namespace Notesnook.API.Models
|
||||
[DataMember(Name = "id")]
|
||||
[JsonPropertyName("id")]
|
||||
[MessagePack.Key("id")]
|
||||
public string ItemId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string? ItemId { get; set; }
|
||||
|
||||
[BsonId]
|
||||
[BsonIgnoreIfDefault]
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
[JsonIgnore]
|
||||
[MessagePack.IgnoreMember]
|
||||
public string Id
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("title")]
|
||||
public string Title { get; set; }
|
||||
public string? Title { get; set; }
|
||||
|
||||
[JsonPropertyName("userId")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace Notesnook.API.Models
|
||||
public class MonographContent
|
||||
{
|
||||
[JsonPropertyName("data")]
|
||||
public string Data { get; set; }
|
||||
public required string Data { get; set; }
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; }
|
||||
public required string Type { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ namespace Notesnook.API.Models
|
||||
}
|
||||
|
||||
[JsonPropertyName("title")]
|
||||
public required string Title { get; set; }
|
||||
public string? Title { get; set; }
|
||||
|
||||
[JsonPropertyName("selfDestruct")]
|
||||
public bool SelfDestruct { get; set; }
|
||||
|
||||
@@ -17,11 +17,13 @@ You should have received a copy of the Affero GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Notesnook.API.Models
|
||||
{
|
||||
public class MultipartUploadMeta
|
||||
{
|
||||
public string UploadId { get; set; }
|
||||
public string[] Parts { get; set; }
|
||||
public string UploadId { get; set; } = string.Empty;
|
||||
public string[] Parts { get; set; } = Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,5 @@
|
||||
public class PartETagWrapper
|
||||
{
|
||||
public int PartNumber { get; set; }
|
||||
public string ETag { get; set; }
|
||||
public string ETag { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -6,9 +6,9 @@ namespace Notesnook.API.Models.Responses
|
||||
public class SignupResponse : Response
|
||||
{
|
||||
[JsonPropertyName("userId")]
|
||||
public string UserId { get; set; }
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[JsonPropertyName("errors")]
|
||||
public string[] Errors { get; set; }
|
||||
public string[]? Errors { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ namespace Notesnook.API.Models
|
||||
{
|
||||
public class S3Options
|
||||
{
|
||||
public string ServiceUrl { get; set; }
|
||||
public string Region { get; set; }
|
||||
public string AccessKeyId { get; set; }
|
||||
public string SecretAccessKey { get; set; }
|
||||
public string ServiceUrl { get; set; } = string.Empty;
|
||||
public string Region { get; set; } = string.Empty;
|
||||
public string AccessKeyId { get; set; } = string.Empty;
|
||||
public string SecretAccessKey { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -53,20 +53,14 @@ namespace Notesnook.API.Models
|
||||
[DataMember(Name = "iv")]
|
||||
[MessagePack.Key("iv")]
|
||||
[Required]
|
||||
public string IV
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string IV { get; set; } = string.Empty;
|
||||
|
||||
|
||||
[JsonPropertyName("cipher")]
|
||||
[DataMember(Name = "cipher")]
|
||||
[MessagePack.Key("cipher")]
|
||||
[Required]
|
||||
public string Cipher
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string Cipher { get; set; } = string.Empty;
|
||||
|
||||
[DataMember(Name = "id")]
|
||||
[JsonPropertyName("id")]
|
||||
@@ -108,10 +102,7 @@ namespace Notesnook.API.Models
|
||||
[DataMember(Name = "alg")]
|
||||
[MessagePack.Key("alg")]
|
||||
[Required]
|
||||
public string Algorithm
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string Algorithm { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class SyncItemBsonSerializer : SerializerBase<SyncItem>
|
||||
|
||||
@@ -29,23 +29,23 @@ namespace Notesnook.API.Models
|
||||
public long UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
public class UserSettings : IUserSettings
|
||||
public class UserSettings
|
||||
{
|
||||
public UserSettings()
|
||||
{
|
||||
this.Id = ObjectId.GenerateNewId().ToString();
|
||||
this.Id = ObjectId.GenerateNewId();
|
||||
}
|
||||
public string UserId { get; set; }
|
||||
public required string UserId { get; set; }
|
||||
public long LastSynced { get; set; }
|
||||
public string Salt { get; set; }
|
||||
public required string Salt { get; set; }
|
||||
public EncryptedData? VaultKey { get; set; }
|
||||
public EncryptedData? AttachmentsKey { get; set; }
|
||||
public EncryptedData? MonographPasswordsKey { get; set; }
|
||||
public InboxKeys? InboxKeys { get; set; }
|
||||
public Limit StorageLimit { get; set; }
|
||||
public Limit? StorageLimit { get; set; }
|
||||
|
||||
[BsonId]
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string Id { get; set; }
|
||||
public ObjectId Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user