@rmdes/indiekit-endpoint-microsub 1.0.41 → 1.0.42

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.
@@ -6,7 +6,7 @@
6
6
  import { IndiekitError } from "@indiekit/error";
7
7
 
8
8
  import { proxyItemImages } from "../media/proxy.js";
9
- import { getChannel } from "../storage/channels.js";
9
+ import { getChannel, getChannelById } from "../storage/channels.js";
10
10
  import {
11
11
  getTimelineItems,
12
12
  markItemsRead,
@@ -72,8 +72,16 @@ export async function action(request, response) {
72
72
 
73
73
  validateChannel(channel);
74
74
 
75
- // Verify channel exists
76
- const channelDocument = await getChannel(application, channel, userId);
75
+ // Verify channel exists — try by UID first, fall back to ObjectId
76
+ // (timeline view may send ObjectId string for items from orphan channels)
77
+ let channelDocument = await getChannel(application, channel, userId);
78
+ if (!channelDocument) {
79
+ try {
80
+ channelDocument = await getChannelById(application, channel);
81
+ } catch {
82
+ // Invalid ObjectId format — channel string is not a valid ObjectId
83
+ }
84
+ }
77
85
  if (!channelDocument) {
78
86
  throw new IndiekitError("Channel not found", {
79
87
  status: 404,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-microsub",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "Microsub endpoint for Indiekit. Enables subscribing to feeds and reading content using the Microsub protocol.",
5
5
  "keywords": [
6
6
  "indiekit",
@@ -203,6 +203,7 @@
203
203
  data-action="mark-read"
204
204
  data-item-id="{{ item._id }}"
205
205
  {% if item._channelUid %}data-channel-uid="{{ item._channelUid }}"{% endif %}
206
+ {% if item._channelId %}data-channel-id="{{ item._channelId }}"{% endif %}
206
207
  title="Mark as read">
207
208
  {{ icon("checkboxChecked") }}
208
209
  <span class="visually-hidden">Mark read</span>
@@ -108,7 +108,8 @@
108
108
 
109
109
  const itemId = button.dataset.itemId;
110
110
  const channelUid = button.dataset.channelUid;
111
- if (!itemId || !channelUid) return;
111
+ const channelId = button.dataset.channelId;
112
+ if (!itemId || (!channelUid && !channelId)) return;
112
113
 
113
114
  button.disabled = true;
114
115
 
@@ -116,7 +117,7 @@
116
117
  const formData = new URLSearchParams();
117
118
  formData.append('action', 'timeline');
118
119
  formData.append('method', 'mark_read');
119
- formData.append('channel', channelUid);
120
+ formData.append('channel', channelUid || channelId);
120
121
  formData.append('entry', itemId);
121
122
 
122
123
  const response = await fetch(microsubApiUrl, {