mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49: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
|
|
@ -298,20 +298,17 @@ export const replaceTextMentions = (text: string, mentions: User[]): string => {
|
|||
);
|
||||
}
|
||||
|
||||
return finalText
|
||||
.replace(
|
||||
createRegExp(
|
||||
return finalText.replace(
|
||||
createRegExp(
|
||||
exactly(
|
||||
exactly(`@${username}`)
|
||||
.notBefore(anyOf(letter, digit, charIn("@")))
|
||||
.notAfter(anyOf(letter, digit, charIn("@"))),
|
||||
[global],
|
||||
),
|
||||
linkTemplate(`@${username}@${baseHost}`),
|
||||
)
|
||||
.replaceAll(
|
||||
`@${username}@${baseHost}`,
|
||||
linkTemplate(`@${username}@${baseHost}`),
|
||||
);
|
||||
).or(exactly(`@${username}@${baseHost}`)),
|
||||
[global],
|
||||
),
|
||||
linkTemplate(`@${username}@${baseHost}`),
|
||||
);
|
||||
}, text);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ mock.module("@versia/kit/db", () => ({
|
|||
},
|
||||
Notification: {
|
||||
fromSql: jest.fn(),
|
||||
insert: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
|
|
@ -242,6 +241,7 @@ describe("InboxProcessor", () => {
|
|||
id: "followee-id",
|
||||
data: { isLocked: false },
|
||||
sendFollowAccept: jest.fn(),
|
||||
notify: jest.fn(),
|
||||
};
|
||||
const mockRelationship = {
|
||||
data: { following: false },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue