mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-13 18:00:05 +00:00
remove feed hacks from storage
This commit is contained in:
@@ -2,9 +2,7 @@ package storage
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"html"
|
||||
"log"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type Feed struct {
|
||||
@@ -19,22 +17,9 @@ type Feed struct {
|
||||
}
|
||||
|
||||
func (s *Storage) CreateFeed(title, description, link, feedLink string, folderId *int64) *Feed {
|
||||
title = html.UnescapeString(title)
|
||||
// WILD: fallback to `feed.link` -> `feed.feed_link` -> "<???>" if title is missing
|
||||
if title == "" {
|
||||
title = link
|
||||
// use domain if possible
|
||||
linkUrl, err := url.Parse(link)
|
||||
if err == nil && linkUrl.Host != "" && len(linkUrl.Path) <= 1 {
|
||||
title = linkUrl.Host
|
||||
}
|
||||
}
|
||||
if title == "" {
|
||||
title = feedLink
|
||||
}
|
||||
if title == "" {
|
||||
title = "<???>"
|
||||
}
|
||||
result, err := s.db.Exec(`
|
||||
insert into feeds (title, description, link, feed_link, folder_id)
|
||||
values (?, ?, ?, ?, ?)
|
||||
|
Reference in New Issue
Block a user