From 83a2a6ab679590023fd626c95b23bbf1b289bc6b Mon Sep 17 00:00:00 2001 From: Matthew Jorgensen Date: Wed, 29 Mar 2023 00:44:04 -0500 Subject: [PATCH 1/2] Revert "Revert "Introduce Bookmark.DefaultTags property"" --- BookmarkSync.Core.Tests/Entities/BookmarkTests.cs | 5 +++-- BookmarkSync.Core/Entities/Bookmark.cs | 2 ++ .../Bookmarking/Pinboard/PinboardBookmarkingService.cs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/BookmarkSync.Core.Tests/Entities/BookmarkTests.cs b/BookmarkSync.Core.Tests/Entities/BookmarkTests.cs index c38f612..2848f16 100644 --- a/BookmarkSync.Core.Tests/Entities/BookmarkTests.cs +++ b/BookmarkSync.Core.Tests/Entities/BookmarkTests.cs @@ -6,17 +6,18 @@ namespace BookmarkSync.Core.Tests.Entities; public class BookmarkTests { [TestMethod] - public void App_HasProperties() + public void Bookmark_HasProperties() { // Arrange Bookmark obj = new(); // Assert - Assert.AreEqual(5, obj.PropertyCount()); + Assert.AreEqual(6, obj.PropertyCount()); Assert.IsTrue(obj.HasProperty("Account")); Assert.IsTrue(obj.HasProperty("Content")); Assert.IsTrue(obj.HasProperty("Id")); Assert.IsTrue(obj.HasProperty("Uri")); Assert.IsTrue(obj.HasProperty("Visibility")); + Assert.IsTrue(obj.HasProperty("DefaultTags")); } } diff --git a/BookmarkSync.Core/Entities/Bookmark.cs b/BookmarkSync.Core/Entities/Bookmark.cs index 65dc4e6..706f647 100644 --- a/BookmarkSync.Core/Entities/Bookmark.cs +++ b/BookmarkSync.Core/Entities/Bookmark.cs @@ -14,4 +14,6 @@ public string? Content public string? Id { get; set; } public string? Uri { get; set; } public string? Visibility { get; set; } + public string DefaultTags => + string.Join(" ", $"via:@{Account}", "via:mastodon-bookmark-sync"); } diff --git a/BookmarkSync.Infrastructure/Services/Bookmarking/Pinboard/PinboardBookmarkingService.cs b/BookmarkSync.Infrastructure/Services/Bookmarking/Pinboard/PinboardBookmarkingService.cs index 15391f3..1409ea9 100644 --- a/BookmarkSync.Infrastructure/Services/Bookmarking/Pinboard/PinboardBookmarkingService.cs +++ b/BookmarkSync.Infrastructure/Services/Bookmarking/Pinboard/PinboardBookmarkingService.cs @@ -40,7 +40,7 @@ public async Task Save(Bookmark bookmark) { query["extended"] = extended; } - query["tags"] = string.Join(" ", $"via:@{bookmark.Account}", "via:mastodon-bookmark-sync"); + query["tags"] = bookmark.DefaultTags; builder.Query = query.ToString(); var requestUri = builder.ToString(); _logger.Debug("Request URI: {RequestUri}", requestUri); From b061294b1b3c75b171bef4a549535a94742f82dc Mon Sep 17 00:00:00 2001 From: Matthew Jorgensen Date: Wed, 29 Mar 2023 00:48:18 -0500 Subject: [PATCH 2/2] Make Bookmark.DefaultTags a string[] --- BookmarkSync.Core/Entities/Bookmark.cs | 4 ++-- .../Bookmarking/Pinboard/PinboardBookmarkingService.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BookmarkSync.Core/Entities/Bookmark.cs b/BookmarkSync.Core/Entities/Bookmark.cs index 706f647..27560bc 100644 --- a/BookmarkSync.Core/Entities/Bookmark.cs +++ b/BookmarkSync.Core/Entities/Bookmark.cs @@ -14,6 +14,6 @@ public string? Content public string? Id { get; set; } public string? Uri { get; set; } public string? Visibility { get; set; } - public string DefaultTags => - string.Join(" ", $"via:@{Account}", "via:mastodon-bookmark-sync"); + public string[] DefaultTags => + new[] { $"via:@{Account}", "via:mastodon-bookmark-sync"}; } diff --git a/BookmarkSync.Infrastructure/Services/Bookmarking/Pinboard/PinboardBookmarkingService.cs b/BookmarkSync.Infrastructure/Services/Bookmarking/Pinboard/PinboardBookmarkingService.cs index 1409ea9..1812d14 100644 --- a/BookmarkSync.Infrastructure/Services/Bookmarking/Pinboard/PinboardBookmarkingService.cs +++ b/BookmarkSync.Infrastructure/Services/Bookmarking/Pinboard/PinboardBookmarkingService.cs @@ -40,7 +40,7 @@ public async Task Save(Bookmark bookmark) { query["extended"] = extended; } - query["tags"] = bookmark.DefaultTags; + query["tags"] = string.Join(" ", bookmark.DefaultTags); builder.Query = query.ToString(); var requestUri = builder.ToString(); _logger.Debug("Request URI: {RequestUri}", requestUri);