From 7742b58e15063cbecd9cccc9b7204a8b4597ba96 Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Wed, 15 Mar 2023 01:25:24 +1000 Subject: [PATCH 01/10] Fix rendering bug & bump deps --- Src/Notion.Client/Notion.Client.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Src/Notion.Client/Notion.Client.csproj b/Src/Notion.Client/Notion.Client.csproj index 4a614c6..31ea52d 100644 --- a/Src/Notion.Client/Notion.Client.csproj +++ b/Src/Notion.Client/Notion.Client.csproj @@ -19,10 +19,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + From 7daa961cc8d38180e40d24601f93e705b7281a78 Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Thu, 18 May 2023 09:58:57 +1000 Subject: [PATCH 02/10] Fix synced block serialization --- Src/Notion.Client/Models/Blocks/IBlock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Notion.Client/Models/Blocks/IBlock.cs b/Src/Notion.Client/Models/Blocks/IBlock.cs index bbe5d6e..24d6a12 100644 --- a/Src/Notion.Client/Models/Blocks/IBlock.cs +++ b/Src/Notion.Client/Models/Blocks/IBlock.cs @@ -29,7 +29,7 @@ namespace Notion.Client [JsonSubtypes.KnownSubTypeAttribute(typeof(ParagraphBlock), BlockType.Paragraph)] [JsonSubtypes.KnownSubTypeAttribute(typeof(PDFBlock), BlockType.PDF)] [JsonSubtypes.KnownSubTypeAttribute(typeof(QuoteBlock), BlockType.Quote)] - [JsonSubtypes.KnownSubTypeAttribute(typeof(UnsupportedBlock), BlockType.SyncedBlock)] + [JsonSubtypes.KnownSubTypeAttribute(typeof(SyncedBlockBlock), BlockType.SyncedBlock)] [JsonSubtypes.KnownSubTypeAttribute(typeof(TableBlock), BlockType.Table)] [JsonSubtypes.KnownSubTypeAttribute(typeof(TableRowBlock), BlockType.TableRow)] [JsonSubtypes.KnownSubTypeAttribute(typeof(TableOfContentsBlock), BlockType.TableOfContents)] From 16cb375603ecd0707d7cbabf40d06e2ea9705540 Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Thu, 18 May 2023 10:00:02 +1000 Subject: [PATCH 03/10] Revert "Fix rendering bug & bump deps" This reverts commit 7742b58e15063cbecd9cccc9b7204a8b4597ba96. --- Src/Notion.Client/Notion.Client.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Src/Notion.Client/Notion.Client.csproj b/Src/Notion.Client/Notion.Client.csproj index 31ea52d..4a614c6 100644 --- a/Src/Notion.Client/Notion.Client.csproj +++ b/Src/Notion.Client/Notion.Client.csproj @@ -19,10 +19,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + From 30ac232781f0dff173a60ece9ee449f6e5d1cbbb Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Fri, 26 May 2023 22:08:54 +1000 Subject: [PATCH 04/10] Fix IP not forwarding issue for Sphere10.com (and compilation error) --- Src/Notion.Client/Notion.Client.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Src/Notion.Client/Notion.Client.csproj b/Src/Notion.Client/Notion.Client.csproj index 4a614c6..31ea52d 100644 --- a/Src/Notion.Client/Notion.Client.csproj +++ b/Src/Notion.Client/Notion.Client.csproj @@ -19,10 +19,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + From 686e3ef6e370f22eb06604549c5a026aa8cffba9 Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Tue, 21 Nov 2023 10:42:36 +1000 Subject: [PATCH 05/10] Local Notion v1.1 --- Src/Notion.Client/Notion.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Notion.Client/Notion.Client.csproj b/Src/Notion.Client/Notion.Client.csproj index 31ea52d..1a3c641 100644 --- a/Src/Notion.Client/Notion.Client.csproj +++ b/Src/Notion.Client/Notion.Client.csproj @@ -21,7 +21,7 @@ - + From c0762403b2ed9d0106d7bc262c25e76f62c0ccd4 Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Wed, 13 Dec 2023 12:13:07 +1000 Subject: [PATCH 06/10] Sphere10.com emailing issue resolution --- Src/Notion.Client/Notion.Client.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Src/Notion.Client/Notion.Client.csproj b/Src/Notion.Client/Notion.Client.csproj index 1a3c641..04d8d1e 100644 --- a/Src/Notion.Client/Notion.Client.csproj +++ b/Src/Notion.Client/Notion.Client.csproj @@ -16,13 +16,13 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive - - + + From d6731b5015346982b4be1431757523dffc5ebe25 Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Tue, 28 May 2024 22:24:15 +1000 Subject: [PATCH 07/10] Bump Deps --- Src/Notion.Client/Notion.Client.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/Notion.Client/Notion.Client.csproj b/Src/Notion.Client/Notion.Client.csproj index e7d7024..95626f9 100644 --- a/Src/Notion.Client/Notion.Client.csproj +++ b/Src/Notion.Client/Notion.Client.csproj @@ -21,8 +21,8 @@ - - + + From 59520eec4d949820197c9842b3550d261c9ca321 Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Thu, 31 Oct 2024 15:39:10 +1000 Subject: [PATCH 08/10] Fix memory leaks --- Src/Notion.Client/RestClient/RestClient.cs | 26 +++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Src/Notion.Client/RestClient/RestClient.cs b/Src/Notion.Client/RestClient/RestClient.cs index 59a848f..1874dd7 100644 --- a/Src/Notion.Client/RestClient/RestClient.cs +++ b/Src/Notion.Client/RestClient/RestClient.cs @@ -22,8 +22,6 @@ public class RestClient : IRestClient ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() } }; - private HttpClient _httpClient; - public RestClient(ClientOptions options) { _options = MergeOptions(options); @@ -36,7 +34,7 @@ public async Task GetAsync( JsonSerializerSettings serializerSettings = null, CancellationToken cancellationToken = default) { - var response = await SendAsync(uri, HttpMethod.Get, queryParams, headers, + using var response = await SendAsync(uri, HttpMethod.Get, queryParams, headers, cancellationToken: cancellationToken); return await response.ParseStreamAsync(serializerSettings); @@ -56,7 +54,7 @@ void AttachContent(HttpRequestMessage httpRequest) Encoding.UTF8, "application/json"); } - var response = await SendAsync(uri, HttpMethod.Post, queryParams, headers, AttachContent, + using var response = await SendAsync(uri, HttpMethod.Post, queryParams, headers, AttachContent, cancellationToken); return await response.ParseStreamAsync(serializerSettings); @@ -76,7 +74,7 @@ void AttachContent(HttpRequestMessage httpRequest) httpRequest.Content = new StringContent(serializedBody, Encoding.UTF8, "application/json"); } - var response = await SendAsync(uri, new HttpMethod("PATCH"), queryParams, headers, AttachContent, + using var response = await SendAsync(uri, new HttpMethod("PATCH"), queryParams, headers, AttachContent, cancellationToken); return await response.ParseStreamAsync(serializerSettings); @@ -88,7 +86,7 @@ public async Task DeleteAsync( IDictionary headers = null, CancellationToken cancellationToken = default) { - await SendAsync(uri, HttpMethod.Delete, queryParams, headers, null, cancellationToken); + using var _ = await SendAsync(uri, HttpMethod.Delete, queryParams, headers, null, cancellationToken); } private static ClientOptions MergeOptions(ClientOptions options) @@ -141,7 +139,7 @@ private async Task SendAsync( Action attachContent = null, CancellationToken cancellationToken = default) { - EnsureHttpClient(); + using var client = GetHttpClient(); requestUri = AddQueryString(requestUri, queryParams); @@ -156,7 +154,7 @@ private async Task SendAsync( attachContent?.Invoke(httpRequest); - var response = await _httpClient.SendAsync(httpRequest, cancellationToken); + var response = await client.SendAsync(httpRequest, cancellationToken); if (!response.IsSuccessStatusCode) { @@ -174,17 +172,13 @@ private static void AddHeaders(HttpRequestMessage request, IDictionary> queryParams) From fc892701cb4dfb79149649a9ab2e6331c202573c Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Mon, 11 Nov 2024 21:07:29 +1000 Subject: [PATCH 09/10] Added support for "default_background" color --- Src/Notion.Client/Models/Blocks/Color.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Src/Notion.Client/Models/Blocks/Color.cs b/Src/Notion.Client/Models/Blocks/Color.cs index 46e38e2..ec6cc28 100644 --- a/Src/Notion.Client/Models/Blocks/Color.cs +++ b/Src/Notion.Client/Models/Blocks/Color.cs @@ -39,6 +39,9 @@ public enum Color [EnumMember(Value = "gray_background")] GrayBackground, + [EnumMember(Value = "default_background")] + DefaultBackground, + [EnumMember(Value = "brown_background")] BrownBackground, From 781ab72c9caeb6a93f6b92434d079ff4c9be08b2 Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Mon, 11 Nov 2024 21:07:59 +1000 Subject: [PATCH 10/10] Added support for "custom_emoji" page icons --- Src/Notion.Client/Models/CustomEmojiObject.cs | 25 +++++++++++++++++++ Src/Notion.Client/Models/Page/IPageIcon.cs | 1 + 2 files changed, 26 insertions(+) create mode 100644 Src/Notion.Client/Models/CustomEmojiObject.cs diff --git a/Src/Notion.Client/Models/CustomEmojiObject.cs b/Src/Notion.Client/Models/CustomEmojiObject.cs new file mode 100644 index 0000000..f682b65 --- /dev/null +++ b/Src/Notion.Client/Models/CustomEmojiObject.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; + +namespace Notion.Client +{ + public class CustomEmojiObject : IPageIcon + { + [JsonProperty("type")] + public virtual string Type { get; set; } + + [JsonProperty("custom_emoji")] + public Info Emoji { get; set; } + + public class Info + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + } + } +} diff --git a/Src/Notion.Client/Models/Page/IPageIcon.cs b/Src/Notion.Client/Models/Page/IPageIcon.cs index b9ebea5..44f8385 100644 --- a/Src/Notion.Client/Models/Page/IPageIcon.cs +++ b/Src/Notion.Client/Models/Page/IPageIcon.cs @@ -7,6 +7,7 @@ namespace Notion.Client [JsonSubtypes.KnownSubTypeAttribute(typeof(EmojiObject), "emoji")] [JsonSubtypes.KnownSubTypeAttribute(typeof(FileObject), "file")] [JsonSubtypes.KnownSubTypeAttribute(typeof(FileObject), "external")] + [JsonSubtypes.KnownSubTypeAttribute(typeof(CustomEmojiObject), "custom_emoji")] public interface IPageIcon { [JsonProperty("type")]