mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-30 01:10:38 +00:00
Support OPML import for FreshRSS accounts
This commit is contained in:
1 parent
9732f6ada9
commit
91c69841ea
2 files changed
+25
-1
No files matched your search
@@ -54,7 +54,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
let refreshProgress = RSProgress()
|
||||
|
||||
var behaviors: AccountBehaviors {
|
||||
var behaviors: AccountBehaviors = [.disallowOPMLImports, .disallowFeedInMultipleFolders]
|
||||
var behaviors: AccountBehaviors = [.disallowFeedInMultipleFolders]
|
||||
if variant == .freshRSS {
|
||||
behaviors.append(.disallowFeedInRootFolder)
|
||||
}
|
||||
@@ -215,6 +215,8 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
||||
}
|
||||
|
||||
@MainActor func importOPML(for account: Account, opmlFile: URL) async throws {
|
||||
let opmlData = try Data(contentsOf: opmlFile)
|
||||
try await caller.importOPML(opmlData: opmlData)
|
||||
}
|
||||
|
||||
@MainActor func createFolder(for account: Account, name: String) async throws -> Folder {
|
||||
|
||||
@@ -42,6 +42,7 @@ enum CreateReaderAPISubscriptionResult {
|
||||
case subscriptionList = "/reader/api/0/subscription/list"
|
||||
case subscriptionEdit = "/reader/api/0/subscription/edit"
|
||||
case subscriptionAdd = "/reader/api/0/subscription/quickadd"
|
||||
case subscriptionImport = "/reader/api/0/subscription/import"
|
||||
case contents = "/reader/api/0/stream/items/contents"
|
||||
case itemIds = "/reader/api/0/stream/items/ids"
|
||||
case editTag = "/reader/api/0/edit-tag"
|
||||
@@ -525,6 +526,27 @@ enum CreateReaderAPISubscriptionResult {
|
||||
return try await retrieveItemIDs(type: type, url: callURL, dateInfo: dateInfo, itemIDs: totalItemIDs, continuation: entries?.continuation)
|
||||
}
|
||||
|
||||
@MainActor func importOPML(opmlData: Data) async throws {
|
||||
guard let baseURL = apiBaseURL else {
|
||||
throw CredentialsError.incompleteCredentials
|
||||
}
|
||||
|
||||
let callURL = baseURL
|
||||
.appendingPathComponent(ReaderAPIEndpoints.subscriptionImport.rawValue)
|
||||
var request = URLRequest(url: callURL, readerAPICredentials: self.credentials)
|
||||
addVariantHeaders(&request)
|
||||
request.setValue("text/xml", forHTTPHeaderField: "Content-Type")
|
||||
request.httpMethod = "POST"
|
||||
request.httpBody = opmlData
|
||||
|
||||
let (response, responseData) = try await transport.send(request: request)
|
||||
|
||||
guard response.statusCode == 200 else {
|
||||
throw AccountError.invalidResponse
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func createUnreadEntries(entries: [String]) async throws {
|
||||
|
||||
try await updateStateToEntries(entries: entries, state: .read, add: false)
|
||||
|
||||
Reference in new issue
Block a user