@remit/backend 0.0.11 → 0.0.12
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.
package/package.json
CHANGED
|
@@ -18,15 +18,18 @@ const row = (
|
|
|
18
18
|
): Row => ({ threadMessageId, messageIdHeader, createdAt });
|
|
19
19
|
|
|
20
20
|
describe("buildListThreadMessagesOptions", () => {
|
|
21
|
-
it("defaults to
|
|
21
|
+
it("defaults to oldest-first and hides soft-deleted messages", () => {
|
|
22
22
|
assert.deepEqual(buildListThreadMessagesOptions({}), {
|
|
23
|
-
order: "
|
|
23
|
+
order: "asc",
|
|
24
24
|
excludeDeleted: true,
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it("honours an explicit order", () => {
|
|
29
|
-
assert.equal(
|
|
29
|
+
assert.equal(
|
|
30
|
+
buildListThreadMessagesOptions({ order: "desc" }).order,
|
|
31
|
+
"desc",
|
|
32
|
+
);
|
|
30
33
|
});
|
|
31
34
|
|
|
32
35
|
it("carries no mailbox filter, so sent messages stay in the conversation", () => {
|
package/src/handlers/thread.ts
CHANGED
|
@@ -251,11 +251,16 @@ export const executeThreadSearch = async (
|
|
|
251
251
|
* A conversation is never scoped to one mailbox: the user's own replies live
|
|
252
252
|
* in Sent, filed messages live in their folder, and all of them belong to the
|
|
253
253
|
* same thread (#46).
|
|
254
|
+
*
|
|
255
|
+
* The default order is `asc`: a conversation is read in the order it happened,
|
|
256
|
+
* so a reply follows the message it answers (#81). The ordering is the query's,
|
|
257
|
+
* not the handler's — `listByThread` sorts on sentDate with `threadMessageId`
|
|
258
|
+
* breaking ties, so it holds across pages rather than within one response.
|
|
254
259
|
*/
|
|
255
260
|
export const buildListThreadMessagesOptions = (query: {
|
|
256
261
|
order?: "asc" | "desc";
|
|
257
262
|
}) => ({
|
|
258
|
-
order: query.order ?? ("
|
|
263
|
+
order: query.order ?? ("asc" as const),
|
|
259
264
|
excludeDeleted: true,
|
|
260
265
|
});
|
|
261
266
|
|