This commit is contained in:
Brent Simmons committed 2026-11-24 10:11:14 -08:00
commit 7c69c26cd3
54 files changed
+3695 -9

No files matched your search

@@ -57,6 +57,12 @@ final class AccountsDetailViewController: NSViewController {
accountsNewsBlurWindowController.account = account
accountsNewsBlurWindowController.runSheetOnWindow(window)
case .miniflux:
let accountsMinifluxWindowController = AccountsMinifluxWindowController()
accountsWindowController = accountsMinifluxWindowController
accountsMinifluxWindowController.account = account
accountsMinifluxWindowController.runSheetOnWindow(window)
default:
break
}
@@ -0,0 +1,304 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24506"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccountsMinifluxWindowController" customModule="NetNewsWire" customModuleProvider="target">
<connections>
<outlet property="actionButton" destination="9mz-D9-krh" id="ozu-6Q-9Lb"/>
<outlet property="apiTokenTextField" destination="Mfx-C4-fld" id="Mfx-Ot-tok"/>
<outlet property="apiURLTextField" destination="d7d-ZV-CcZ" id="Af4-uM-Dgd"/>
<outlet property="authModeControl" destination="Mfx-Sg-ctl" id="Mfx-Sg-otl"/>
<outlet property="createAccountButton" destination="kUQ-aj-Iu6" id="n9d-n0-mvN"/>
<outlet property="errorMessageLabel" destination="Gyz-Mz-v08" id="fwM-K9-xnR"/>
<outlet property="gridView" destination="zBB-JH-huI" id="ghz-ki-b0V"/>
<outlet property="noAccountTextField" destination="R8e-67-Bwh" id="7oG-ro-jcB"/>
<outlet property="passwordTextField" destination="JSa-LY-zNQ" id="E9W-0F-69m"/>
<outlet property="progressIndicator" destination="B0W-bh-Evv" id="Tiq-gx-s3F"/>
<outlet property="titleImageView" destination="Ssh-Dh-xbg" id="8Iy-jf-EYR"/>
<outlet property="titleLabel" destination="lti-yM-8LV" id="AP0-ds-6tS"/>
<outlet property="usernameTextField" destination="78p-Cf-f55" id="RWd-0q-oAL"/>
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="209" width="433" height="306"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1410"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="433" height="306"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView distribution="fill" orientation="horizontal" alignment="bottom" spacing="19" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7Ht-Fn-0Ya">
<rect key="frame" x="217" y="286" width="0.0" height="0.0"/>
</stackView>
<segmentedControl translatesAutoresizingMaskIntoConstraints="NO" id="Mfx-Sg-ctl">
<rect key="frame" x="78" y="211" width="270" height="24"/>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="Mfx-Sg-cel">
<font key="font" metaFont="system"/>
<segments>
<segment label="Username &amp; Password" width="0.0" tag="0" selected="YES"/>
<segment label="API Token" width="0.0" tag="1"/>
</segments>
</segmentedCell>
<connections>
<action selector="authModeChanged:" target="-2" id="Mfx-Sg-act"/>
</connections>
</segmentedControl>
<gridView xPlacement="trailing" yPlacement="center" rowAlignment="none" rowSpacing="7" columnSpacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="zBB-JH-huI">
<rect key="frame" x="80" y="84" width="270" height="117"/>
<rows>
<gridRow id="DRl-lC-vUc"/>
<gridRow id="eW8-uH-txq"/>
<gridRow id="ebD-On-mOK"/>
<gridRow id="Mfx-R4-tok"/>
</rows>
<columns>
<gridColumn id="fCQ-jY-Mts"/>
<gridColumn xPlacement="leading" id="7CY-bX-6x4"/>
</columns>
<gridCells>
<gridCell row="DRl-lC-vUc" column="fCQ-jY-Mts" id="xwR-xz-N6h">
<textField key="contentView" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="H6f-t4-SMg">
<rect key="frame" x="7" y="97" width="57" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="API URL:" id="zBm-dZ-EF1">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</gridCell>
<gridCell row="DRl-lC-vUc" column="7CY-bX-6x4" id="Wd5-Zp-t61">
<textField key="contentView" focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="d7d-ZV-CcZ" userLabel="API URL Text Field">
<rect key="frame" x="70" y="93" width="200" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="Mki-bb-tDu"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="https://miniflux.example.com" drawsBackground="YES" id="0OO-BG-GXI">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</gridCell>
<gridCell row="eW8-uH-txq" column="fCQ-jY-Mts" id="4DI-01-jGD">
<textField key="contentView" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Zy6-9c-8TI">
<rect key="frame" x="23" y="66" width="41" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Login:" id="DqN-SV-v35">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</gridCell>
<gridCell row="eW8-uH-txq" column="7CY-bX-6x4" id="Z0b-qS-MUJ">
<textField key="contentView" focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="78p-Cf-f55">
<rect key="frame" x="70" y="62" width="200" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="Qin-jm-4zt"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="username" drawsBackground="YES" id="fCk-Tf-q01">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</gridCell>
<gridCell row="ebD-On-mOK" column="fCQ-jY-Mts" id="Hqa-3w-cQv">
<textField key="contentView" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wEx-TM-rPM">
<rect key="frame" x="-2" y="35" width="66" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Password:" id="7g8-Kk-ISg">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</gridCell>
<gridCell row="ebD-On-mOK" column="7CY-bX-6x4" id="m16-3v-9pf">
<secureTextField key="contentView" focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JSa-LY-zNQ">
<rect key="frame" x="70" y="31" width="200" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="eal-wa-1nU"/>
</constraints>
<secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="••••••••" drawsBackground="YES" usesSingleLineMode="YES" id="trK-OG-tBe">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</secureTextFieldCell>
</secureTextField>
</gridCell>
<gridCell row="Mfx-R4-tok" column="fCQ-jY-Mts" id="Mfx-C4-lbc">
<textField key="contentView" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Mfx-C4-lbf">
<rect key="frame" x="4" y="4" width="60" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="API Token:" id="Mfx-C4-lbl">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</gridCell>
<gridCell row="Mfx-R4-tok" column="7CY-bX-6x4" id="Mfx-C4-fdc">
<secureTextField key="contentView" focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Mfx-C4-fld">
<rect key="frame" x="70" y="0.0" width="200" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="Mfx-C4-wid"/>
</constraints>
<secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" placeholderString="optional" drawsBackground="YES" usesSingleLineMode="YES" id="Mfx-C4-fcl">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</secureTextFieldCell>
</secureTextField>
</gridCell>
</gridCells>
</gridView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9mz-D9-krh">
<rect key="frame" x="354" y="20" width="62" height="24"/>
<buttonCell key="cell" type="push" title="Add" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="IMO-YT-k9Z">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
</buttonCell>
<constraints>
<constraint firstAttribute="width" constant="62" id="afy-Zh-DIy"/>
</constraints>
<connections>
<action selector="action:" target="-2" id="Kix-5a-5Og"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XAM-Hb-0Hw">
<rect key="frame" x="280" y="20" width="62" height="24"/>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="ufs-ar-BAY">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
Gw
</string>
</buttonCell>
<connections>
<action selector="cancel:" target="-2" id="WAD-ES-hpq"/>
</connections>
</button>
<progressIndicator hidden="YES" wantsLayer="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" maxValue="100" displayedWhenStopped="NO" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="B0W-bh-Evv">
<rect key="frame" x="256" y="20" width="16" height="16"/>
<constraints>
<constraint firstAttribute="width" constant="16" id="QuJ-Kk-QvB"/>
<constraint firstAttribute="height" constant="16" id="SbP-MC-kng"/>
</constraints>
</progressIndicator>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Ssh-Dh-xbg">
<rect key="frame" x="20" y="236" width="50" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="NYV-hM-AYz"/>
<constraint firstAttribute="width" constant="50" id="qWk-4n-LXb"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" id="y38-YL-woC"/>
</imageView>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lti-yM-8LV">
<rect key="frame" x="78" y="270" width="337" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Sign in to your Miniflux account." id="ras-dj-nP8">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="R8e-67-Bwh">
<rect key="frame" x="78" y="249" width="185" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Don’t have a Miniflux instance?" id="ker-hu-FEc">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="kUQ-aj-Iu6">
<rect key="frame" x="262" y="249" width="99" height="16"/>
<buttonCell key="cell" type="roundRect" title="Find out more" bezelStyle="roundedRect" alignment="center" state="on" imageScaling="proportionallyDown" inset="2" id="xY9-Rw-8kx">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
</buttonCell>
<color key="contentTintColor" name="AccentColor"/>
<constraints>
<constraint firstAttribute="height" constant="16" id="NOr-5b-kRd"/>
</constraints>
<connections>
<action selector="createAccountWithProvider:" target="-2" id="eQi-od-QJ3"/>
</connections>
</button>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="q5z-LG-0Fm">
<rect key="frame" x="78" y="61" width="337" height="39"/>
<constraints>
<constraint firstAttribute="height" constant="39" id="Zv4-mj-po0"/>
<constraint firstAttribute="width" constant="333" id="xsi-I6-XNM"/>
</constraints>
<textFieldCell key="cell" title="Your username and password will be encrypted and stored in Keychain. " id="Ec9-bB-tQz">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Gyz-Mz-v08">
<rect key="frame" x="78" y="43" width="337" height="16"/>
<textFieldCell key="cell" id="AGV-EV-VmY">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="systemRedColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="Ssh-Dh-xbg" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" symbolic="YES" id="0Fq-9s-pKG"/>
<constraint firstItem="Mfx-Sg-ctl" firstAttribute="top" secondItem="R8e-67-Bwh" secondAttribute="bottom" constant="17" id="2Ve-1M-0xg"/>
<constraint firstItem="zBB-JH-huI" firstAttribute="top" secondItem="Mfx-Sg-ctl" secondAttribute="bottom" constant="12" id="Mfx-Sg-top"/>
<constraint firstItem="Mfx-Sg-ctl" firstAttribute="leading" secondItem="R8e-67-Bwh" secondAttribute="leading" id="Mfx-Sg-led"/>
<constraint firstItem="kUQ-aj-Iu6" firstAttribute="centerY" secondItem="R8e-67-Bwh" secondAttribute="centerY" id="2hZ-w7-Lne"/>
<constraint firstItem="lti-yM-8LV" firstAttribute="leading" secondItem="Ssh-Dh-xbg" secondAttribute="trailing" constant="10" id="5a7-jI-SC9"/>
<constraint firstAttribute="bottom" secondItem="B0W-bh-Evv" secondAttribute="bottom" constant="20" symbolic="YES" id="7OS-Ie-XXN"/>
<constraint firstItem="XAM-Hb-0Hw" firstAttribute="leading" secondItem="B0W-bh-Evv" secondAttribute="trailing" constant="8" symbolic="YES" id="Ame-HX-mdC"/>
<constraint firstItem="q5z-LG-0Fm" firstAttribute="leading" secondItem="R8e-67-Bwh" secondAttribute="leading" id="B2k-oM-YfG"/>
<constraint firstItem="kUQ-aj-Iu6" firstAttribute="leading" secondItem="R8e-67-Bwh" secondAttribute="trailing" constant="1" id="BWQ-ly-Hcg"/>
<constraint firstItem="9mz-D9-krh" firstAttribute="leading" secondItem="XAM-Hb-0Hw" secondAttribute="trailing" constant="12" symbolic="YES" id="CC8-HR-FDy"/>
<constraint firstAttribute="trailing" secondItem="lti-yM-8LV" secondAttribute="trailing" constant="20" symbolic="YES" id="CeA-ET-oeg"/>
<constraint firstItem="Ssh-Dh-xbg" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" symbolic="YES" id="EKF-Yq-DxZ"/>
<constraint firstItem="q5z-LG-0Fm" firstAttribute="top" secondItem="zBB-JH-huI" secondAttribute="bottom" constant="15" id="Hdb-dd-lM9"/>
<constraint firstItem="XAM-Hb-0Hw" firstAttribute="width" secondItem="9mz-D9-krh" secondAttribute="width" id="IN4-Kx-qyK"/>
<constraint firstItem="XAM-Hb-0Hw" firstAttribute="centerY" secondItem="9mz-D9-krh" secondAttribute="centerY" id="M2M-fb-kfR"/>
<constraint firstItem="zBB-JH-huI" firstAttribute="leading" secondItem="R8e-67-Bwh" secondAttribute="leading" id="Mqa-R7-znW"/>
<constraint firstAttribute="bottom" secondItem="9mz-D9-krh" secondAttribute="bottom" constant="20" id="PK2-Ye-400"/>
<constraint firstItem="Gyz-Mz-v08" firstAttribute="top" secondItem="q5z-LG-0Fm" secondAttribute="bottom" constant="2" id="UVQ-eH-uwR"/>
<constraint firstItem="R8e-67-Bwh" firstAttribute="leading" secondItem="Ssh-Dh-xbg" secondAttribute="trailing" constant="10" id="ah8-Mj-rXV"/>
<constraint firstAttribute="trailing" secondItem="9mz-D9-krh" secondAttribute="trailing" constant="17" id="fVQ-zN-rKd"/>
<constraint firstItem="7Ht-Fn-0Ya" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" id="jlY-Jg-KJR"/>
<constraint firstItem="B0W-bh-Evv" firstAttribute="leading" secondItem="Gyz-Mz-v08" secondAttribute="trailing" constant="8" id="Mfx-Er-trl"/>
<constraint firstItem="Gyz-Mz-v08" firstAttribute="leading" secondItem="q5z-LG-0Fm" secondAttribute="leading" id="rTh-Ea-LYf"/>
<constraint firstAttribute="trailing" secondItem="q5z-LG-0Fm" secondAttribute="trailing" constant="20" id="rky-el-9AK"/>
<constraint firstItem="lti-yM-8LV" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" symbolic="YES" id="t4L-Nb-T2M"/>
<constraint firstItem="7Ht-Fn-0Ya" firstAttribute="centerX" secondItem="se5-gp-TjO" secondAttribute="centerX" id="tAZ-Te-w3H"/>
<constraint firstItem="R8e-67-Bwh" firstAttribute="top" secondItem="lti-yM-8LV" secondAttribute="bottom" constant="5" id="vL5-xO-f7d"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
</connections>
<point key="canvasLocation" x="116.5" y="149.5"/>
</window>
</objects>
<resources>
<namedColor name="AccentColor">
<color red="0.030999999493360519" green="0.41600000858306885" blue="0.93300002813339233" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>
@@ -0,0 +1,232 @@
//
// AccountsMinifluxWindowController.swift
// NetNewsWire
//
// Copyright © 2026 Ranchero Software. All rights reserved.
//
import AppKit
import Account
import RSWeb
import Secrets
final class AccountsMinifluxWindowController: NSWindowController {
@IBOutlet var titleImageView: NSImageView!
@IBOutlet var titleLabel: NSTextField!
@IBOutlet var gridView: NSGridView!
@IBOutlet var progressIndicator: NSProgressIndicator!
@IBOutlet var usernameTextField: NSTextField!
@IBOutlet var apiURLTextField: NSTextField!
@IBOutlet var passwordTextField: NSSecureTextField!
@IBOutlet var apiTokenTextField: NSSecureTextField!
@IBOutlet var authModeControl: NSSegmentedControl!
@IBOutlet var createAccountButton: NSButton!
@IBOutlet var errorMessageLabel: NSTextField!
@IBOutlet var actionButton: NSButton!
@IBOutlet var noAccountTextField: NSTextField!
var account: Account?
private weak var hostWindow: NSWindow?
/// Fixed row indices in `gridView`: API URL, Username, Password, API Token.
private let usernameRowIndex = 1
private let passwordRowIndex = 2
private let apiTokenRowIndex = 3
convenience init() {
self.init(windowNibName: NSNib.Name("AccountsMiniflux"))
}
override func windowDidLoad() {
titleImageView.image = Assets.Images.accountMiniflux
titleLabel.stringValue = NSLocalizedString("Sign in to your Miniflux account.", comment: "Miniflux")
noAccountTextField.stringValue = NSLocalizedString("Don’t have a Miniflux instance?", comment: "No Miniflux")
createAccountButton.title = NSLocalizedString("Find out more", comment: "No Miniflux Button")
apiURLTextField.placeholderString = NSLocalizedString("https://miniflux.example.com", comment: "Miniflux API Helper")
authModeControl.selectedSegment = 0
if let account {
if let tokenCredentials = try? account.retrieveCredentials(type: .minifluxAPIToken) {
apiTokenTextField.stringValue = tokenCredentials.secret
authModeControl.selectedSegment = 1
} else if let basicCredentials = try? account.retrieveCredentials(type: .minifluxBasic) {
usernameTextField.stringValue = basicCredentials.username
authModeControl.selectedSegment = 0
}
apiURLTextField.stringValue = account.endpointURL?.absoluteString ?? ""
actionButton.title = NSLocalizedString("Update", comment: "Update")
} else {
actionButton.title = NSLocalizedString("Add", comment: "Add button")
}
updateAuthModeVisibility()
enableAutofill()
apiURLTextField.becomeFirstResponder()
}
// MARK: API
func runSheetOnWindow(_ hostWindow: NSWindow, completion: ((NSApplication.ModalResponse) -> Void)? = nil) {
guard let window else {
return
}
self.hostWindow = hostWindow
hostWindow.beginSheet(window, completionHandler: completion)
}
// MARK: Actions
@IBAction func cancel(_ sender: Any) {
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.cancel)
}
@IBAction func action(_ sender: Any) {
errorMessageLabel.stringValue = ""
guard let apiURL = normalizedEndpointURL(from: apiURLTextField.stringValue) else {
errorMessageLabel.stringValue = NSLocalizedString("Invalid API URL.", comment: "Invalid API URL")
return
}
let isTokenMode = authModeControl.selectedSegment == 1
let credentials: Credentials
if isTokenMode {
let token = apiTokenTextField.stringValue.trimmingWhitespace
guard !token.isEmpty else {
errorMessageLabel.stringValue = NSLocalizedString("An API token is required.", comment: "Credentials Error")
return
}
credentials = Credentials(type: .minifluxAPIToken, username: "", secret: token)
} else {
let trimmedUsername = usernameTextField.stringValue.trimmingWhitespace
let password = passwordTextField.stringValue
guard !trimmedUsername.isEmpty, !password.isEmpty else {
errorMessageLabel.stringValue = NSLocalizedString("Username and password are required.", comment: "Credentials Error")
return
}
credentials = Credentials(type: .minifluxBasic, username: trimmedUsername, secret: password)
}
Task { @MainActor in
actionButton.isEnabled = false
progressIndicator.isHidden = false
progressIndicator.startAnimation(self)
@MainActor func stopAnimation() {
actionButton.isEnabled = true
progressIndicator.isHidden = true
progressIndicator.stopAnimation(self)
}
do {
let validatedCredentials = try await Account.validateCredentials(type: .miniflux, credentials: credentials, endpoint: apiURL)
stopAnimation()
guard let validatedCredentials else {
errorMessageLabel.stringValue = NSLocalizedString("Invalid username/password combination, or invalid API token.", comment: "Credentials Error")
return
}
guard account != nil || !AccountManager.shared.duplicateServiceAccount(type: .miniflux, endpointURL: apiURL, username: validatedCredentials.username) else {
errorMessageLabel.stringValue = NSLocalizedString("There is already a Miniflux account for this user on this server.", comment: "Duplicate Error")
return
}
if account == nil {
account = AccountManager.shared.createAccount(type: .miniflux)
}
do {
account?.endpointURL = apiURL
// Remove any credentials of the other type so a stale token or
// password doesn't take precedence after switching auth modes.
let staleCredentialsType: CredentialsType = validatedCredentials.type == .minifluxAPIToken ? .minifluxBasic : .minifluxAPIToken
try? account?.removeCredentials(type: staleCredentialsType)
try account?.storeCredentials(validatedCredentials)
hostWindow?.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
let refreshingAccount = account
Task { @MainActor in
do {
try await refreshingAccount?.refreshAll()
} catch {
NSApplication.shared.presentError(error)
}
}
} catch {
errorMessageLabel.stringValue = NSLocalizedString("Keychain error while storing credentials.", comment: "Credentials Error")
}
} catch {
stopAnimation()
errorMessageLabel.stringValue = error.localizedDescription
}
}
}
@IBAction func createAccountWithProvider(_ sender: Any) {
NSWorkspace.shared.open(URL(string: "https://miniflux.app")!)
}
@IBAction func authModeChanged(_ sender: Any) {
updateAuthModeVisibility()
}
// MARK: Autofill
func enableAutofill() {
usernameTextField.contentType = .username
passwordTextField.contentType = .password
}
// MARK: Auth Mode
private func updateAuthModeVisibility() {
let isTokenMode = authModeControl.selectedSegment == 1
gridView.row(at: usernameRowIndex).isHidden = isTokenMode
gridView.row(at: passwordRowIndex).isHidden = isTokenMode
gridView.row(at: apiTokenRowIndex).isHidden = !isTokenMode
}
// MARK: URL Normalization
/// Trims whitespace, adds a `https://` scheme if none was given, drops a
/// trailing slash, and strips a trailing `/v1` path component in case the
/// user pasted the API URL rather than the instance's base URL —
/// e.g. `https://host/v1/` becomes `https://host`.
private func normalizedEndpointURL(from string: String) -> URL? {
var trimmed = string.trimmingWhitespace
guard !trimmed.isEmpty else {
return nil
}
if !trimmed.contains("://") {
trimmed = "https://" + trimmed
}
if trimmed.hasSuffix("/") {
trimmed = String(trimmed.dropLast())
}
if trimmed.hasSuffix("/v1") {
trimmed = String(trimmed.dropLast(3))
}
if trimmed.hasSuffix("/") {
trimmed = String(trimmed.dropLast())
}
guard !trimmed.isEmpty else {
return nil
}
return URL(string: trimmed)
}
}
@@ -201,6 +201,11 @@ extension AccountsPreferencesViewController: AccountsPreferencesAddAccountDelega
let accountsNewsBlurWindowController = AccountsNewsBlurWindowController()
addAccountWindowController = accountsNewsBlurWindowController
accountsNewsBlurWindowController.runSheetOnWindow(window)
case .miniflux:
let accountsMinifluxWindowController = AccountsMinifluxWindowController()
addAccountWindowController = accountsMinifluxWindowController
accountsMinifluxWindowController.runSheetOnWindow(window)
}
}
@@ -60,7 +60,7 @@ enum AddAccountSections: Int, CaseIterable {
return [.bazQux, .feedbin, .feedly, .inoreader, .newsBlur, .theOldReader]
}
case .selfhosted:
return [.freshRSS]
return [.freshRSS, .miniflux]
case .allOrdered:
return AddAccountSections.local.sectionContent +
AddAccountSections.icloud.sectionContent +
@@ -0,0 +1,26 @@
{
"images" : [
{
"filename" : "accountMiniflux.pdf",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "accountMiniflux-dark.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "original"
}
}
@@ -230,6 +230,8 @@ import RSCore
osType = "Bzqx"
case .theOldReader:
osType = "Tord"
case .miniflux:
osType = "Mnfx"
}
return osType.fourCharCode
}
+1 -1
View File
@@ -50,7 +50,7 @@ let package = Package(
),
.testTarget(
name: "AccountTests",
dependencies: ["Account"],
dependencies: ["Account", "SyncDatabase"],
resources: [
.copy("JSON")
],
@@ -48,6 +48,7 @@ nonisolated public enum AccountType: Int, Codable, Sendable {
case inoreader = 21
case bazQux = 22
case theOldReader = 23
case miniflux = 24
public var isDeveloperRestricted: Bool {
return self == .cloudKit || self == .feedbin || self == .feedly || self == .inoreader
@@ -74,6 +75,8 @@ nonisolated public enum AccountType: Int, Codable, Sendable {
return NSLocalizedString("BazQux", comment: "Account name")
case .theOldReader:
return NSLocalizedString("The Old Reader", comment: "Account name")
case .miniflux:
return "Miniflux"
}
}
}
@@ -313,6 +316,8 @@ public enum FetchType {
self.delegate = ReaderAPIAccountDelegate(dataFolder: dataFolder, variant: .bazQux)
case .theOldReader:
self.delegate = ReaderAPIAccountDelegate(dataFolder: dataFolder, variant: .theOldReader)
case .miniflux:
self.delegate = MinifluxAccountDelegate(dataFolder: dataFolder)
}
self.accountID = accountID
@@ -411,6 +416,8 @@ public enum FetchType {
return try await NewsBlurAccountDelegate.validateCredentials(credentials: credentials, endpoint: endpoint)
case .freshRSS, .inoreader, .bazQux, .theOldReader:
return try await ReaderAPIAccountDelegate.validateCredentials(credentials: credentials, endpoint: endpoint)
case .miniflux:
return try await MinifluxAccountDelegate.validateCredentials(credentials: credentials, endpoint: endpoint)
default:
return nil
}
@@ -1038,6 +1045,22 @@ public enum FetchType {
await database.deleteAsync(articleIDs: articleIDs)
}
/// Delete the statuses for the given articleIDs. Call this only when the sync
/// service has affirmatively reported the articles as deleted server-side.
///
/// Statuses deliberately outlive their articles — they're the memory that stops
/// old articles from reappearing as unread, so no cleanup removes them early.
/// But a status whose article is gone from the service matches the
/// statuses-without-articles query on every sync, and the delegate re-requests
/// an article the service will never return. When the service says the article
/// is deleted, removing the status is correct and ends that loop.
func deleteStatuses(articleIDs: Set<String>) async {
guard !articleIDs.isEmpty else {
return
}
await database.deleteStatusesAsync(articleIDs: articleIDs)
}
/// Empty caches that can reasonably be emptied. Call when the app goes in the background, for instance.
func emptyCaches() {
database.emptyCaches()
@@ -255,6 +255,33 @@ import ActivityLog
return false
}
public func duplicateServiceAccount(type: AccountType, endpointURL: URL?, username: String?) -> Bool {
Self.duplicateServiceAccount(type: type, endpointURL: endpointURL, username: username, among: accounts)
}
/// A self-hosted server can have several users, so only the same user on the same server is a duplicate.
static func duplicateServiceAccount(type: AccountType, endpointURL: URL?, username: String?, among accounts: [Account]) -> Bool {
guard type != .onMyMac, let normalizedEndpoint = Self.normalizedEndpointForComparison(endpointURL) else {
return false
}
return accounts.contains { $0.type == type && $0.username == username && Self.normalizedEndpointForComparison($0.endpointURL) == normalizedEndpoint }
}
/// Normalizes for duplicate-server comparison: lowercases scheme/host (case-insensitive
/// per RFC 3986) and drops a trailing slash from the path, so `https://Host.example/` and
/// `https://host.example` compare equal.
static func normalizedEndpointForComparison(_ url: URL?) -> String? {
guard var components = url.flatMap({ URLComponents(url: $0, resolvingAgainstBaseURL: false) }) else {
return nil
}
components.scheme = components.scheme?.lowercased()
components.host = components.host?.lowercased()
if components.path.hasSuffix("/") {
components.path.removeLast()
}
return components.string
}
public func existingAccount(accountID: String) -> Account? {
return accountsDictionary[accountID]
}
@@ -21,6 +21,7 @@ import RSWeb
case lastArticleFetchStartTime
case lastRefreshCompletedDate
case endpointURL
case detectedServerVersion
case externalID
case imported
}
@@ -130,6 +131,17 @@ import RSWeb
}
}
/// The sync server's self-reported version string (e.g. "2.4.1"), for services whose
/// available endpoints vary by version. `nil` until the first successful detection.
var detectedServerVersion: String? {
get {
UserDefaults.standard.string(forKey: defaultsKey(.detectedServerVersion))
}
set {
UserDefaults.standard.set(newValue, forKey: defaultsKey(.detectedServerVersion))
}
}
var externalID: String? {
get {
UserDefaults.standard.string(forKey: defaultsKey(.externalID))
@@ -0,0 +1,15 @@
//
// Miniflux.swift
// Account
//
// Created by Dave Marquard on 7/7/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import Foundation
import os
struct Miniflux {
// Convention with this logger is to put "Miniflux: " at the beginning of each message.
static let logger = Logger(subsystem: Bundle.main.bundleIdentifier ?? "NetNewsWire", category: "Miniflux")
}
@@ -0,0 +1,419 @@
//
// MinifluxAPICaller.swift
// Account
//
// Created by Dave Marquard on 7/7/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import Foundation
import RSWeb
import Secrets
@MainActor final class MinifluxAPICaller {
// Miniflux rejects limit values above 1000 for /v1/entries with HTTP 400, so stay under that.
static let entriesPageSize = 500
// Miniflux caps /v1/entries/ids at MaxEntryIDsLimit (10000) per response, so page at that size.
static let entryIDsPageSize = 10000
static let statusChunkSize = 1000
private static let minimumVersion = MinifluxVersion(2, 0, 49)
// /v1/entries/ids and batch starred updates require this newer version; below it,
// MinifluxAPICaller transparently falls back to paged /v1/entries and per-entry toggles.
private static let entryIDsMinimumVersion = MinifluxVersion(2, 3, 2)
private let session = URLSession.makeWebserviceSession()
private var suspended = false
var credentials: Credentials?
var accountSettings: AccountSettings?
var server: String? {
apiBaseURL?.host
}
private var apiBaseURL: URL? {
accountSettings?.endpointURL
}
/// Cancels all pending requests and rejects any that come in later.
func suspend() {
session.cancelAll()
suspended = true
}
func resume() {
suspended = false
}
/// Validates credentials against a caller-supplied endpoint. This runs before an Account exists,
/// so it can’t rely on `accountSettings` (and thus not on `makeRequest`).
func validateCredentials(endpoint: URL) async throws -> Credentials? {
if suspended {
throw WebserviceError.suspended
}
guard let credentials else {
throw CredentialsError.missingUsername
}
let callURL = endpoint.appendingPathComponent("v1/me")
let request = URLRequest(url: callURL, credentials: credentials)
let validatedCredentials: Credentials
do {
let (_, me) = try await session.send(request: request, resultType: MinifluxUser.self)
guard let me else {
throw WebserviceError.noData
}
validatedCredentials = credentials.username.isEmpty ? Credentials(type: credentials.type, username: me.username, secret: credentials.secret) : credentials
} catch {
if case WebserviceError.httpError(let status, _) = error {
if status == HTTPResponseCode.unauthorized {
return nil
}
if status == HTTPResponseCode.notFound {
throw AccountError.urlNotFound
}
}
throw error
}
try await validateServerVersion(endpoint: endpoint)
return validatedCredentials
}
/// Re-detects the server version and persists it to account settings, so
/// `supportsEntryIDsEndpoint`/`supportsBatchStarredUpdates` pick up a server upgrade
/// without the account being recreated. Called once per `refreshAll()`, from a point
/// where `accountSettings` is guaranteed set. Best-effort: any failure just leaves the
/// previously detected version (if any) in place, and gating already treats an unknown
/// version conservatively.
func detectServerVersion() async {
guard let apiBaseURL else {
return
}
guard let response = try? await fetchVersionResponse(endpoint: apiBaseURL) else {
return
}
accountSettings?.detectedServerVersion = response.version
}
func retrieveCategories() async throws -> [MinifluxCategory] {
try await fetch("categories")
}
func createCategory(title: String) async throws -> MinifluxCategory {
var request = try makeRequest(path: "categories")
request.addValue("application/json; charset=utf-8", forHTTPHeaderField: HTTPRequestHeader.contentType)
let payload = try JSONEncoder().encode(MinifluxCategoryPayload(title: title))
let (_, category) = try await session.send(request: request, method: HTTPMethod.post, data: payload, resultType: MinifluxCategory.self)
guard let category else {
throw WebserviceError.noData
}
return category
}
func renameCategory(categoryID: Int64, title: String) async throws {
try await session.send(request: makeRequest(path: "categories/\(categoryID)"), method: HTTPMethod.put, payload: MinifluxCategoryPayload(title: title))
}
func deleteCategory(categoryID: Int64) async throws {
try await session.send(request: makeRequest(path: "categories/\(categoryID)"), method: HTTPMethod.delete)
}
func retrieveFeeds() async throws -> [MinifluxFeed] {
try await fetch("feeds")
}
/// On failure, attempts to decode a `MinifluxErrorResponse` from the response body to distinguish
/// “feed already exists” from other errors. Miniflux has no machine-readable error code for this,
/// so this is a heuristic based on the human-readable `error_message` text. Any other decodable
/// server error is surfaced as `MinifluxError.serverError` with the server's message; otherwise
/// the failure is reported as a plain HTTP error.
func createFeed(url urlString: String, categoryID: Int64) async throws -> Int64 {
var request = try makeRequest(path: "feeds")
request.addValue("application/json; charset=utf-8", forHTTPHeaderField: HTTPRequestHeader.contentType)
request.httpMethod = HTTPMethod.post
request.httpBody = try JSONEncoder().encode(MinifluxCreateFeed(feedURL: urlString, categoryID: categoryID))
let (data, urlResponse) = try await session.data(for: request)
guard (200...399).contains(urlResponse.forcedStatusCode) else {
if let errorResponse = try? JSONDecoder().decode(MinifluxErrorResponse.self, from: data) {
if errorResponse.errorMessage.contains("already exists") {
throw AccountError.createErrorAlreadySubscribed
}
throw MinifluxError.serverError(message: errorResponse.errorMessage)
}
throw WebserviceError.httpError(status: urlResponse.forcedStatusCode, responseBody: nil)
}
guard !data.isEmpty else {
throw WebserviceError.noData
}
let response = try JSONDecoder().decode(MinifluxCreateFeedResponse.self, from: data)
return response.feedID
}
func retrieveFeed(feedID: Int64) async throws -> MinifluxFeed {
try await fetch("feeds/\(feedID)")
}
func renameFeed(feedID: Int64, title: String) async throws {
try await session.send(request: makeRequest(path: "feeds/\(feedID)"), method: HTTPMethod.put, payload: MinifluxUpdateFeed(title: title, categoryID: nil))
}
func moveFeed(feedID: Int64, categoryID: Int64) async throws {
try await session.send(request: makeRequest(path: "feeds/\(feedID)"), method: HTTPMethod.put, payload: MinifluxUpdateFeed(title: nil, categoryID: categoryID))
}
func deleteFeed(feedID: Int64) async throws {
try await session.send(request: makeRequest(path: "feeds/\(feedID)"), method: HTTPMethod.delete)
}
func retrieveEntries(offset: Int, changedAfter: Date?, publishedAfter: Date?) async throws -> MinifluxEntriesResponse {
var query = Self.entriesPageQueryItems(offset: offset)
if let changedAfter {
query.append(URLQueryItem(name: "changed_after", value: String(Int(changedAfter.timeIntervalSince1970))))
}
if let publishedAfter {
query.append(URLQueryItem(name: "published_after", value: String(Int(publishedAfter.timeIntervalSince1970))))
}
return try await fetch("entries", query: query)
}
func retrieveEntries(feedID: Int64, offset: Int) async throws -> MinifluxEntriesResponse {
try await fetch("feeds/\(feedID)/entries", query: Self.entriesPageQueryItems(offset: offset))
}
/// Returns `nil` if the entry has been removed server-side.
func retrieveEntry(entryID: Int64) async throws -> MinifluxEntry? {
do {
return try await fetch("entries/\(entryID)")
} catch {
if case WebserviceError.httpError(let status, _) = error, status == HTTPResponseCode.notFound {
return nil
}
throw error
}
}
func retrieveUnreadEntryIDs() async throws -> Set<Int64> {
try await retrieveEntryIDs(matching: [URLQueryItem(name: "status", value: "unread")])
}
func retrieveStarredEntryIDs() async throws -> Set<Int64> {
try await retrieveEntryIDs(matching: [URLQueryItem(name: "starred", value: "true")])
}
func updateEntries(entryIDs: [Int64], read: Bool) async throws {
try await updateEntries(entryIDs: entryIDs, payload: MinifluxUpdateEntriesPayload(entryIDs: entryIDs, status: read ? "read" : "unread", starred: nil))
}
/// Uses the batch endpoint on servers that support it (2.3.2+), where `starred` is
/// absolute state, not a toggle. Older servers (down to the 2.0.49 floor) only expose a
/// per-entry bookmark *toggle* (`PUT /v1/entries/{id}/bookmark`), which flips state
/// rather than setting it — see `updateEntriesStarredFallback`.
func updateEntries(entryIDs: [Int64], starred: Bool) async throws {
guard !entryIDs.isEmpty else {
return
}
if supportsBatchStarredUpdates {
try await updateEntries(entryIDs: entryIDs, payload: MinifluxUpdateEntriesPayload(entryIDs: entryIDs, status: nil, starred: starred))
} else {
try await updateEntriesStarredFallback(entryIDs: entryIDs, starred: starred)
}
}
/// Synchronous — Miniflux’s OPML import doesn’t require polling for completion.
func importOPML(opmlData: Data) async throws {
var request = try makeRequest(path: "import")
request.addValue("text/xml; charset=utf-8", forHTTPHeaderField: HTTPRequestHeader.contentType)
_ = try await session.send(request: request, method: HTTPMethod.post, payload: opmlData)
}
}
// MARK: Private
private extension MinifluxAPICaller {
/// Builds an authenticated request for `v1/<path>`, honoring `suspend()`. Auth for both
/// `.minifluxBasic` and `.minifluxAPIToken` is applied inside `URLRequest(url:credentials:)`.
func makeRequest(path: String, query: [URLQueryItem] = []) throws -> URLRequest {
if suspended {
throw WebserviceError.suspended
}
return URLRequest(url: try apiURL(path: path, queryItems: query), credentials: credentials)
}
/// Sends a GET for `v1/<path>` and decodes the JSON body.
func fetch<R: Decodable & Sendable>(_ path: String, query: [URLQueryItem] = []) async throws -> R {
let (_, result) = try await session.send(request: makeRequest(path: path, query: query), resultType: R.self)
guard let result else {
throw WebserviceError.noData
}
return result
}
/// Pages through `/v1/entries/ids` on servers that support it (2.3.2+), which caps each
/// response at `entryIDsPageSize`; older servers (down to the 2.0.49 floor) fall back to
/// paging `/v1/entries` instead. `filter` is `status=unread`, `starred=true`, etc. — the
/// same filter works on both endpoints.
func retrieveEntryIDs(matching filter: [URLQueryItem]) async throws -> Set<Int64> {
guard supportsEntryIDsEndpoint else {
return try await retrieveEntryIDsByPagingEntries(matching: filter)
}
var entryIDs = Set<Int64>()
var offset = 0
while true {
let query = filter + [
URLQueryItem(name: "limit", value: String(Self.entryIDsPageSize)),
URLQueryItem(name: "offset", value: String(offset))
]
let response: MinifluxEntryIDsResponse = try await fetch("entries/ids", query: query)
entryIDs.formUnion(response.entryIDs)
offset += response.entryIDs.count
if response.entryIDs.isEmpty || offset >= response.total {
break
}
}
return entryIDs
}
/// Fallback for servers below `entryIDsMinimumVersion`, which lack `/v1/entries/ids`.
/// Used only for the initial sync's one-time reconciliation (see
/// `MinifluxAccountDelegate.reconcileAllArticleStatuses`) — never on routine refreshes —
/// so a full paginated scan here is a one-time cost, not a recurring one.
func retrieveEntryIDsByPagingEntries(matching filter: [URLQueryItem]) async throws -> Set<Int64> {
var entryIDs = Set<Int64>()
var offset = 0
while true {
let response: MinifluxEntriesResponse = try await fetch("entries", query: filter + Self.entriesPageQueryItems(offset: offset))
entryIDs.formUnion(response.entries.map { $0.entryID })
offset += response.entries.count
if response.entries.isEmpty || offset >= response.total {
break
}
}
return entryIDs
}
func updateEntries(entryIDs: [Int64], payload: MinifluxUpdateEntriesPayload) async throws {
guard !entryIDs.isEmpty else {
return
}
try await session.send(request: makeRequest(path: "entries"), method: HTTPMethod.put, payload: payload)
}
/// Fallback for servers below `entryIDsMinimumVersion`: fetches each entry's current
/// starred state and only calls the toggle when it actually differs from `starred`.
/// This is the important part — the toggle endpoint flips state, so blindly calling it
/// on an entry already in the desired state would set it *wrong*. Fetch-then-compare
/// also makes retries safe: if this throws partway through and the caller resets the
/// whole chunk for a retry, re-running re-checks each entry's now-current state and
/// skips the ones already fixed, rather than toggling them a second time.
func updateEntriesStarredFallback(entryIDs: [Int64], starred: Bool) async throws {
for entryID in entryIDs {
guard let entry = try await retrieveEntry(entryID: entryID) else {
continue // Gone server-side; nothing to update.
}
guard entry.starred != starred else {
continue // Already correct — toggling would flip it the wrong way.
}
try await toggleBookmark(entryID: entryID)
}
}
func toggleBookmark(entryID: Int64) async throws {
try await session.send(request: makeRequest(path: "entries/\(entryID)/bookmark"), method: HTTPMethod.put)
}
static func entriesPageQueryItems(offset: Int) -> [URLQueryItem] {
[
URLQueryItem(name: "order", value: "id"),
URLQueryItem(name: "direction", value: "asc"),
URLQueryItem(name: "limit", value: String(entriesPageSize)),
URLQueryItem(name: "offset", value: String(offset))
]
}
/// Requires the server response before this call to have already confirmed credentials
/// are valid — a plain 404 here means the server predates `/v1/version` (< 2.0.49).
func validateServerVersion(endpoint: URL) async throws {
let response: MinifluxVersionResponse
do {
response = try await fetchVersionResponse(endpoint: endpoint)
} catch {
if case WebserviceError.httpError(let status, _) = error, status == HTTPResponseCode.notFound {
throw MinifluxError.serverVersionTooOld(foundVersion: nil)
}
throw error
}
guard let version = MinifluxVersion(string: response.version) else {
return
}
guard version >= Self.minimumVersion else {
throw MinifluxError.serverVersionTooOld(foundVersion: response.version)
}
}
func fetchVersionResponse(endpoint: URL) async throws -> MinifluxVersionResponse {
let callURL = endpoint.appendingPathComponent("v1/version")
let request = URLRequest(url: callURL, credentials: credentials)
let (_, versionResponse) = try await session.send(request: request, resultType: MinifluxVersionResponse.self)
guard let versionResponse else {
throw WebserviceError.noData
}
return versionResponse
}
/// `nil` until a `detectServerVersion()` call has succeeded at least once this app
/// session (or in a previous one, since it's persisted).
var detectedVersion: MinifluxVersion? {
accountSettings?.detectedServerVersion.flatMap(MinifluxVersion.init(string:))
}
/// `false` (the safe default) when the version hasn't been detected yet, failed to
/// parse, or is below `entryIDsMinimumVersion` — the fallback works on every server
/// this app supports (down to the 2.0.49 floor), so "unknown" must resolve to "fall back."
var supportsEntryIDsEndpoint: Bool {
guard let detectedVersion else {
return false
}
return detectedVersion >= Self.entryIDsMinimumVersion
}
var supportsBatchStarredUpdates: Bool {
supportsEntryIDsEndpoint // Same 2.3.2 threshold as the ids endpoint.
}
func apiURL(path: String, queryItems: [URLQueryItem] = []) throws -> URL {
guard let apiBaseURL else {
throw CredentialsError.missingEndpointURL
}
let base = apiBaseURL.appendingPathComponent("v1/\(path)")
guard !queryItems.isEmpty else {
return base
}
guard let url = base.appendingQueryItems(queryItems) else {
throw WebserviceError.noURL
}
return url
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,34 @@
//
// MinifluxCategory.swift
// Account
//
// Created by Dave Marquard on 7/7/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import Foundation
// GET /v1/categories → [{"id":38,"title":"All","user_id":35,"hide_globally":false},...]
// A Miniflux category maps one-to-one to an NNW folder.
struct MinifluxCategory: Decodable, Sendable, Hashable {
let categoryID: Int64
let title: String
enum CodingKeys: String, CodingKey {
case categoryID = "id"
case title
}
static func == (lhs: MinifluxCategory, rhs: MinifluxCategory) -> Bool {
lhs.categoryID == rhs.categoryID
}
func hash(into hasher: inout Hasher) {
hasher.combine(categoryID)
}
}
// Used for both category creation and rename — Miniflux takes the same body for both.
struct MinifluxCategoryPayload: Encodable, Sendable {
let title: String
}
@@ -0,0 +1,136 @@
//
// MinifluxEntry.swift
// Account
//
// Created by Dave Marquard on 7/7/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import Foundation
import RSParser
// GET /v1/entries?limit=1 → {"total":2043,"entries":[{"id":121624,"feed_id":310,"status":"unread",
// "hash":"...","title":"...","url":"...","published_at":"2026-07-07T05:12:06Z",
// "created_at":"2026-07-07T05:13:22.668113Z","changed_at":"2026-07-07T05:13:22.668113Z",
// "content":"...","author":"...","starred":false,"reading_time":1,"enclosures":[],
// "feed":{...},"tags":[...]}]}
struct MinifluxEntry: Decodable, Sendable {
let entryID: Int64
let feedID: Int64
let title: String?
let url: String?
let author: String?
let contentHTML: String?
let datePublished: String?
let enclosures: [MinifluxEnclosure]?
let status: String?
let starred: Bool?
// Miniflux emits ISO8601 dates with fractional seconds and offsets, which JSONDecoder’s
// .iso8601 strategy can’t parse. Rather than lose the whole entry, decode the date as a
// String and let DateParser take care of it — exactly like FeedbinEntry.parsedDatePublished.
var parsedDatePublished: Date? {
datePublished.flatMap { DateParser.date(from: $0) }
}
var attachments: [ParsedAttachment]? {
let attachments = enclosures?.compactMap { $0.parsedAttachment } ?? []
return attachments.isEmpty ? nil : attachments
}
var imageURL: String? {
enclosures?.first { $0.isImage }?.url
}
enum CodingKeys: String, CodingKey {
case entryID = "id"
case feedID = "feed_id"
case title
case url
case author
case contentHTML = "content"
case datePublished = "published_at"
case enclosures
case status
case starred
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
entryID = try container.decode(Int64.self, forKey: .entryID)
feedID = try container.decode(Int64.self, forKey: .feedID)
title = try? container.decode(String.self, forKey: .title)
url = try? container.decode(String.self, forKey: .url)
author = try? container.decode(String.self, forKey: .author)
contentHTML = try? container.decode(String.self, forKey: .contentHTML)
datePublished = try? container.decode(String.self, forKey: .datePublished)
enclosures = try? container.decode([MinifluxEnclosure].self, forKey: .enclosures)
status = try? container.decode(String.self, forKey: .status)
starred = try? container.decode(Bool.self, forKey: .starred)
}
}
struct MinifluxEnclosure: Decodable, Sendable {
let url: String?
let mimeType: String?
let size: Int?
var parsedAttachment: ParsedAttachment? {
guard let url else {
return nil
}
return ParsedAttachment(url: url, mimeType: mimeType, title: nil, sizeInBytes: sizeInBytes, durationInSeconds: nil, width: nil, height: nil, medium: nil)
}
var isImage: Bool {
mimeType?.lowercased().hasPrefix("image/") == true
}
private var sizeInBytes: Int? {
guard let size, size > 0 else {
return nil
}
return size
}
enum CodingKeys: String, CodingKey {
case url
case mimeType = "mime_type"
case size
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
url = try? container.decodeIfPresent(String.self, forKey: .url)
mimeType = try? container.decodeIfPresent(String.self, forKey: .mimeType)
size = try? container.decodeIfPresent(Int.self, forKey: .size)
}
}
struct MinifluxEntriesResponse: Decodable, Sendable {
let total: Int
let entries: [MinifluxEntry]
}
// GET /v1/entries/ids?status=unread → {"total":1960,"entry_ids":[121634,121624,...]}
struct MinifluxEntryIDsResponse: Decodable, Sendable {
let total: Int
let entryIDs: [Int64]
enum CodingKeys: String, CodingKey {
case total = "total"
case entryIDs = "entry_ids"
}
}
struct MinifluxUpdateEntriesPayload: Encodable, Sendable {
let entryIDs: [Int64]
let status: String?
let starred: Bool?
enum CodingKeys: String, CodingKey {
case entryIDs = "entry_ids"
case status
case starred
}
}
@@ -0,0 +1,38 @@
//
// MinifluxError.swift
// Account
//
// Created by Dave Marquard on 7/7/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import Foundation
// Miniflux error responses look like: {"error_message": "This feed already exists (feed_id: 123)"}
struct MinifluxErrorResponse: Decodable, Sendable {
let errorMessage: String
enum CodingKeys: String, CodingKey {
case errorMessage = "error_message"
}
}
enum MinifluxError: LocalizedError {
case serverVersionTooOld(foundVersion: String?)
case serverError(message: String)
var errorDescription: String? {
switch self {
case .serverVersionTooOld(let foundVersion):
guard let foundVersion else {
return NSLocalizedString("NetNewsWire requires Miniflux 2.0.49 or later.", comment: "Server version too old")
}
let localizedText = NSLocalizedString("This Miniflux server is version %@, but NetNewsWire requires Miniflux 2.0.49 or later.", comment: "Server version too old")
return NSString.localizedStringWithFormat(localizedText as NSString, foundVersion) as String
case .serverError(let message):
let localizedText = NSLocalizedString("The Miniflux server reported an error: %@", comment: "Server error")
return NSString.localizedStringWithFormat(localizedText as NSString, message) as String
}
}
}
@@ -0,0 +1,72 @@
//
// MinifluxFeed.swift
// Account
//
// Created by Dave Marquard on 7/7/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import Foundation
// GET /v1/feeds → [{"id":311,"feed_url":"...","site_url":"...","title":"...",
// "category":{"id":39,...},"icon":{"feed_id":311,...},...}]
struct MinifluxFeed: Decodable, Sendable {
let feedID: Int64
let feedURL: String
let siteURL: String?
let title: String?
let category: MinifluxCategory?
enum CodingKeys: String, CodingKey {
case feedID = "id"
case feedURL = "feed_url"
case siteURL = "site_url"
case title
case category
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
feedID = try container.decode(Int64.self, forKey: .feedID)
feedURL = try container.decode(String.self, forKey: .feedURL)
siteURL = try? container.decode(String.self, forKey: .siteURL)
title = try? container.decode(String.self, forKey: .title)
// Decoded leniently: older servers, or feeds mid-import, may omit or malform this.
category = try? container.decode(MinifluxCategory.self, forKey: .category)
}
}
struct MinifluxCreateFeed: Encodable, Sendable {
let feedURL: String
let categoryID: Int64
enum CodingKeys: String, CodingKey {
case feedURL = "feed_url"
case categoryID = "category_id"
}
}
struct MinifluxCreateFeedResponse: Decodable, Sendable {
let feedID: Int64
enum CodingKeys: String, CodingKey {
case feedID = "feed_id"
}
}
// Only non-nil properties are encoded, so callers can send a title-only or category-only update.
struct MinifluxUpdateFeed: Encodable, Sendable {
let title: String?
let categoryID: Int64?
enum CodingKeys: String, CodingKey {
case title
case categoryID = "category_id"
}
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(title, forKey: .title)
try container.encodeIfPresent(categoryID, forKey: .categoryID)
}
}
@@ -0,0 +1,15 @@
//
// MinifluxUser.swift
// Account
//
// Created by Dave Marquard on 7/7/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import Foundation
// GET /v1/me → {"id":35,"username":"claude","is_admin":false,...}
struct MinifluxUser: Decodable, Sendable {
let id: Int64
let username: String
}
@@ -0,0 +1,63 @@
//
// MinifluxVersion.swift
// Account
//
// Created by Dave Marquard on 7/8/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import Foundation
// GET /v1/version → {"version":"2.3.2","commit":"...","build_date":"...",...}
struct MinifluxVersionResponse: Decodable, Sendable {
let version: String
}
/// A dotted numeric version, e.g. "2.3.2". Tolerates a non-numeric suffix on the last
/// component, e.g. "2.3.2-dev", but fails to parse a wholly non-numeric component.
struct MinifluxVersion: Comparable, Sendable {
private let components: [Int]
init(_ components: Int...) {
self.components = components
}
init?(string: String) {
let parts = string.split(separator: ".")
guard !parts.isEmpty else {
return nil
}
var parsedComponents = [Int]()
for part in parts {
let digits = part.prefix { $0.isNumber }
guard let value = Int(digits) else {
return nil
}
parsedComponents.append(value)
}
components = parsedComponents
}
static func == (lhs: MinifluxVersion, rhs: MinifluxVersion) -> Bool {
lhs.compare(rhs) == .orderedSame
}
static func < (lhs: MinifluxVersion, rhs: MinifluxVersion) -> Bool {
lhs.compare(rhs) == .orderedAscending
}
private func compare(_ other: MinifluxVersion) -> ComparisonResult {
let count = max(components.count, other.components.count)
for i in 0..<count {
let lhsValue = i < components.count ? components[i] : 0
let rhsValue = i < other.components.count ? other.components[i] : 0
if lhsValue != rhsValue {
return lhsValue < rhsValue ? .orderedAscending : .orderedDescending
}
}
return .orderedSame
}
}
@@ -50,6 +50,13 @@ public extension URLRequest {
case .readerAPIKey:
let auth = "GoogleLogin auth=\(credentials.secret)"
setValue(auth, forHTTPHeaderField: HTTPRequestHeader.authorization)
case .minifluxBasic:
let data = Data("\(credentials.username):\(credentials.secret)".utf8)
let base64 = data.base64EncodedString()
let auth = "Basic \(base64)"
setValue(auth, forHTTPHeaderField: HTTPRequestHeader.authorization)
case .minifluxAPIToken:
setValue(credentials.secret, forHTTPHeaderField: "X-Auth-Token")
case .oauthAccessToken:
let auth = "OAuth \(credentials.secret)"
setValue(auth, forHTTPHeaderField: "Authorization")
@@ -0,0 +1,54 @@
//
// AccountManagerDuplicateEndpointTests.swift
// AccountTests
//
// Created by Dave Marquard on 7/15/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import XCTest
@testable import Account
@MainActor final class AccountManagerDuplicateEndpointTests: XCTestCase {
func testCaseInsensitiveHostMatches() {
let a = AccountManager.normalizedEndpointForComparison(URL(string: "https://Miniflux.Example.com"))
let b = AccountManager.normalizedEndpointForComparison(URL(string: "https://miniflux.example.com"))
XCTAssertEqual(a, b)
}
func testTrailingSlashIsIgnored() {
let a = AccountManager.normalizedEndpointForComparison(URL(string: "https://miniflux.example.com/"))
let b = AccountManager.normalizedEndpointForComparison(URL(string: "https://miniflux.example.com"))
XCTAssertEqual(a, b)
}
func testDifferentPathsDoNotMatch() {
let a = AccountManager.normalizedEndpointForComparison(URL(string: "https://example.com/miniflux"))
let b = AccountManager.normalizedEndpointForComparison(URL(string: "https://example.com/other"))
XCTAssertNotEqual(a, b)
}
func testNilURLNormalizesToNil() {
XCTAssertNil(AccountManager.normalizedEndpointForComparison(nil))
}
func testSameUsernameOnDifferentServersIsAllowed() {
let existingAccount = TestAccountManager.shared.createAccount(type: .miniflux)
defer { TestAccountManager.shared.deleteAccount(existingAccount) }
existingAccount.username = "admin"
existingAccount.endpointURL = URL(string: "https://first.miniflux.test")
XCTAssertFalse(AccountManager.duplicateServiceAccount(type: .miniflux, endpointURL: URL(string: "https://second.miniflux.test"), username: "admin", among: [existingAccount]))
XCTAssertTrue(AccountManager.duplicateServiceAccount(type: .miniflux, endpointURL: URL(string: "https://first.miniflux.test"), username: "admin", among: [existingAccount]))
}
func testDifferentUsernamesOnSameServerAreAllowed() {
let existingAccount = TestAccountManager.shared.createAccount(type: .miniflux)
defer { TestAccountManager.shared.deleteAccount(existingAccount) }
existingAccount.username = "admin"
existingAccount.endpointURL = URL(string: "https://first.miniflux.test")
XCTAssertFalse(AccountManager.duplicateServiceAccount(type: .miniflux, endpointURL: URL(string: "https://first.miniflux.test"), username: "claude", among: [existingAccount]))
}
}
@@ -0,0 +1,26 @@
[
{
"id": 1,
"title": "All",
"user_id": 35,
"hide_globally": false
},
{
"id": 2,
"title": "Tech",
"user_id": 35,
"hide_globally": false
},
{
"id": 3,
"title": "News",
"user_id": 35,
"hide_globally": false
},
{
"id": 4,
"title": "Reviews",
"user_id": 35,
"hide_globally": false
}
]
@@ -0,0 +1,14 @@
[
{
"id": 1,
"title": "All",
"user_id": 35,
"hide_globally": false
},
{
"id": 2,
"title": "Tech",
"user_id": 35,
"hide_globally": false
}
]
@@ -0,0 +1,20 @@
[
{
"id": 1,
"title": "All",
"user_id": 35,
"hide_globally": false
},
{
"id": 2,
"title": "Tech",
"user_id": 35,
"hide_globally": false
},
{
"id": 3,
"title": "News",
"user_id": 35,
"hide_globally": false
}
]
@@ -0,0 +1,93 @@
{
"total": 5,
"entries": [
{
"id": 5001,
"feed_id": 101,
"status": "unread",
"hash": "hash5001",
"title": "Unread and starred entry",
"url": "https://general.example/posts/1",
"published_at": "2026-07-07T05:12:06.668113Z",
"created_at": "2026-07-07T05:13:22.668113Z",
"changed_at": "2026-07-07T05:13:22.668113Z",
"content": "<p>Body of the unread starred entry.</p>",
"author": "Jane Doe",
"starred": true,
"reading_time": 2,
"feed_id_str": "101"
},
{
"id": 5002,
"feed_id": 102,
"status": "read",
"hash": "hash5002",
"title": "Read entry",
"url": "https://tech-a.example/posts/2",
"published_at": "2026-07-06T09:00:00Z",
"created_at": "2026-07-06T09:05:00Z",
"changed_at": "2026-07-06T09:05:00Z",
"content": "<p>Body of the read entry.</p>",
"author": "John Smith",
"starred": false,
"reading_time": 4
},
{
"id": 5003,
"feed_id": 103,
"status": "unread",
"hash": "hash5003",
"title": "Entry with no author",
"url": "https://tech-b.example/posts/3",
"published_at": "2026-07-05T12:30:00Z",
"created_at": "2026-07-05T12:31:00Z",
"changed_at": "2026-07-05T12:31:00Z",
"content": "<p>Body of the entry with no author.</p>",
"starred": false,
"reading_time": 1
},
{
"id": 5004,
"feed_id": 104,
"status": "unread",
"hash": "hash5004",
"title": "Entry with empty enclosures",
"url": "https://news-a.example/posts/4",
"published_at": "2026-07-04T08:15:00Z",
"created_at": "2026-07-04T08:16:00Z",
"changed_at": "2026-07-04T08:16:00Z",
"content": "<p>Body of the entry with empty enclosures.</p>",
"author": "News Desk",
"starred": false,
"reading_time": 3,
"enclosures": []
},
{
"id": 5005,
"feed_id": 105,
"status": "read",
"hash": "hash5005",
"title": "Entry with an enclosure",
"url": "https://general-b.example/posts/5",
"published_at": "2026-07-03T18:45:00Z",
"created_at": "2026-07-03T18:46:00Z",
"changed_at": "2026-07-03T18:46:00Z",
"content": "<p>Body of the entry with an enclosure.</p>",
"author": "Jane Doe",
"starred": false,
"reading_time": 5,
"enclosures": [
{
"url": "https://media.example/ep1.mp3",
"mime_type": "audio/mpeg",
"size": 1234567
},
{
"url": "https://media.example/ep1.jpg",
"mime_type": "image/jpeg",
"size": 0
}
]
}
]
}
@@ -0,0 +1,15 @@
{
"id": 5001,
"feed_id": 101,
"status": "unread",
"hash": "hash5001",
"title": "Unread and starred entry",
"url": "https://general.example/posts/1",
"published_at": "2026-07-07T05:12:06.668113Z",
"created_at": "2026-07-07T05:13:22.668113Z",
"changed_at": "2026-07-07T05:13:22.668113Z",
"content": "<p>Body of the unread starred entry.</p>",
"author": "Jane Doe",
"starred": true,
"reading_time": 2
}
@@ -0,0 +1,15 @@
{
"id": 5002,
"feed_id": 102,
"status": "read",
"hash": "hash5002",
"title": "Read entry",
"url": "https://tech-a.example/posts/2",
"published_at": "2026-07-06T09:00:00Z",
"created_at": "2026-07-06T09:05:00Z",
"changed_at": "2026-07-06T09:05:00Z",
"content": "<p>Body of the read entry.</p>",
"author": "John Smith",
"starred": false,
"reading_time": 4
}
@@ -0,0 +1,4 @@
{
"total": 3,
"entry_ids": [5001, 5003, 5004]
}
@@ -0,0 +1,87 @@
[
{
"id": 101,
"feed_url": "https://miniflux.test/feeds/general.xml",
"site_url": "https://general.example",
"title": "General Feed",
"checked_at": "2026-07-07T05:00:00Z",
"category": {
"id": 1,
"title": "All",
"user_id": 35,
"hide_globally": false
},
"icon": {
"feed_id": 101,
"icon_id": 201,
"external_icon_id": "abc101"
}
},
{
"id": 102,
"feed_url": "https://tech-a.example/rss.xml",
"site_url": "https://tech-a.example",
"title": "Tech Feed A",
"checked_at": "2026-07-07T05:00:00Z",
"category": {
"id": 2,
"title": "Tech",
"user_id": 35,
"hide_globally": false
},
"icon": {
"feed_id": 102,
"icon_id": 202,
"external_icon_id": "abc102"
}
},
{
"id": 103,
"feed_url": "https://tech-b.example/feed",
"site_url": "https://tech-b.example",
"title": "Tech Feed B",
"checked_at": "2026-07-07T05:00:00Z",
"category": {
"id": 2,
"title": "Tech",
"user_id": 35,
"hide_globally": false
},
"icon": {
"feed_id": 103,
"icon_id": 203,
"external_icon_id": "abc103"
}
},
{
"id": 104,
"feed_url": "https://news-a.example/atom.xml",
"site_url": "https://news-a.example",
"title": "News Feed A",
"checked_at": "2026-07-07T05:00:00Z",
"category": {
"id": 3,
"title": "News",
"user_id": 35,
"hide_globally": false
},
"icon": {
"feed_id": 104,
"icon_id": 204,
"external_icon_id": "abc104"
}
},
{
"id": 105,
"feed_url": "https://general-b.example/feed.json",
"site_url": "https://general-b.example",
"title": "General Feed B",
"checked_at": "2026-07-07T05:00:00Z",
"category": {
"id": 1,
"title": "All",
"user_id": 35,
"hide_globally": false
}
}
]
@@ -0,0 +1,8 @@
{
"id": 35,
"username": "testuser",
"is_admin": false,
"theme": "light_serif",
"language": "en_US",
"timezone": "UTC"
}
@@ -0,0 +1,9 @@
{
"version": "2.3.2",
"commit": "abc1234",
"build_date": "2026-06-01T00:00:00Z",
"go_version": "go1.24.0",
"compiler": "gc",
"arch": "arm64",
"os": "linux"
}
@@ -0,0 +1,9 @@
{
"version": "2.1.0",
"commit": "def5678",
"build_date": "2026-01-01T00:00:00Z",
"go_version": "go1.23.0",
"compiler": "gc",
"arch": "amd64",
"os": "linux"
}
@@ -0,0 +1,162 @@
//
// AccountMinifluxFolderSyncTest.swift
// AccountTests
//
// Created by Dave Marquard on 7/7/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import XCTest
import RSWeb
@testable import Account
@MainActor final class AccountMinifluxFolderSyncTest: XCTestCase {
override func setUp() {
TestingURLProtocol.reset()
}
func testDownloadSync() async throws {
TestingURLProtocol.setResponse("/v1/version", file: "JSON/miniflux_version.json")
TestingURLProtocol.setResponse("/v1/categories", file: "JSON/miniflux_categories_initial.json")
TestingURLProtocol.setResponse("/v1/feeds", file: "JSON/miniflux_feeds_initial.json")
TestingURLProtocol.setResponse("/v1/entries/ids", file: "JSON/miniflux_entry_ids.json")
TestingURLProtocol.setResponse("/v1/entries?", file: "JSON/miniflux_entries_page1.json")
let account = TestAccountManager.shared.createAccount(type: .miniflux)
account.endpointURL = URL(string: "https://miniflux.test")
// Test initial folders
try await account.refreshAll()
guard let initialFolders = account.folders else {
XCTFail()
return
}
XCTAssertEqual(3, initialFolders.count)
guard let all = initialFolders.first(where: { $0.name == "All" }) else {
XCTFail("Expected an “All” folder")
return
}
XCTAssertEqual("1", all.externalID)
guard let tech = initialFolders.first(where: { $0.name == "Tech" }) else {
XCTFail("Expected a “Tech” folder")
return
}
XCTAssertEqual("2", tech.externalID)
guard let news = initialFolders.first(where: { $0.name == "News" }) else {
XCTFail("Expected a “News” folder")
return
}
XCTAssertEqual("3", news.externalID)
// Test removing a folder
TestingURLProtocol.setResponse("/v1/categories", file: "JSON/miniflux_categories_delete.json")
try await account.refreshAll()
guard let deleteFolders = account.folders else {
XCTFail()
return
}
XCTAssertEqual(2, deleteFolders.count)
let deleteFolderNames = deleteFolders.map { $0.name ?? "" }
XCTAssertTrue(deleteFolderNames.contains("All"))
XCTAssertTrue(deleteFolderNames.contains("Tech"))
XCTAssertFalse(deleteFolderNames.contains("News"))
// Test adding a folder
TestingURLProtocol.setResponse("/v1/categories", file: "JSON/miniflux_categories_add.json")
try await account.refreshAll()
guard let addFolders = account.folders else {
XCTFail()
return
}
XCTAssertEqual(4, addFolders.count)
let addFolderNames = addFolders.map { $0.name ?? "" }
XCTAssertTrue(addFolderNames.contains("News"))
XCTAssertTrue(addFolderNames.contains("Reviews"))
guard let reviews = addFolders.first(where: { $0.name == "Reviews" }) else {
XCTFail("Expected a “Reviews” folder")
return
}
XCTAssertEqual("4", reviews.externalID)
TestAccountManager.shared.deleteAccount(account)
}
func testFeedsLandInCorrectFolders() async throws {
TestingURLProtocol.setResponse("/v1/version", file: "JSON/miniflux_version.json")
TestingURLProtocol.setResponse("/v1/categories", file: "JSON/miniflux_categories_initial.json")
TestingURLProtocol.setResponse("/v1/feeds", file: "JSON/miniflux_feeds_initial.json")
TestingURLProtocol.setResponse("/v1/entries/ids", file: "JSON/miniflux_entry_ids.json")
TestingURLProtocol.setResponse("/v1/entries?", file: "JSON/miniflux_entries_page1.json")
let account = TestAccountManager.shared.createAccount(type: .miniflux)
account.endpointURL = URL(string: "https://miniflux.test")
try await account.refreshAll()
guard let folders = account.folders else {
XCTFail()
return
}
XCTAssertEqual(3, folders.count)
guard let all = folders.first(where: { $0.name == "All" }) else {
XCTFail("Expected an “All” folder")
return
}
guard let tech = folders.first(where: { $0.name == "Tech" }) else {
XCTFail("Expected a “Tech” folder")
return
}
guard let news = folders.first(where: { $0.name == "News" }) else {
XCTFail("Expected a “News” folder")
return
}
// Feeds 101 and 105 belong to category 1 (“All”).
XCTAssertEqual(2, all.topLevelFeeds.count)
let allFeedExternalIDs = Set(all.topLevelFeeds.map { $0.externalID })
XCTAssertEqual(Set(["101", "105"]), allFeedExternalIDs)
// Feeds 102 and 103 belong to category 2 (“Tech”).
XCTAssertEqual(2, tech.topLevelFeeds.count)
let techFeedExternalIDs = Set(tech.topLevelFeeds.map { $0.externalID })
XCTAssertEqual(Set(["102", "103"]), techFeedExternalIDs)
// Feed 104 belongs to category 3 (“News”).
XCTAssertEqual(1, news.topLevelFeeds.count)
let newsFeedExternalIDs = Set(news.topLevelFeeds.map { $0.externalID })
XCTAssertEqual(Set(["104"]), newsFeedExternalIDs)
// Miniflux feeds always belong to exactly one category, so nothing should land
// at the account's top level.
XCTAssertEqual(0, account.topLevelFeeds.count)
guard let generalFeed = all.topLevelFeeds.first(where: { $0.externalID == "101" }) else {
XCTFail("Expected feed 101 in the “All” folder")
return
}
XCTAssertEqual("https://miniflux.test/feeds/general.xml", generalFeed.url)
XCTAssertEqual("General Feed", generalFeed.name)
TestAccountManager.shared.deleteAccount(account)
}
}
@@ -0,0 +1,157 @@
//
// MinifluxModelDecodingTests.swift
// AccountTests
//
// Created by Dave Marquard on 7/7/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import XCTest
@testable import Account
@MainActor final class MinifluxModelDecodingTests: XCTestCase {
func testDecodeUser() throws {
let user = try decode(MinifluxUser.self, from: "miniflux_me.json")
XCTAssertEqual(35, user.id)
XCTAssertEqual("testuser", user.username)
}
func testDecodeCategories() throws {
let categories = try decode([MinifluxCategory].self, from: "miniflux_categories_initial.json")
XCTAssertEqual(3, categories.count)
guard let all = categories.first(where: { $0.title == "All" }) else {
XCTFail("Expected an “All” category")
return
}
XCTAssertEqual(1, all.categoryID)
guard let tech = categories.first(where: { $0.title == "Tech" }) else {
XCTFail("Expected a “Tech” category")
return
}
XCTAssertEqual(2, tech.categoryID)
guard let news = categories.first(where: { $0.title == "News" }) else {
XCTFail("Expected a “News” category")
return
}
XCTAssertEqual(3, news.categoryID)
}
func testDecodeCategoriesAfterDelete() throws {
let categories = try decode([MinifluxCategory].self, from: "miniflux_categories_delete.json")
XCTAssertEqual(2, categories.count)
XCTAssertFalse(categories.contains { $0.title == "News" })
}
func testDecodeFeeds() throws {
let feeds = try decode([MinifluxFeed].self, from: "miniflux_feeds_initial.json")
XCTAssertEqual(5, feeds.count)
guard let feed = feeds.first(where: { $0.feedID == 101 }) else {
XCTFail("Expected feed 101")
return
}
XCTAssertEqual("https://miniflux.test/feeds/general.xml", feed.feedURL)
XCTAssertEqual("https://general.example", feed.siteURL)
XCTAssertEqual("General Feed", feed.title)
XCTAssertEqual(1, feed.category?.categoryID)
XCTAssertEqual("All", feed.category?.title)
// Feed 105 has no "icon" key at all — confirms lenient decoding tolerates its absence.
guard let feedWithoutIcon = feeds.first(where: { $0.feedID == 105 }) else {
XCTFail("Expected feed 105")
return
}
XCTAssertEqual(1, feedWithoutIcon.category?.categoryID)
let categoryIDs = Set(feeds.compactMap { $0.category?.categoryID })
XCTAssertEqual(Set([1, 2, 3]), categoryIDs)
}
func testDecodeEntriesResponse() throws {
let response = try decode(MinifluxEntriesResponse.self, from: "miniflux_entries_page1.json")
XCTAssertEqual(5, response.total)
XCTAssertEqual(5, response.entries.count)
guard let unreadStarred = response.entries.first(where: { $0.entryID == 5001 }) else {
XCTFail("Expected entry 5001")
return
}
XCTAssertEqual(101, unreadStarred.feedID)
XCTAssertEqual("Jane Doe", unreadStarred.author)
XCTAssertEqual("unread", unreadStarred.status)
XCTAssertEqual(true, unreadStarred.starred)
// published_at has fractional seconds — confirms DateParser (not JSONDecoder's
// .iso8601 strategy) is what's doing the parsing.
XCTAssertNotNil(unreadStarred.parsedDatePublished)
guard let readEntry = response.entries.first(where: { $0.entryID == 5002 }) else {
XCTFail("Expected entry 5002")
return
}
XCTAssertEqual("read", readEntry.status)
XCTAssertEqual(false, readEntry.starred)
guard let missingAuthor = response.entries.first(where: { $0.entryID == 5003 }) else {
XCTFail("Expected entry 5003")
return
}
XCTAssertNil(missingAuthor.author)
guard let emptyEnclosures = response.entries.first(where: { $0.entryID == 5004 }) else {
XCTFail("Expected entry 5004")
return
}
XCTAssertNotNil(emptyEnclosures.enclosures)
XCTAssertEqual(0, emptyEnclosures.enclosures?.count ?? -1)
XCTAssertNil(emptyEnclosures.attachments)
guard let withEnclosure = response.entries.first(where: { $0.entryID == 5005 }) else {
XCTFail("Expected entry 5005")
return
}
guard let enclosure = withEnclosure.enclosures?.first else {
XCTFail("Expected an enclosure on entry 5005")
return
}
XCTAssertEqual("https://media.example/ep1.mp3", enclosure.url)
XCTAssertEqual("audio/mpeg", enclosure.mimeType)
let attachments = withEnclosure.attachments ?? []
XCTAssertEqual(["https://media.example/ep1.mp3", "https://media.example/ep1.jpg"], attachments.map(\.url))
XCTAssertEqual(1234567, attachments.first?.sizeInBytes)
XCTAssertNil(attachments.last?.sizeInBytes)
XCTAssertEqual("https://media.example/ep1.jpg", withEnclosure.imageURL)
}
func testDecodeEntryIDsResponse() throws {
let response = try decode(MinifluxEntryIDsResponse.self, from: "miniflux_entry_ids.json")
XCTAssertEqual(3, response.total)
XCTAssertEqual([5001, 5003, 5004], response.entryIDs)
}
func testDecodeErrorResponse() throws {
let json = Data(#"{"error_message": "This feed already exists (feed_id: 123)"}"#.utf8)
let error = try JSONDecoder().decode(MinifluxErrorResponse.self, from: json)
XCTAssertEqual("This feed already exists (feed_id: 123)", error.errorMessage)
}
func testDecodeVersionResponse() throws {
let response = try decode(MinifluxVersionResponse.self, from: "miniflux_version.json")
XCTAssertEqual("2.3.2", response.version)
}
}
// MARK: - Fixture loading
private extension MinifluxModelDecodingTests {
func decode<T: Decodable>(_ type: T.Type, from fileName: String) throws -> T {
let fileURL = Bundle.module.resourceURL!.appendingPathComponent("JSON/\(fileName)")
let data = try Data(contentsOf: fileURL)
return try JSONDecoder().decode(T.self, from: data)
}
}
@@ -0,0 +1,38 @@
//
// MinifluxStarredFallbackTests.swift
// AccountTests
//
// Created by Dave Marquard on 7/15/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import XCTest
import RSWeb
import Secrets
@testable import Account
@MainActor final class MinifluxStarredFallbackTests: XCTestCase {
override func setUp() {
TestingURLProtocol.reset()
}
func testFallbackOnlyTogglesEntriesWhoseStateDiffers() async throws {
let accountSettings = AccountSettings(accountID: UUID().uuidString, dataFolder: NSTemporaryDirectory())
accountSettings.endpointURL = URL(string: "https://miniflux.test")
accountSettings.detectedServerVersion = "2.1.0" // Below entryIDsMinimumVersion.
let caller = MinifluxAPICaller()
caller.credentials = Credentials(type: .minifluxAPIToken, username: "", secret: "token")
caller.accountSettings = accountSettings
// 5001 is already starred; 5002 is not.
TestingURLProtocol.setResponse("/v1/entries/5001", file: "JSON/miniflux_entry_5001_starred.json")
TestingURLProtocol.setResponse("/v1/entries/5002", file: "JSON/miniflux_entry_5002_unstarred.json")
try await caller.updateEntries(entryIDs: [5001, 5002], starred: true)
XCTAssertEqual(TestingURLProtocol.requestCount(forURLContaining: "/entries/5001/bookmark"), 0)
XCTAssertGreaterThan(TestingURLProtocol.requestCount(forURLContaining: "/entries/5002/bookmark"), 0)
}
}
@@ -0,0 +1,89 @@
//
// MinifluxSyncRegressionTests.swift
// AccountTests
//
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import XCTest
import RSWeb
import SyncDatabase
@testable import Account
@MainActor final class MinifluxSyncRegressionTests: XCTestCase {
override func setUp() {
TestingURLProtocol.reset()
}
func testFailedStarredSendKeepsItsQueuedStatusAfterReadSendSucceeds() async throws {
let account = TestAccountManager.shared.createAccount(type: .miniflux)
defer { TestAccountManager.shared.deleteAccount(account) }
account.endpointURL = URL(string: "https://miniflux.test")
(account.delegate as! MinifluxAccountDelegate).accountSettings?.detectedServerVersion = "2.1.0"
let databasePath = (account.dataFolder as NSString).appendingPathComponent("Sync.sqlite3")
let database = SyncDatabase(databasePath: databasePath)
await database.insertStatuses([
SyncStatus(articleID: "5001", key: .read, flag: true),
SyncStatus(articleID: "5001", key: .starred, flag: true)
])
TestingURLProtocol.setResponse(.init(statusCode: 204), forURLContaining: "/v1/entries", httpMethod: "PUT")
TestingURLProtocol.setResponse(.init(statusCode: 500), forURLContaining: "/v1/entries/5001", httpMethod: "GET")
do {
try await account.sendArticleStatus()
XCTFail("Expected the starred update to fail")
} catch {
let pendingRead = try await database.selectPendingReadStatusArticleIDs()
let pendingStarred = try await database.selectPendingStarredStatusArticleIDs()
XCTAssertEqual(pendingRead, [])
XCTAssertEqual(pendingStarred, ["5001"])
}
}
func testFailedInitialReconciliationIsRetried() async throws {
TestingURLProtocol.setResponse("/v1/version", file: "JSON/miniflux_version.json")
TestingURLProtocol.setResponse("/v1/categories", file: "JSON/miniflux_categories_initial.json")
TestingURLProtocol.setResponse("/v1/feeds", file: "JSON/miniflux_feeds_initial.json")
TestingURLProtocol.setResponse("/v1/entries?", file: "JSON/miniflux_entries_page1.json")
TestingURLProtocol.setResponse(.init(statusCode: 500), forURLContaining: "/v1/entries/ids")
let account = TestAccountManager.shared.createAccount(type: .miniflux)
defer { TestAccountManager.shared.deleteAccount(account) }
account.endpointURL = URL(string: "https://miniflux.test")
do {
try await account.refreshAll()
XCTFail("Expected initial reconciliation to fail")
} catch {}
let firstAttemptCount = TestingURLProtocol.requestCount(forURLContaining: "/v1/entries/ids")
XCTAssertGreaterThan(firstAttemptCount, 0)
TestingURLProtocol.setResponse("/v1/entries/ids", file: "JSON/miniflux_entry_ids.json")
try await account.refreshAll()
XCTAssertGreaterThan(TestingURLProtocol.requestCount(forURLContaining: "/v1/entries/ids"), firstAttemptCount)
}
func testInitialReconciliationPreservesPendingLocalStatus() async {
let account = TestAccountManager.shared.createAccount(type: .miniflux)
defer { TestAccountManager.shared.deleteAccount(account) }
let delegate = account.delegate as! MinifluxAccountDelegate
var markedOff = Set<String>()
let changedCount = await delegate.syncArticleState(
entryIDs: [],
pendingArticleIDs: ["5001"],
currentArticleIDs: { ["5001"] },
markOn: { $0 },
markOff: { articleIDs in
markedOff = articleIDs
return articleIDs
}
)
XCTAssertTrue(markedOff.isEmpty)
XCTAssertEqual(changedCount, 0)
}
}
@@ -0,0 +1,64 @@
//
// MinifluxVersionFallbackTests.swift
// AccountTests
//
// Created by Dave Marquard on 7/15/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import XCTest
import RSWeb
@testable import Account
@MainActor final class MinifluxVersionFallbackTests: XCTestCase {
override func setUp() {
TestingURLProtocol.reset()
}
/// On a server older than `entryIDsMinimumVersion`, `/v1/entries/ids` isn’t stubbed at
/// all — if the gating logic wrongly tried to use it, `refreshAll()` would throw. Instead
/// the initial sync's reconciliation must fall back to paging `/v1/entries`.
func testInitialSyncOnOldServerFallsBackToPagedEntries() async throws {
TestingURLProtocol.setResponse("/v1/version", file: "JSON/miniflux_version_old.json")
TestingURLProtocol.setResponse("/v1/categories", file: "JSON/miniflux_categories_initial.json")
TestingURLProtocol.setResponse("/v1/feeds", file: "JSON/miniflux_feeds_initial.json")
TestingURLProtocol.setResponse("/v1/entries?", file: "JSON/miniflux_entries_page1.json")
let account = TestAccountManager.shared.createAccount(type: .miniflux)
account.endpointURL = URL(string: "https://miniflux.test")
try await account.refreshAll()
let unreadArticleIDs = await account.fetchUnreadArticleIDsAsync()
let starredArticleIDs = await account.fetchStarredArticleIDsAsync()
XCTAssertTrue(unreadArticleIDs.contains("5001"))
XCTAssertTrue(starredArticleIDs.contains("5001"))
TestAccountManager.shared.deleteAccount(account)
}
/// On a current server, the initial sync's reconciliation should still use
/// `/v1/entries/ids` rather than the paged fallback.
func testInitialSyncOnCurrentServerStillUsesEntryIDsEndpoint() async throws {
TestingURLProtocol.setResponse("/v1/version", file: "JSON/miniflux_version.json")
TestingURLProtocol.setResponse("/v1/categories", file: "JSON/miniflux_categories_initial.json")
TestingURLProtocol.setResponse("/v1/feeds", file: "JSON/miniflux_feeds_initial.json")
TestingURLProtocol.setResponse("/v1/entries/ids", file: "JSON/miniflux_entry_ids.json")
TestingURLProtocol.setResponse("/v1/entries?", file: "JSON/miniflux_entries_page1.json")
let account = TestAccountManager.shared.createAccount(type: .miniflux)
account.endpointURL = URL(string: "https://miniflux.test")
try await account.refreshAll()
XCTAssertGreaterThan(TestingURLProtocol.requestCount(forURLContaining: "/v1/entries/ids"), 0)
let unreadArticleIDs = await account.fetchUnreadArticleIDsAsync()
let starredArticleIDs = await account.fetchStarredArticleIDsAsync()
XCTAssertTrue(unreadArticleIDs.contains("5001"))
XCTAssertTrue(starredArticleIDs.contains("5001"))
TestAccountManager.shared.deleteAccount(account)
}
}
@@ -0,0 +1,41 @@
//
// MinifluxVersionTests.swift
// AccountTests
//
// Created by Dave Marquard on 7/8/26.
// Copyright © 2026 Ranchero Software, LLC. All rights reserved.
//
import XCTest
@testable import Account
final class MinifluxVersionTests: XCTestCase {
func testParsesSimpleVersionString() throws {
let version = try XCTUnwrap(MinifluxVersion(string: "2.3.2"))
XCTAssertGreaterThanOrEqual(version, MinifluxVersion(2, 3, 2))
XCTAssertEqual(version, MinifluxVersion(2, 3, 2))
}
func testComparesNumericallyNotLexicographically() {
XCTAssertGreaterThan(MinifluxVersion(2, 3, 10), MinifluxVersion(2, 3, 2))
}
func testOlderMinorVersionIsLess() {
XCTAssertLessThan(MinifluxVersion(2, 2, 17), MinifluxVersion(2, 3, 2))
}
func testParsesNonNumericSuffixOnLastComponent() throws {
let version = try XCTUnwrap(MinifluxVersion(string: "2.3.2-dev"))
XCTAssertEqual(version, MinifluxVersion(2, 3, 2))
}
func testMissingComponentIsTreatedAsZero() throws {
let version = try XCTUnwrap(MinifluxVersion(string: "2.3"))
XCTAssertEqual(version, MinifluxVersion(2, 3, 0))
}
func testWhollyNonNumericStringFailsToParse() {
XCTAssertNil(MinifluxVersion(string: "dev"))
}
}
@@ -352,6 +352,18 @@ public struct ArticleCounts: Sendable {
}
}
/// Delete statuses — only for articles the sync service has affirmatively reported
/// as deleted. Statuses intentionally outlive their articles (see
/// `ArticlesTable.deleteStatuses`); deleting one on any weaker signal reintroduces
/// the old-articles-reappear-as-unread class of bugs.
public func deleteStatusesAsync(articleIDs: Set<String>) async {
await withCheckedContinuation { continuation in
_deleteStatuses(articleIDs: articleIDs) {
continuation.resume()
}
}
}
// MARK: - ArticleIDs
/// Fetch the articleIDs of unread articles.
@@ -556,6 +568,11 @@ private extension ArticlesDatabase {
articlesTable.delete(articleIDs: articleIDs, completion: completion)
}
func _deleteStatuses(articleIDs: Set<String>, completion: DatabaseCompletionBlock?) {
Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)")
articlesTable.deleteStatuses(articleIDs: articleIDs, completion: completion)
}
func _fetchUnreadArticleIDsAsync(completion: @escaping ArticleIDsCompletionBlock) {
Self.logger.debug("ArticlesDatabase: \(#function, privacy: .public) \(self.accountID, privacy: .public)")
articlesTable.fetchUnreadArticleIDsAsync(completion)
@@ -352,6 +352,29 @@ final class ArticlesTable: DatabaseTable, Sendable {
}
}
/// Delete statuses for articles the sync service reports as deleted.
///
/// Statuses deliberately outlive their articles: they're what lets
/// `articleIsIgnorable` drop a re-appearing old article instead of resurrecting
/// it, and what keeps long-lived feed items from coming back as unread. So
/// nothing else — not article deletion, not the retention cleanups — removes a
/// status before its own aging window ends.
///
/// The flip side: a status whose article no longer exists on the sync service
/// matches `fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate`
/// on every sync, so the account delegate re-requests the article forever and
/// the service keeps saying it's gone. Deleting the status is the terminal state
/// for that loop — and it's only safe here, when the service has affirmatively
/// reported the article deleted.
public func deleteStatuses(articleIDs: Set<String>, completion: DatabaseCompletionBlock?) {
self.queue.runInTransaction { database in
self.statusesTable.removeStatuses(articleIDs, database)
DispatchQueue.main.async {
completion?()
}
}
}
// MARK: - Unread Counts
/// Calls `completion` with nil if the query fails, so a failure doesn’t zero every unread count.
@@ -58,6 +58,8 @@ public enum CredentialsType: String, CaseIterable, Sendable {
case newsBlurSessionID = "newsBlurSessionId"
case readerBasic = "readerBasic"
case readerAPIKey = "readerAPIKey"
case minifluxBasic = "minifluxBasic"
case minifluxAPIToken = "minifluxAPIToken"
case oauthAccessToken = "oauthAccessToken"
case oauthAccessTokenSecret = "oauthAccessTokenSecret"
case oauthRefreshToken = "oauthRefreshToken"
+6
View File
@@ -36,6 +36,8 @@ extension AccountType {
return .systemTeal
case .inoreader:
return .systemBrown
case .miniflux:
return .systemMint
case .bazQux:
return .systemIndigo
case .theOldReader:
@@ -59,6 +61,8 @@ extension AccountType {
return .teal
case .inoreader:
return .brown
case .miniflux:
return .mint
case .bazQux:
return .indigo
case .theOldReader:
@@ -93,6 +97,8 @@ extension AccountType {
return Image("accountFreshRSS")
case .inoreader:
return Image("accountInoreader")
case .miniflux:
return Image("accountMiniflux")
case .newsBlur:
return Image("accountNewsBlur")
case .theOldReader:
+3
View File
@@ -30,6 +30,7 @@ struct Assets {
static var accountFeedly: RSImage { RSImage(named: "accountFeedly")! }
static var accountFreshRSS: RSImage { RSImage(named: "accountFreshRSS")! }
static var accountInoreader: RSImage { RSImage(named: "accountInoreader")! }
static var accountMiniflux: RSImage { RSImage(named: "accountMiniflux")! }
static var accountNewsBlur: RSImage { RSImage(named: "accountNewsBlur")! }
static var accountTheOldReader: RSImage { RSImage(named: "accountTheOldReader")! }
@@ -179,6 +180,8 @@ struct Assets {
return Assets.Images.accountFreshRSS
case .inoreader:
return Assets.Images.accountInoreader
case .miniflux:
return Assets.Images.accountMiniflux
case .newsBlur:
return Assets.Images.accountNewsBlur
case .theOldReader:
+41 -2
View File
@@ -48,6 +48,9 @@
}
}
},
"A username and password are required." : {
"comment" : "Credentials Error"
},
"A web browser will open the Feedly login for you to authorize access." : {
"comment" : "Alert informative text when adding a Feedly account and waiting for authorization from the user.",
"localizations" : {
@@ -182,9 +185,18 @@
"Always Use Reader View" : {
"comment" : "Always Use Reader View"
},
"An API token is required." : {
"comment" : "Credentials Error"
},
"API Token" : {
"comment" : "Miniflux authentication mode and token field"
},
"API URL: https://fresh.rss.net/api/greader.php" : {
"comment" : "FreshRSS API Helper"
},
"API URL: https://miniflux.example.com" : {
"comment" : "Miniflux API Helper"
},
"Appearance" : {
"comment" : "Preferences"
},
@@ -258,6 +270,9 @@
"Author’s website:\n%@" : {
"comment" : "Authors website"
},
"Authentication" : {
"comment" : "Miniflux authentication mode picker"
},
"Automatic" : {
"comment" : "Automatic"
},
@@ -516,6 +531,9 @@
"Don’t have a FreshRSS instance?" : {
"comment" : "No FreshRSS"
},
"Don’t have a Miniflux instance?" : {
"comment" : "No Miniflux"
},
"Don’t have a The Old Reader account?" : {
"comment" : "No OldReader"
},
@@ -654,7 +672,7 @@
"comment" : "Find in Article"
},
"Find out more" : {
"comment" : "No FreshRSS Button"
"comment" : "No FreshRSS Button\nNo Miniflux Button"
},
"Find Out More" : {
"comment" : "Find Out More"
@@ -760,6 +778,9 @@
"https://fresh.rss.net/api/greader.php" : {
"comment" : "FreshRSS API Helper"
},
"https://miniflux.example.com" : {
"comment" : "Miniflux API Helper"
},
"iCloud" : {
"comment" : "iCloud Account",
"localizations" : {
@@ -806,9 +827,15 @@
"Invalid API URL." : {
"comment" : "Invalid API URL"
},
"Invalid credentials." : {
"comment" : "Credentials Error"
},
"Invalid email/password combination." : {
"comment" : "Credentials Error"
},
"Invalid username/password combination, or invalid API token." : {
"comment" : "Credentials Error"
},
"Invalid username/password combination." : {
"comment" : "Credentials Error"
},
@@ -1367,6 +1394,12 @@
"Sign in to your Inoreader account." : {
"comment" : "Inoreader"
},
"Sign in to your Miniflux account." : {
"comment" : "Miniflux"
},
"Sign in to your Miniflux instance and sync your feeds across your devices. Your credentials will be encrypted and stored in Keychain.\n\nDon’t have a Miniflux instance?" : {
"comment" : "Miniflux"
},
"Sign in to your NewsBlur account and sync your feeds across your devices. Your username and password will be encrypted and stored in Keychain.\n\nDon’t have a NewsBlur account?" : {
"comment" : "NewsBlur"
},
@@ -1504,6 +1537,9 @@
"There is already a Feedbin account with that username created." : {
"comment" : "Duplicate Error"
},
"There is already a Miniflux account for this user on this server." : {
"comment" : "Duplicate Error"
},
"There is already a NewsBlur account with that username created." : {
"comment" : "Duplicate Error"
},
@@ -1720,6 +1756,9 @@
"Username and password are required." : {
"comment" : "Credentials Error"
},
"Username and Password" : {
"comment" : "Miniflux authentication mode"
},
"Username or Email" : {
"comment" : "Username field placeholder"
},
@@ -1807,4 +1846,4 @@
}
},
"version" : "1.1"
}
}
+144
View File
@@ -0,0 +1,144 @@
//
// MinifluxAccountView.swift
// NetNewsWire-iOS
//
// Copyright © 2026 Ranchero Software. All rights reserved.
//
import SwiftUI
import RSCore
import Account
import Secrets
/// Miniflux supports either a username and password or an API token.
struct MinifluxAccountView: View {
let account: Account?
let didAddAccount: (() -> Void)?
@Environment(\.dismiss) private var dismiss
@State private var username = ""
@State private var password = ""
@State private var apiToken = ""
@State private var apiURLString = ""
@State private var usesAPIToken = false
@State private var isValidating = false
@State private var errorMessage: String?
@State private var isShowingSignUp = false
var body: some View {
AccountSetupSheet(accountType: .miniflux, isWorking: isValidating) {
Section {
Picker(NSLocalizedString("Authentication", comment: "Miniflux authentication mode"), selection: $usesAPIToken) {
Text(NSLocalizedString("Username and Password", comment: "Miniflux authentication mode")).tag(false)
Text(NSLocalizedString("API Token", comment: "Miniflux authentication mode")).tag(true)
}
if usesAPIToken {
SecureField(NSLocalizedString("API Token", comment: "Miniflux API token"), text: $apiToken)
} else {
TextField(NSLocalizedString("Username or Email", comment: "Username field placeholder"), text: $username)
.textContentType(.username)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
SecureField(NSLocalizedString("Password", comment: "Password field placeholder"), text: $password)
}
TextField(NSLocalizedString("API URL: https://miniflux.example.com", comment: "Miniflux API Helper"), text: $apiURLString)
.textContentType(.URL)
.keyboardType(.URL)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
} header: {
AccountIconHeader(accountType: .miniflux)
}
Section {
Button(account == nil ? NSLocalizedString("Add Account", comment: "Add Account") : NSLocalizedString("Update Credentials", comment: "Update Credentials")) {
Task { await submit() }
}
.frame(maxWidth: .infinity)
.disabled(!canSubmit || isValidating)
} footer: {
AccountSheetFooter(text: NSLocalizedString("Sign in to your Miniflux instance and sync your feeds across your devices. Your credentials will be encrypted and stored in Keychain.\n\nDon’t have a Miniflux instance?", comment: "Miniflux"), linkTitle: NSLocalizedString("Find Out More", comment: "Find Out More")) {
isShowingSignUp = true
}
}
}
.errorAlert(message: $errorMessage)
.sheet(isPresented: $isShowingSignUp) {
if let signUpURL = URL(string: "https://miniflux.app") {
SafariView(url: signUpURL)
}
}
.onAppear { loadExistingCredentials() }
}
private var canSubmit: Bool {
guard !apiURLString.trimmingWhitespace.isEmpty else {
return false
}
return usesAPIToken
? !apiToken.trimmingWhitespace.isEmpty
: !username.trimmingWhitespace.isEmpty && !password.isEmpty
}
private func loadExistingCredentials() {
guard let account else {
return
}
apiURLString = account.endpointURL?.absoluteString ?? ""
if let credentials = try? account.retrieveCredentials(type: .minifluxAPIToken) {
usesAPIToken = true
apiToken = credentials.secret
} else if let credentials = try? account.retrieveCredentials(type: .minifluxBasic) {
username = credentials.username
password = credentials.secret
}
}
@MainActor private func submit() async {
guard let endpoint = normalizedEndpointURL else {
errorMessage = NSLocalizedString("Invalid API URL.", comment: "Invalid API URL")
return
}
let credentials = usesAPIToken
? Credentials(type: .minifluxAPIToken, username: "", secret: apiToken.trimmingWhitespace)
: Credentials(type: .minifluxBasic, username: username.trimmingWhitespace, secret: password)
isValidating = true
defer { isValidating = false }
do {
guard let validatedCredentials = try await Account.validateCredentials(type: .miniflux, credentials: credentials, endpoint: endpoint) else {
errorMessage = NSLocalizedString("Invalid username/password combination, or invalid API token.", comment: "Credentials Error")
return
}
if account == nil && AccountManager.shared.duplicateServiceAccount(type: .miniflux, endpointURL: endpoint, username: validatedCredentials.username) {
errorMessage = NSLocalizedString("There is already a Miniflux account for this user on this server.", comment: "Duplicate Error")
return
}
let account = self.account ?? AccountManager.shared.createAccount(type: .miniflux)
account.endpointURL = endpoint
let staleType: CredentialsType = validatedCredentials.type == .minifluxAPIToken ? .minifluxBasic : .minifluxAPIToken
try? account.removeCredentials(type: staleType)
try account.storeCredentials(validatedCredentials)
account.triggerRefreshAll()
dismiss()
didAddAccount?()
} catch {
errorMessage = error.localizedDescription
}
}
private var normalizedEndpointURL: URL? {
var text = apiURLString.trimmingWhitespace
while text.hasSuffix("/") { text.removeLast() }
if text.hasSuffix("/v1") { text.removeLast(3) }
while text.hasSuffix("/") { text.removeLast() }
guard !text.isEmpty else {
return nil
}
if !text.contains("://") { text = "https://" + text }
return URL(string: text)
}
}
+10 -2
View File
@@ -94,7 +94,7 @@ struct AccountInspectorView: View {
AccountManager.shared.syncArticleContentForUnreadArticles = syncContentOfUnreadArticles
}
.sheet(isPresented: $isShowingCredentials) {
CredentialsAccountView(accountType: account.type, account: account, didAddAccount: nil)
credentialsView
}
.sheet(isPresented: $isShowingLimitationsAndSolutions) {
SafariView(url: CloudKitWebDocumentation.limitationsAndSolutionsURL)
@@ -120,7 +120,15 @@ private extension AccountInspectorView {
}
var showsCredentials: Bool {
!isDefaultAccount && CredentialsAccountView.accountTypes.contains(account.type)
!isDefaultAccount && (account.type == .miniflux || CredentialsAccountView.accountTypes.contains(account.type))
}
@ViewBuilder var credentialsView: some View {
if account.type == .miniflux {
MinifluxAccountView(account: account, didAddAccount: nil)
} else {
CredentialsAccountView(accountType: account.type, account: account, didAddAccount: nil)
}
}
var showsSyncContent: Bool {
@@ -0,0 +1,26 @@
{
"images" : [
{
"filename" : "accountMiniflux.pdf",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "accountMiniflux-dark.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "original"
}
}
+3 -1
View File
@@ -66,7 +66,7 @@ struct AddAccountView: View {
case .web:
return [.bazQux, .feedbin, .feedly, .inoreader, .newsBlur, .theOldReader]
case .selfhosted:
return [.freshRSS]
return [.freshRSS, .miniflux]
}
}
}
@@ -100,6 +100,8 @@ struct AddAccountView: View {
LocalAccountView(didAddAccount: didAddAccount)
case .cloudKit:
CloudKitAccountView(didAddAccount: didAddAccount)
case .miniflux:
MinifluxAccountView(account: nil, didAddAccount: didAddAccount)
default:
CredentialsAccountView(accountType: sheet.accountType, account: nil, didAddAccount: didAddAccount)
}
@@ -16,6 +16,17 @@ extension UIViewController {
/// Size of form sheets on iPad.
static let formSheetSize = CGSize(width: 460, height: 400)
/// The sheet for updating an account's credentials, or nil if its type has none.
static func credentialsViewController(for account: Account) -> UIViewController? {
if account.type == .miniflux {
return UIHostingController(rootView: MinifluxAccountView(account: account, didAddAccount: nil))
}
guard CredentialsAccountView.accountTypes.contains(account.type) else {
return nil
}
return UIHostingController(rootView: CredentialsAccountView(accountType: account.type, account: account, didAddAccount: nil))
}
func presentError(_ error: Error, dismiss: (() -> Void)? = nil) {
if let accountError = error as? AccountError, accountError.isCredentialsError {
presentAccountError(accountError, dismiss: dismiss)
@@ -35,12 +46,11 @@ private extension UIViewController {
let title = NSLocalizedString("Account Error", comment: "Account Error")
let alertController = UIAlertController(title: title, message: error.localizedDescription, preferredStyle: .alert)
if let account = AccountError.account(from: error), CredentialsAccountView.accountTypes.contains(account.type) {
if let account = AccountError.account(from: error), let hostingController = UIViewController.credentialsViewController(for: account) {
let credentialsTitle = NSLocalizedString("Update Credentials", comment: "Update Credentials")
let credentialsAction = UIAlertAction(title: credentialsTitle, style: .default) { [weak self] _ in
dismiss?()
let hostingController = UIHostingController(rootView: CredentialsAccountView(accountType: account.type, account: account, didAddAccount: nil))
hostingController.modalPresentationStyle = .formSheet
hostingController.preferredContentSize = UIViewController.formSheetSize
self?.present(hostingController, animated: true)