feedkeeper 0.40.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -110,7 +110,7 @@ export function createMcpServerForUser(userId, scope) {
110
110
  if (scope === "write")
111
111
  server.registerTool("subscribe_feed", {
112
112
  title: "Subscribe to a feed",
113
- description: "Subscribes the current user to an RSS/Atom feed URL or website URL (auto-discovering the feed link if a website URL is provided). Requires write scope. Idempotent: subscribing to an already subscribed feed returns the existing subscription. Returns the subscription record. For API documentation, see https://github.com/visualfusion/feedkeeper.",
113
+ description: "Subscribes the current user to an RSS, Atom, or JSON feed URL or website URL (auto-discovering the feed link if a website URL is provided). Requires write scope. Idempotent: subscribing to an already subscribed feed returns the existing subscription. Returns the subscription record. For API documentation, see https://github.com/visualfusion/feedkeeper.",
114
114
  annotations: {
115
115
  readOnlyHint: false,
116
116
  destructiveHint: false,
@@ -118,7 +118,7 @@ export function createMcpServerForUser(userId, scope) {
118
118
  openWorldHint: true,
119
119
  },
120
120
  inputSchema: {
121
- url: mcpUrlSchema.describe("The RSS/Atom feed URL or website URL to subscribe to"),
121
+ url: mcpUrlSchema.describe("The RSS, Atom, or JSON feed URL or website URL to subscribe to"),
122
122
  label: z.string().max(200).optional().describe("Optional custom display name for this feed subscription"),
123
123
  folderId: z.number().int().positive().optional().describe("Optional folder/category ID to place the new subscription in"),
124
124
  },
@@ -149,7 +149,7 @@ export function createMcpServerForUser(userId, scope) {
149
149
  description: "Inspects a website URL and discovers available RSS, Atom, and JSON feed links from HTML link tags. Safe read-only operation: does NOT subscribe to any feed. Returns a list of discovered candidate feed URLs and titles. Use subscribe_feed to subscribe to one of the discovered URLs. For API documentation, see https://github.com/visualfusion/feedkeeper.",
150
150
  annotations: readOnlyOpenWorldAnnotations,
151
151
  inputSchema: {
152
- url: mcpUrlSchema.describe("The website URL to scan for available RSS/Atom feed links"),
152
+ url: mcpUrlSchema.describe("The website URL to scan for available RSS, Atom, or JSON feed links"),
153
153
  },
154
154
  }, async ({ url }) => {
155
155
  if (!hasUserCapability(userId, "sync"))
@@ -67,7 +67,7 @@ export function saveDevice(userId, target) {
67
67
  db.prepare(`INSERT INTO push_devices (user_id, endpoint, p256dh, auth) VALUES (?, ?, ?, ?)
68
68
  ON CONFLICT(endpoint) DO UPDATE SET user_id = excluded.user_id, p256dh = excluded.p256dh, auth = excluded.auth`).run(userId, target.endpoint, target.keys.p256dh, target.keys.auth);
69
69
  // Keep the newest devices only.
70
- db.prepare(`DELETE FROM push_devices WHERE user_id = ? AND id NOT IN (SELECT id FROM push_devices WHERE user_id = ? ORDER BY id DESC LIMIT ?)`).run(userId, userId, MAX_DEVICES_PER_USER);
70
+ db.prepare(`DELETE FROM push_devices WHERE user_id = ? AND endpoint IS NOT NULL AND id NOT IN (SELECT id FROM push_devices WHERE user_id = ? AND endpoint IS NOT NULL ORDER BY id DESC LIMIT ?)`).run(userId, userId, MAX_DEVICES_PER_USER);
71
71
  })();
72
72
  }
73
73
  export function removeDevice(userId, endpoint) {
@@ -78,7 +78,7 @@ export function hasDevice(userId, endpoint) {
78
78
  }
79
79
  function devicesOf(userId) {
80
80
  return db
81
- .prepare("SELECT endpoint, p256dh, auth FROM push_devices WHERE user_id = ?")
81
+ .prepare("SELECT endpoint, p256dh, auth FROM push_devices WHERE user_id = ? AND endpoint IS NOT NULL")
82
82
  .all(userId)
83
83
  .map((row) => ({ endpoint: row.endpoint, keys: { p256dh: row.p256dh, auth: row.auth } }));
84
84
  }
@@ -5,6 +5,10 @@ import { newItemsPushPayload, sendPushTarget } from "./push.js";
5
5
  import { parseRetryAfter } from "./feeds/fetcher.js";
6
6
  // Initialized during startup, so background work never retains an HTTP capability cache.
7
7
  const context = new AsyncResource("FeedKeeperPushOutbox");
8
+ let nativeSender;
9
+ export function setNativePushSender(sender) {
10
+ nativeSender = sender;
11
+ }
8
12
  /** Call inside the article/job-completion transaction. No network or recipient-sized array. */
9
13
  export function enqueueNewItemNotifications(feedId, newItems) {
10
14
  if (!newItems)
@@ -96,8 +100,9 @@ export class PushOutbox {
96
100
  .run(subscription.id, event.device_ceiling, event.id);
97
101
  }
98
102
  const device = db.prepare(`
99
- SELECT id,endpoint,p256dh,auth FROM push_devices WHERE user_id = ? AND id > ? AND id <= ? ORDER BY id LIMIT 1`)
100
- .get(subscription.user_id, event.device_cursor, event.device_ceiling);
103
+ SELECT id,endpoint,p256dh,auth,native_device_id,native_token,native_environment,native_language FROM push_devices
104
+ WHERE user_id = ? AND id > ? AND id <= ? AND (endpoint IS NOT NULL OR (native_feeds = 1 AND ?)) ORDER BY id LIMIT 1`)
105
+ .get(subscription.user_id, event.device_cursor, event.device_ceiling, nativeSender ? 1 : 0);
101
106
  if (!device) {
102
107
  this.advanceSubscription(event, subscription.id);
103
108
  return;
@@ -119,7 +124,10 @@ export class PushOutbox {
119
124
  return;
120
125
  }
121
126
  try {
122
- await sendPushTarget({ endpoint: device.endpoint, keys: { p256dh: device.p256dh, auth: device.auth } }, payload);
127
+ if (device.endpoint === null)
128
+ await nativeSender?.(device, payload);
129
+ else
130
+ await sendPushTarget({ endpoint: device.endpoint, keys: { p256dh: device.p256dh, auth: device.auth } }, payload);
123
131
  this.counters.delivered++;
124
132
  }
125
133
  catch (error) {
@@ -127,7 +135,12 @@ export class PushOutbox {
127
135
  const status = error.statusCode;
128
136
  if (status === 404 || status === 410) {
129
137
  // Do not remove a device if its ownership changed during I/O.
130
- db.prepare("DELETE FROM push_devices WHERE id = ? AND user_id = ?").run(device.id, subscription.user_id);
138
+ if (device.endpoint === null) {
139
+ db.prepare("DELETE FROM push_devices WHERE id = ? AND native_token = ? AND native_environment = ?")
140
+ .run(device.id, device.native_token, device.native_environment);
141
+ }
142
+ else
143
+ db.prepare("DELETE FROM push_devices WHERE id = ? AND user_id = ?").run(device.id, subscription.user_id);
131
144
  }
132
145
  else if ((status === undefined || [408, 425, 429, 500, 502, 503, 504].includes(status)) && event.attempts < 2) {
133
146
  const headers = error.headers;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedkeeper/server",
3
- "version": "0.40.0",
3
+ "version": "0.42.0",
4
4
  "private": true,
5
5
  "type": "module"
6
6
  }