From 1ba0630b63c0affbb71c9ed18bcd29fc76b23edc Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 17 Nov 2025 22:06:59 -0800 Subject: [PATCH] Coalesced the many small Feedly models into a single FeedlyModel.swift file. --- .../Sources/Account/Feedly/FeedlyModel.swift | 393 ++++++++++++++++++ .../Feedly/Models/FeedlyCategory.swift | 14 - .../Feedly/Models/FeedlyCollection.swift | 15 - .../Models/FeedlyCollectionParser.swift | 23 - .../Account/Feedly/Models/FeedlyEntry.swift | 65 --- .../FeedlyEntryIdentifierProviding.swift | 29 -- .../Feedly/Models/FeedlyEntryParser.swift | 114 ----- .../Account/Feedly/Models/FeedlyFeed.swift | 16 - .../Feedly/Models/FeedlyFeedParser.swift | 32 -- .../Models/FeedlyFeedsSearchResponse.swift | 18 - .../Account/Feedly/Models/FeedlyLink.swift | 18 - .../Account/Feedly/Models/FeedlyOrigin.swift | 15 - .../Models/FeedlyRTLTextSanitizer.swift | 28 -- .../Feedly/Models/FeedlyResourceId.swift | 85 ---- .../Account/Feedly/Models/FeedlyStream.swift | 26 -- .../Feedly/Models/FeedlyStreamIds.swift | 18 - .../Account/Feedly/Models/FeedlyTag.swift | 14 - 17 files changed, 393 insertions(+), 530 deletions(-) create mode 100644 Modules/Account/Sources/Account/Feedly/FeedlyModel.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyCategory.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyCollection.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyCollectionParser.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyEntry.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyEntryIdentifierProviding.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyEntryParser.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyFeed.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyFeedParser.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyFeedsSearchResponse.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyLink.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyOrigin.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyRTLTextSanitizer.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyResourceId.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyStream.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyStreamIds.swift delete mode 100644 Modules/Account/Sources/Account/Feedly/Models/FeedlyTag.swift diff --git a/Modules/Account/Sources/Account/Feedly/FeedlyModel.swift b/Modules/Account/Sources/Account/Feedly/FeedlyModel.swift new file mode 100644 index 000000000..c6f25dd3b --- /dev/null +++ b/Modules/Account/Sources/Account/Feedly/FeedlyModel.swift @@ -0,0 +1,393 @@ +// +// File.swift +// Account +// +// Created by Brent Simmons on 11/17/25. +// + +import Foundation +import RSParser + +struct FeedlyCategory: Decodable, Sendable { + let label: String + let id: String +} + +struct FeedlyCollection: Codable, Sendable { + let feeds: [FeedlyFeed] + let label: String + let id: String +} + +struct FeedlyCollectionParser { + let collection: FeedlyCollection + + private let rightToLeftTextSantizer = FeedlyRTLTextSanitizer() + + var folderName: String { + return rightToLeftTextSantizer.sanitize(collection.label) ?? "" + } + + var externalID: String { + return collection.id + } +} + +struct FeedlyFeed: Codable, Sendable { + let id: String + let title: String? + let updated: Date? + let website: String? +} + +struct FeedlyFeedParser { + let feed: FeedlyFeed + + private let rightToLeftTextSantizer = FeedlyRTLTextSanitizer() + + var title: String? { + return rightToLeftTextSantizer.sanitize(feed.title) ?? "" + } + + var feedID: String { + return feed.id + } + + var url: String { + let resource = FeedlyFeedResourceId(id: feed.id) + return resource.url + } + + var homePageURL: String? { + return feed.website + } +} + +struct FeedlyFeedsSearchResponse: Decodable, Sendable { + struct Feed: Decodable { + let title: String + let feedId: String + } + + let results: [Feed] +} + +struct FeedlyLink: Decodable, Sendable { + let href: String + + /// The mime type of the resource located by `href`. + /// When `nil`, it's probably a web page? + /// https://groups.google.com/forum/#!searchin/feedly-cloud/feed$20url%7Csort:date/feedly-cloud/Rx3dVd4aTFQ/Hf1ZfLJoCQAJ + let type: String? +} + +struct FeedlyOrigin: Decodable, Sendable { + let title: String? + let streamId: String? + let htmlUrl: String? +} + +struct FeedlyStream: Decodable, Sendable { + let id: String + + /// Of the most recent entry for this stream (regardless of continuation, newerThan, etc). + let updated: Date? + + /// the continuation id to pass to the next stream call, for pagination. + /// This id guarantees that no entry will be duplicated in a stream (meaning, there is no need to de-duplicate entries returned by this call). + /// If this value is not returned, it means the end of the stream has been reached. + let continuation: String? + let items: [FeedlyEntry] + + var isStreamEnd: Bool { + return continuation == nil + } +} + +struct FeedlyStreamIds: Decodable, Sendable { + let continuation: String? + let ids: [String] + + var isStreamEnd: Bool { + return continuation == nil + } +} + +struct FeedlyTag: Decodable, Sendable { + let id: String + let label: String? +} + +struct FeedlyEntry: Decodable, Sendable { + /// the unique, immutable ID for this particular article. + let id: String + + /// the article’s title. This string does not contain any HTML markup. + let title: String? + + struct Content: Decodable { + + enum Direction: String, Decodable { + case leftToRight = "ltr" + case rightToLeft = "rtl" + } + + let content: String? + let direction: Direction? + } + + /// This object typically has two values: “content” for the content itself, and “direction” (“ltr” for left-to-right, “rtl” for right-to-left). The content itself contains sanitized HTML markup. + let content: Content? + + /// content object the article summary. See the content object above. + let summary: Content? + + /// the author’s name + let author: String? + + /// the immutable timestamp, in ms, when this article was processed by the feedly Cloud servers. + let crawled: Date + + /// the timestamp, in ms, when this article was re-processed and updated by the feedly Cloud servers. + let recrawled: Date? + + /// the feed from which this article was crawled. If present, “streamId” will contain the feed id, “title” will contain the feed title, and “htmlUrl” will contain the feed’s website. + let origin: FeedlyOrigin? + + /// Used to help find the URL to visit an article on a web site. + /// See https://groups.google.com/forum/#!searchin/feedly-cloud/feed$20url%7Csort:date/feedly-cloud/Rx3dVd4aTFQ/Hf1ZfLJoCQAJ + let canonical: [FeedlyLink]? + + /// a list of alternate links for this article. Each link object contains a media type and a URL. Typically, a single object is present, with a link to the original web page. + let alternate: [FeedlyLink]? + + /// Was this entry read by the user? If an Authorization header is not provided, this will always return false. If an Authorization header is provided, it will reflect if the user has read this entry or not. + let unread: Bool + + /// a list of tag objects (“id” and “label”) that the user added to this entry. This value is only returned if an Authorization header is provided, and at least one tag has been added. If the entry has been explicitly marked as read (not the feed itself), the “global.read” tag will be present. + let tags: [FeedlyTag]? + + /// a list of category objects (“id” and “label”) that the user associated with the feed of this entry. This value is only returned if an Authorization header is provided. + let categories: [FeedlyCategory]? + + /// A list of media links (videos, images, sound etc) provided by the feed. Some entries do not have a summary or content, only a collection of media links. + let enclosure: [FeedlyLink]? +} + +struct FeedlyEntryParser { + let entry: FeedlyEntry + + private let rightToLeftTextSantizer = FeedlyRTLTextSanitizer() + + var id: String { + return entry.id + } + + /// When ingesting articles, the feedURL must match a feed's `feedID` for the article to be reachable between it and its matching feed. It reminds me of a foreign key. + var feedUrl: String? { + guard let id = entry.origin?.streamId else { + // At this point, check Feedly's API isn't glitching or the response has not changed structure. + assertionFailure("Entries need to be traceable to a feed or this entry will be dropped.") + return nil + } + return id + } + + /// Convoluted external URL logic "documented" here: + /// https://groups.google.com/forum/#!searchin/feedly-cloud/feed$20url%7Csort:date/feedly-cloud/Rx3dVd4aTFQ/Hf1ZfLJoCQAJ + var externalUrl: String? { + let multidimensionalArrayOfLinks = [entry.canonical, entry.alternate] + let withExistingValues = multidimensionalArrayOfLinks.compactMap { $0 } + let flattened = withExistingValues.flatMap { $0 } + let webPageLinks = flattened.filter { $0.type == nil || $0.type == "text/html" } + return webPageLinks.first?.href + } + + var title: String? { + return rightToLeftTextSantizer.sanitize(entry.title) + } + + var contentHMTL: String? { + return entry.content?.content ?? entry.summary?.content + } + + var contentText: String? { + // We could strip HTML from contentHTML? + return nil + } + + var summary: String? { + return rightToLeftTextSantizer.sanitize(entry.summary?.content) + } + + var datePublished: Date { + return entry.crawled + } + + var dateModified: Date? { + return entry.recrawled + } + + var authors: Set? { + guard let name = entry.author else { + return nil + } + return Set([ParsedAuthor(name: name, url: nil, avatarURL: nil, emailAddress: nil)]) + } + + /// While there is not yet a tagging interface, articles can still be searched for by tags. + var tags: Set? { + guard let labels = entry.tags?.compactMap({ $0.label }), !labels.isEmpty else { + return nil + } + return Set(labels) + } + + var attachments: Set? { + guard let enclosure = entry.enclosure, !enclosure.isEmpty else { + return nil + } + let attachments = enclosure.compactMap { ParsedAttachment(url: $0.href, mimeType: $0.type, title: nil, sizeInBytes: nil, durationInSeconds: nil) } + return attachments.isEmpty ? nil : Set(attachments) + } + + var parsedItemRepresentation: ParsedItem? { + guard let feedUrl = feedUrl else { + return nil + } + + return ParsedItem(syncServiceID: id, + uniqueID: id, // This value seems to get ignored or replaced. + feedURL: feedUrl, + url: nil, + externalURL: externalUrl, + title: title, + language: nil, + contentHTML: contentHMTL, + contentText: contentText, + markdown: nil, + summary: summary, + imageURL: nil, + bannerImageURL: nil, + datePublished: datePublished, + dateModified: dateModified, + authors: authors, + tags: tags, + attachments: attachments) + } +} + +struct FeedlyRTLTextSanitizer: Sendable { + private let rightToLeftPrefix = "
" + private let rightToLeftSuffix = "
" + + func sanitize(_ sourceText: String?) -> String? { + guard let source = sourceText, !source.isEmpty else { + return sourceText + } + + guard source.hasPrefix(rightToLeftPrefix) && source.hasSuffix(rightToLeftSuffix) else { + return source + } + + let start = source.index(source.startIndex, offsetBy: rightToLeftPrefix.indices.count) + let end = source.index(source.endIndex, offsetBy: -rightToLeftSuffix.indices.count) + return String(source[start.. { get } +} + +final class FeedlyEntryIdentifierProvider: FeedlyEntryIdentifierProviding { + private(set) var entryIDs: Set + + init(entryIDs: Set = Set()) { + self.entryIDs = entryIDs + } + + func addEntryIDs(from provider: FeedlyEntryIdentifierProviding) { + entryIDs.formUnion(provider.entryIDs) + } + + func addEntryIDs(in articleIDs: [String]) { + entryIDs.formUnion(articleIDs) + } +} + +/// The kinds of Resource Ids is documented here: https://developer.feedly.com/cloud/ +protocol FeedlyResourceId { + + /// The resource Id from Feedly. + var id: String { get } +} + +/// The Feed Resource is documented here: https://developer.feedly.com/cloud/ +struct FeedlyFeedResourceId: FeedlyResourceId { + let id: String + + /// The location of the kind of resource a concrete type represents. + /// If the concrete type cannot strip the resource type from the Id, it should just return the Id + /// since the Id is a legitimate URL. + /// This is basically assuming Feedly prefixes source feed URLs with `feed/`. + /// It is not documented as such and could potentially change. + /// Feedly does not include the source feed URL as a separate field. + /// See https://developer.feedly.com/v3/feeds/#get-the-metadata-about-a-specific-feed + var url: String { + if let range = id.range(of: "feed/"), range.lowerBound == id.startIndex { + var mutant = id + mutant.removeSubrange(range) + return mutant + } + + // It seems values like "something/https://my.blog/posts.xml" is a legit URL. + return id + } +} + +extension FeedlyFeedResourceId { + init(url: String) { + self.id = "feed/\(url)" + } +} + +struct FeedlyCategoryResourceId: FeedlyResourceId { + let id: String + + enum Global { + + static func uncategorized(for userId: String) -> FeedlyCategoryResourceId { + // https://developer.feedly.com/cloud/#global-resource-ids + let id = "user/\(userId)/category/global.uncategorized" + return FeedlyCategoryResourceId(id: id) + } + + /// All articles from all the feeds the user subscribes to. + static func all(for userId: String) -> FeedlyCategoryResourceId { + // https://developer.feedly.com/cloud/#global-resource-ids + let id = "user/\(userId)/category/global.all" + return FeedlyCategoryResourceId(id: id) + } + + /// All articles from all the feeds the user loves most. + static func mustRead(for userId: String) -> FeedlyCategoryResourceId { + // https://developer.feedly.com/cloud/#global-resource-ids + let id = "user/\(userId)/category/global.must" + return FeedlyCategoryResourceId(id: id) + } + } +} + +struct FeedlyTagResourceId: FeedlyResourceId { + let id: String + + enum Global { + + static func saved(for userId: String) -> FeedlyTagResourceId { + // https://developer.feedly.com/cloud/#global-resource-ids + let id = "user/\(userId)/tag/global.saved" + return FeedlyTagResourceId(id: id) + } + } +} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyCategory.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyCategory.swift deleted file mode 100644 index 534788692..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyCategory.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// FeedlyCategory.swift -// Account -// -// Created by Kiel Gillard on 19/9/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyCategory: Decodable { - let label: String - let id: String -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyCollection.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyCollection.swift deleted file mode 100644 index 930694562..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyCollection.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// FeedlyCollection.swift -// Account -// -// Created by Kiel Gillard on 19/9/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyCollection: Codable, Sendable { - let feeds: [FeedlyFeed] - let label: String - let id: String -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyCollectionParser.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyCollectionParser.swift deleted file mode 100644 index c346b94f3..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyCollectionParser.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// FeedlyCollectionParser.swift -// Account -// -// Created by Kiel Gillard on 28/1/20. -// Copyright © 2020 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyCollectionParser { - let collection: FeedlyCollection - - private let rightToLeftTextSantizer = FeedlyRTLTextSanitizer() - - var folderName: String { - return rightToLeftTextSantizer.sanitize(collection.label) ?? "" - } - - var externalID: String { - return collection.id - } -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyEntry.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyEntry.swift deleted file mode 100644 index 7d46d61f7..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyEntry.swift +++ /dev/null @@ -1,65 +0,0 @@ -// -// FeedlyEntry.swift -// Account -// -// Created by Kiel Gillard on 19/9/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyEntry: Decodable, Sendable { - /// the unique, immutable ID for this particular article. - let id: String - - /// the article’s title. This string does not contain any HTML markup. - let title: String? - - struct Content: Decodable { - - enum Direction: String, Decodable { - case leftToRight = "ltr" - case rightToLeft = "rtl" - } - - let content: String? - let direction: Direction? - } - - /// This object typically has two values: “content” for the content itself, and “direction” (“ltr” for left-to-right, “rtl” for right-to-left). The content itself contains sanitized HTML markup. - let content: Content? - - /// content object the article summary. See the content object above. - let summary: Content? - - /// the author’s name - let author: String? - - /// the immutable timestamp, in ms, when this article was processed by the feedly Cloud servers. - let crawled: Date - - /// the timestamp, in ms, when this article was re-processed and updated by the feedly Cloud servers. - let recrawled: Date? - - /// the feed from which this article was crawled. If present, “streamId” will contain the feed id, “title” will contain the feed title, and “htmlUrl” will contain the feed’s website. - let origin: FeedlyOrigin? - - /// Used to help find the URL to visit an article on a web site. - /// See https://groups.google.com/forum/#!searchin/feedly-cloud/feed$20url%7Csort:date/feedly-cloud/Rx3dVd4aTFQ/Hf1ZfLJoCQAJ - let canonical: [FeedlyLink]? - - /// a list of alternate links for this article. Each link object contains a media type and a URL. Typically, a single object is present, with a link to the original web page. - let alternate: [FeedlyLink]? - - /// Was this entry read by the user? If an Authorization header is not provided, this will always return false. If an Authorization header is provided, it will reflect if the user has read this entry or not. - let unread: Bool - - /// a list of tag objects (“id” and “label”) that the user added to this entry. This value is only returned if an Authorization header is provided, and at least one tag has been added. If the entry has been explicitly marked as read (not the feed itself), the “global.read” tag will be present. - let tags: [FeedlyTag]? - - /// a list of category objects (“id” and “label”) that the user associated with the feed of this entry. This value is only returned if an Authorization header is provided. - let categories: [FeedlyCategory]? - - /// A list of media links (videos, images, sound etc) provided by the feed. Some entries do not have a summary or content, only a collection of media links. - let enclosure: [FeedlyLink]? -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyEntryIdentifierProviding.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyEntryIdentifierProviding.swift deleted file mode 100644 index d98108afa..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyEntryIdentifierProviding.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// FeedlyEntryIdentifierProviding.swift -// Account -// -// Created by Kiel Gillard on 9/1/20. -// Copyright © 2020 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -protocol FeedlyEntryIdentifierProviding: AnyObject { - var entryIDs: Set { get } -} - -final class FeedlyEntryIdentifierProvider: FeedlyEntryIdentifierProviding { - private(set) var entryIDs: Set - - init(entryIDs: Set = Set()) { - self.entryIDs = entryIDs - } - - func addEntryIDs(from provider: FeedlyEntryIdentifierProviding) { - entryIDs.formUnion(provider.entryIDs) - } - - func addEntryIDs(in articleIDs: [String]) { - entryIDs.formUnion(articleIDs) - } -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyEntryParser.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyEntryParser.swift deleted file mode 100644 index ce1609313..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyEntryParser.swift +++ /dev/null @@ -1,114 +0,0 @@ -// -// FeedlyEntryParser.swift -// Account -// -// Created by Kiel Gillard on 3/10/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation -import Articles -import RSParser - -struct FeedlyEntryParser { - let entry: FeedlyEntry - - private let rightToLeftTextSantizer = FeedlyRTLTextSanitizer() - - var id: String { - return entry.id - } - - /// When ingesting articles, the feedURL must match a feed's `feedID` for the article to be reachable between it and its matching feed. It reminds me of a foreign key. - var feedUrl: String? { - guard let id = entry.origin?.streamId else { - // At this point, check Feedly's API isn't glitching or the response has not changed structure. - assertionFailure("Entries need to be traceable to a feed or this entry will be dropped.") - return nil - } - return id - } - - /// Convoluted external URL logic "documented" here: - /// https://groups.google.com/forum/#!searchin/feedly-cloud/feed$20url%7Csort:date/feedly-cloud/Rx3dVd4aTFQ/Hf1ZfLJoCQAJ - var externalUrl: String? { - let multidimensionalArrayOfLinks = [entry.canonical, entry.alternate] - let withExistingValues = multidimensionalArrayOfLinks.compactMap { $0 } - let flattened = withExistingValues.flatMap { $0 } - let webPageLinks = flattened.filter { $0.type == nil || $0.type == "text/html" } - return webPageLinks.first?.href - } - - var title: String? { - return rightToLeftTextSantizer.sanitize(entry.title) - } - - var contentHMTL: String? { - return entry.content?.content ?? entry.summary?.content - } - - var contentText: String? { - // We could strip HTML from contentHTML? - return nil - } - - var summary: String? { - return rightToLeftTextSantizer.sanitize(entry.summary?.content) - } - - var datePublished: Date { - return entry.crawled - } - - var dateModified: Date? { - return entry.recrawled - } - - var authors: Set? { - guard let name = entry.author else { - return nil - } - return Set([ParsedAuthor(name: name, url: nil, avatarURL: nil, emailAddress: nil)]) - } - - /// While there is not yet a tagging interface, articles can still be searched for by tags. - var tags: Set? { - guard let labels = entry.tags?.compactMap({ $0.label }), !labels.isEmpty else { - return nil - } - return Set(labels) - } - - var attachments: Set? { - guard let enclosure = entry.enclosure, !enclosure.isEmpty else { - return nil - } - let attachments = enclosure.compactMap { ParsedAttachment(url: $0.href, mimeType: $0.type, title: nil, sizeInBytes: nil, durationInSeconds: nil) } - return attachments.isEmpty ? nil : Set(attachments) - } - - var parsedItemRepresentation: ParsedItem? { - guard let feedUrl = feedUrl else { - return nil - } - - return ParsedItem(syncServiceID: id, - uniqueID: id, // This value seems to get ignored or replaced. - feedURL: feedUrl, - url: nil, - externalURL: externalUrl, - title: title, - language: nil, - contentHTML: contentHMTL, - contentText: contentText, - markdown: nil, - summary: summary, - imageURL: nil, - bannerImageURL: nil, - datePublished: datePublished, - dateModified: dateModified, - authors: authors, - tags: tags, - attachments: attachments) - } -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyFeed.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyFeed.swift deleted file mode 100644 index 5bb4e0b04..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyFeed.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// FeedlyFeed.swift -// Account -// -// Created by Kiel Gillard on 19/9/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyFeed: Codable, Sendable { - let id: String - let title: String? - let updated: Date? - let website: String? -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyFeedParser.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyFeedParser.swift deleted file mode 100644 index e69d2b5e8..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyFeedParser.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// FeedlyFeedParser.swift -// Account -// -// Created by Kiel Gillard on 29/1/20. -// Copyright © 2020 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyFeedParser { - let feed: FeedlyFeed - - private let rightToLeftTextSantizer = FeedlyRTLTextSanitizer() - - var title: String? { - return rightToLeftTextSantizer.sanitize(feed.title) ?? "" - } - - var feedID: String { - return feed.id - } - - var url: String { - let resource = FeedlyFeedResourceId(id: feed.id) - return resource.url - } - - var homePageURL: String? { - return feed.website - } -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyFeedsSearchResponse.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyFeedsSearchResponse.swift deleted file mode 100644 index cc3c09614..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyFeedsSearchResponse.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// FeedlyFeedsSearchResponse.swift -// Account -// -// Created by Kiel Gillard on 1/12/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyFeedsSearchResponse: Decodable, Sendable { - struct Feed: Decodable { - let title: String - let feedId: String - } - - let results: [Feed] -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyLink.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyLink.swift deleted file mode 100644 index 74c009c6f..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyLink.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// FeedlyLink.swift -// Account -// -// Created by Kiel Gillard on 3/10/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyLink: Decodable { - let href: String - - /// The mime type of the resource located by `href`. - /// When `nil`, it's probably a web page? - /// https://groups.google.com/forum/#!searchin/feedly-cloud/feed$20url%7Csort:date/feedly-cloud/Rx3dVd4aTFQ/Hf1ZfLJoCQAJ - let type: String? -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyOrigin.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyOrigin.swift deleted file mode 100644 index bd4a8cc86..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyOrigin.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// FeedlyOrigin.swift -// Account -// -// Created by Kiel Gillard on 19/9/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyOrigin: Decodable { - let title: String? - let streamId: String? - let htmlUrl: String? -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyRTLTextSanitizer.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyRTLTextSanitizer.swift deleted file mode 100644 index c81210cc4..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyRTLTextSanitizer.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// FeedlyRTLTextSanitizer.swift -// Account -// -// Created by Kiel Gillard on 28/1/20. -// Copyright © 2020 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyRTLTextSanitizer: Sendable { - private let rightToLeftPrefix = "
" - private let rightToLeftSuffix = "
" - - func sanitize(_ sourceText: String?) -> String? { - guard let source = sourceText, !source.isEmpty else { - return sourceText - } - - guard source.hasPrefix(rightToLeftPrefix) && source.hasSuffix(rightToLeftSuffix) else { - return source - } - - let start = source.index(source.startIndex, offsetBy: rightToLeftPrefix.indices.count) - let end = source.index(source.endIndex, offsetBy: -rightToLeftSuffix.indices.count) - return String(source[start.. FeedlyCategoryResourceId { - // https://developer.feedly.com/cloud/#global-resource-ids - let id = "user/\(userId)/category/global.uncategorized" - return FeedlyCategoryResourceId(id: id) - } - - /// All articles from all the feeds the user subscribes to. - static func all(for userId: String) -> FeedlyCategoryResourceId { - // https://developer.feedly.com/cloud/#global-resource-ids - let id = "user/\(userId)/category/global.all" - return FeedlyCategoryResourceId(id: id) - } - - /// All articles from all the feeds the user loves most. - static func mustRead(for userId: String) -> FeedlyCategoryResourceId { - // https://developer.feedly.com/cloud/#global-resource-ids - let id = "user/\(userId)/category/global.must" - return FeedlyCategoryResourceId(id: id) - } - } -} - -struct FeedlyTagResourceId: FeedlyResourceId { - let id: String - - enum Global { - - static func saved(for userId: String) -> FeedlyTagResourceId { - // https://developer.feedly.com/cloud/#global-resource-ids - let id = "user/\(userId)/tag/global.saved" - return FeedlyTagResourceId(id: id) - } - } -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyStream.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyStream.swift deleted file mode 100644 index 7c72823fc..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyStream.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// FeedlyStream.swift -// Account -// -// Created by Kiel Gillard on 19/9/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyStream: Decodable, Sendable { - let id: String - - /// Of the most recent entry for this stream (regardless of continuation, newerThan, etc). - let updated: Date? - - /// the continuation id to pass to the next stream call, for pagination. - /// This id guarantees that no entry will be duplicated in a stream (meaning, there is no need to de-duplicate entries returned by this call). - /// If this value is not returned, it means the end of the stream has been reached. - let continuation: String? - let items: [FeedlyEntry] - - var isStreamEnd: Bool { - return continuation == nil - } -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyStreamIds.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyStreamIds.swift deleted file mode 100644 index 698937d8a..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyStreamIds.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// FeedlyStreamIds.swift -// Account -// -// Created by Kiel Gillard on 18/10/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyStreamIds: Decodable, Sendable { - let continuation: String? - let ids: [String] - - var isStreamEnd: Bool { - return continuation == nil - } -} diff --git a/Modules/Account/Sources/Account/Feedly/Models/FeedlyTag.swift b/Modules/Account/Sources/Account/Feedly/Models/FeedlyTag.swift deleted file mode 100644 index 0111b95e2..000000000 --- a/Modules/Account/Sources/Account/Feedly/Models/FeedlyTag.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// FeedlyTag.swift -// Account -// -// Created by Kiel Gillard on 3/10/19. -// Copyright © 2019 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -struct FeedlyTag: Decodable { - let id: String - let label: String? -}