-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #45
- Loading branch information
Showing
6 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Linkding/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pinboard/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Raindropio/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=unbookmark/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/BookmarkSync.Infrastructure/Services/Bookmarking/Linkding/LinkdingBookmarkingService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Net.Http.Headers; | ||
using System.Net.Mime; | ||
using System.Text; | ||
using Newtonsoft.Json; | ||
|
||
namespace BookmarkSync.Infrastructure.Services.Bookmarking.Linkding; | ||
|
||
public class LinkdingBookmarkingService : BookmarkingService, IBookmarkingService | ||
{ | ||
private static readonly ILogger _logger = Log.ForContext<LinkdingBookmarkingService>(); | ||
public LinkdingBookmarkingService(IConfigManager configManager) | ||
{ | ||
ApiToken = configManager.App.Bookmarking.ApiToken ?? throw new InvalidOperationException("Missing API token"); | ||
string linkAceUri = configManager.GetConfigValue("App:Bookmarking:LinkdingUri") ?? | ||
throw new InvalidOperationException("Missing linkding Uri"); | ||
ApiUri = $"{linkAceUri}/api/bookmarks/"; | ||
Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Token", ApiToken); | ||
} | ||
/// <inheritdoc /> | ||
public async Task<HttpResponseMessage> Save(Bookmark bookmark) | ||
{ | ||
// Prep payload | ||
Dictionary<string, object?> payload = new() | ||
{ | ||
{ | ||
"url", bookmark.Uri | ||
}, | ||
{ | ||
"title", bookmark.Content | ||
}, | ||
{ | ||
"tag_names", bookmark.DefaultTags | ||
}, | ||
{ | ||
"unread", false | ||
}, | ||
{ | ||
"shared", false | ||
} | ||
}; | ||
var stringContent = new StringContent(JsonConvert.SerializeObject(payload), Encoding.UTF8, | ||
MediaTypeNames.Application.Json); | ||
var response = await Client.PostAsync(ApiUri, stringContent); | ||
response.EnsureSuccessStatusCode(); | ||
_logger.Debug("Response status: {StatusCode}", response.StatusCode); | ||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters