@rmdes/indiekit-endpoint-microsub 1.0.0-beta.1 → 1.0.0-beta.3
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.
|
@@ -25,6 +25,12 @@ import { get as getTimeline, action as timelineAction } from "./timeline.js";
|
|
|
25
25
|
export async function get(request, response, next) {
|
|
26
26
|
try {
|
|
27
27
|
const { action } = request.query;
|
|
28
|
+
|
|
29
|
+
// If no action provided, redirect to reader UI
|
|
30
|
+
if (!action) {
|
|
31
|
+
return response.redirect(request.baseUrl + "/reader");
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
validateAction(action);
|
|
29
35
|
|
|
30
36
|
switch (action) {
|
package/lib/search/query.js
CHANGED
|
@@ -94,7 +94,8 @@ export async function searchItemsRegex(
|
|
|
94
94
|
{ "author.name": regex },
|
|
95
95
|
],
|
|
96
96
|
})
|
|
97
|
-
|
|
97
|
+
// eslint-disable-next-line unicorn/no-array-sort -- MongoDB cursor method, not Array#sort
|
|
98
|
+
.sort({ published: -1 })
|
|
98
99
|
.limit(limit)
|
|
99
100
|
.toArray();
|
|
100
101
|
|
package/lib/storage/channels.js
CHANGED
|
@@ -55,7 +55,8 @@ export async function createChannel(application, { name, userId }) {
|
|
|
55
55
|
// Get max order for user
|
|
56
56
|
const maxOrderResult = await collection
|
|
57
57
|
.find({ userId })
|
|
58
|
-
|
|
58
|
+
// eslint-disable-next-line unicorn/no-array-sort -- MongoDB cursor method, not Array#sort
|
|
59
|
+
.sort({ order: -1 })
|
|
59
60
|
.limit(1)
|
|
60
61
|
.toArray();
|
|
61
62
|
|
|
@@ -93,7 +94,8 @@ export async function getChannels(application, userId) {
|
|
|
93
94
|
const channels = await collection
|
|
94
95
|
// eslint-disable-next-line unicorn/no-array-callback-reference -- filter is MongoDB query object
|
|
95
96
|
.find(filter)
|
|
96
|
-
|
|
97
|
+
// eslint-disable-next-line unicorn/no-array-sort -- MongoDB cursor method, not Array#sort
|
|
98
|
+
.sort({ order: 1 })
|
|
97
99
|
.toArray();
|
|
98
100
|
|
|
99
101
|
// Get unread counts for each channel
|
package/lib/storage/items.js
CHANGED
|
@@ -99,7 +99,8 @@ export async function getTimelineItems(application, channelId, options = {}) {
|
|
|
99
99
|
const items = await collection
|
|
100
100
|
// eslint-disable-next-line unicorn/no-array-callback-reference -- query is MongoDB query object
|
|
101
101
|
.find(query)
|
|
102
|
-
|
|
102
|
+
// eslint-disable-next-line unicorn/no-array-sort -- MongoDB cursor method, not Array#sort
|
|
103
|
+
.sort(sort)
|
|
103
104
|
.limit(limit + 1)
|
|
104
105
|
.toArray();
|
|
105
106
|
|
|
@@ -370,7 +371,8 @@ export async function searchItems(application, channelId, query, limit = 20) {
|
|
|
370
371
|
{ summary: regex },
|
|
371
372
|
],
|
|
372
373
|
})
|
|
373
|
-
|
|
374
|
+
// eslint-disable-next-line unicorn/no-array-sort -- MongoDB cursor method, not Array#sort
|
|
375
|
+
.sort({ published: -1 })
|
|
374
376
|
.limit(limit)
|
|
375
377
|
.toArray();
|
|
376
378
|
|
|
@@ -127,13 +127,13 @@ export async function getNotifications(application, userId, options = {}) {
|
|
|
127
127
|
query.readBy = { $ne: userId };
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
/* eslint-disable unicorn/no-array-callback-reference --
|
|
130
|
+
/* eslint-disable unicorn/no-array-callback-reference, unicorn/no-array-sort -- MongoDB cursor methods */
|
|
131
131
|
const notifications = await collection
|
|
132
132
|
.find(query)
|
|
133
|
-
.
|
|
133
|
+
.sort({ published: -1 })
|
|
134
134
|
.limit(limit)
|
|
135
135
|
.toArray();
|
|
136
|
-
/* eslint-enable unicorn/no-array-callback-reference */
|
|
136
|
+
/* eslint-enable unicorn/no-array-callback-reference, unicorn/no-array-sort */
|
|
137
137
|
|
|
138
138
|
return notifications.map((n) => transformNotification(n, userId));
|
|
139
139
|
}
|
package/package.json
CHANGED