Fixed 403 Forbidden thrown when getting Website metadata

- Add User-Agent to header to prevent 403 Forbidden when downloading webpage strings
- Add Bookmark URL and User Id unique combo constraint
- Add Tag Name and User Id unique combo constraint
This commit is contained in:
2023-03-04 00:37:59 -06:00
parent e9d6c2ef88
commit 34d459cc58
5 changed files with 271 additions and 5 deletions

View File

@ -253,6 +253,7 @@ namespace YABA.Service
private void UpdateBookmarkWithMetaData(IBookmark bookmark)
{
var webClient = new WebClient();
webClient.Headers.Add("User-Agent", "APIClient");
var sourceData = webClient.DownloadString(bookmark.Url);
var title = Regex.Match(sourceData, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value;
var description = string.Empty;