mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
fix(api): 🐛 Fix duplicated mentions, general refactorings
This commit is contained in:
parent
84a0a07ea6
commit
e293bd280d
5 changed files with 29 additions and 29 deletions
|
|
@ -143,7 +143,7 @@ describe(meta.route, () => {
|
|||
|
||||
const objects = (await response.json()) as ApiNotification[];
|
||||
|
||||
expect(objects.length).toBe(2);
|
||||
expect(objects.length).toBe(3);
|
||||
// There should be no element with a status with id of timeline[0].id
|
||||
expect(objects).not.toContainEqual(
|
||||
expect.objectContaining({
|
||||
|
|
|
|||
|
|
@ -153,25 +153,25 @@ export default apiRoute((app) =>
|
|||
// Filters in `Filters` table have keyword in `FilterKeywords` table (use LIKE)
|
||||
// Filters table has a userId and a context which is an array
|
||||
sql`NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM "Filters"
|
||||
WHERE "Filters"."userId" = ${user.id}
|
||||
AND "Filters"."filter_action" = 'hide'
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM "FilterKeywords", "Notifications" as "n_inner", "Notes"
|
||||
WHERE "FilterKeywords"."filterId" = "Filters"."id"
|
||||
AND "n_inner"."noteId" = "Notes"."id"
|
||||
AND "Notes"."content" LIKE
|
||||
'%' || "FilterKeywords"."keyword" || '%'
|
||||
AND "n_inner"."id" = "Notifications"."id"
|
||||
)
|
||||
AND "Filters"."context" @> ARRAY['notifications']
|
||||
)`,
|
||||
SELECT 1
|
||||
FROM "Filters"
|
||||
WHERE "Filters"."userId" = ${user.id}
|
||||
AND "Filters"."filter_action" = 'hide'
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM "FilterKeywords", "Notifications" as "n_inner", "Notes"
|
||||
WHERE "FilterKeywords"."filterId" = "Filters"."id"
|
||||
AND "n_inner"."noteId" = "Notes"."id"
|
||||
AND "Notes"."content" LIKE
|
||||
'%' || "FilterKeywords"."keyword" || '%'
|
||||
AND "n_inner"."id" = "Notifications"."id"
|
||||
)
|
||||
AND "Filters"."context" @> ARRAY['notifications']
|
||||
)`,
|
||||
),
|
||||
limit,
|
||||
context.req.url,
|
||||
user?.id,
|
||||
user.id,
|
||||
);
|
||||
|
||||
return context.json(
|
||||
|
|
|
|||
|
|
@ -310,6 +310,9 @@ describe(meta.route, () => {
|
|||
|
||||
const object = (await response.json()) as ApiStatus;
|
||||
|
||||
expect(object.content).toBe(
|
||||
`<p>Hello, <a class="u-url mention" rel="nofollow noopener noreferrer" target="_blank" href="${users[1].getUri()}">@${users[1].data.username}</a>!</p>`,
|
||||
);
|
||||
expect(object.mentions).toBeArrayOfSize(1);
|
||||
expect(object.mentions[0]).toMatchObject({
|
||||
id: users[1].id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue