Skip to content

Commit

Permalink
fix: improve the robustness of callme
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-fish committed Apr 23, 2024
1 parent a45b409 commit 392a5cc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/plugins/callme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ export default class PatchCallme extends BasePlugin {
)
}
})
// 检查不合法词汇
.check((_, name) => {
if (!name) return
const invalid = /[<>]/.test(name)
const invalid = /[<>\x00-\x1F\x7F]/.test(name)
if (invalid) {
return (
<>
Expand All @@ -66,6 +67,7 @@ export default class PatchCallme extends BasePlugin {
)
}
})
// 检查违禁词
.check((_, name) => {
if (!name) return
const verify = ctx.mint.verify(name)
Expand All @@ -82,13 +84,16 @@ export default class PatchCallme extends BasePlugin {
)
}
})
// 检查是否重名
.check(async ({ session }, name) => {
if (!name) return
const existUser = await session.app.database.get('user', { name })
if (
existUser.length &&
existUser.some((user) => user.id !== session.user.id)
) {
if (session.user.name === name) return
const [existUser] = await session.app.database.get(
'user',
{ name, id: { $not: session.user.id } },
{ limit: 1 }
)
if (existUser) {
return (
<>
<random>
Expand Down

0 comments on commit 392a5cc

Please sign in to comment.