fix: Present collections in suggestions.mention response (#14747)

This commit is contained in:
Tom Moor authored and GitHub committed 2026-11-26 18:51:29 -05:00
1 parent 66432e53a4
commit 5891724628
2 files changed
+39 -9

No files matched your search

@@ -1,5 +1,6 @@
import { EmailDisplay, TeamPreference } from "@shared/types";
import {
buildCollection,
buildGroup,
buildGroupUser,
buildGuestUser,
@@ -138,6 +139,27 @@ describe("#suggestions.mention", () => {
}
});
it("should present collections", async () => {
const user = await buildUser();
const collection = await buildCollection({
teamId: user.teamId,
userId: user.id,
name: "Elephants",
});
const res = await server.post("/api/suggestions.mention", user, {
body: { query: "Elephants" },
});
const body = await res.json();
const [found] = body.data.collections;
expect(res.status).toEqual(200);
expect(found.id).toEqual(collection.id);
expect(found.url).toEqual(collection.path);
expect(found.content).toBeUndefined();
expect(found.data).toBeUndefined();
});
it("should require authentication", async () => {
const res = await server.post("/api/suggestions.mention");
expect(res.status).toEqual(401);
+17 -9
View File
@@ -15,6 +15,7 @@ import SearchProviderManager from "@server/utils/SearchProviderManager";
import { QueryHelper } from "@server/storage/QueryHelper";
import { can } from "@server/policies";
import {
presentCollection,
presentDocuments,
presentGroup,
presentUser,
@@ -153,15 +154,22 @@ router.post(
),
withinLimit(
"collections",
() =>
SearchProviderManager.getProvider().searchCollectionsForUser(
actor,
{
query,
offset,
limit,
}
),
async () => {
const found =
await SearchProviderManager.getProvider().searchCollectionsForUser(
actor,
{
query,
offset,
limit,
}
);
return Promise.all(
found.map((collection) =>
presentCollection(ctx, collection, { includeData: false })
)
);
},
[]
),
]);