Skip to content

Commit

Permalink
fix: check For Badge existence first
Browse files Browse the repository at this point in the history
  • Loading branch information
boomzero committed Aug 28, 2024
1 parent 8d40c1d commit 48c064a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Source/Process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,11 @@ export class Process {
if (!this.IsAdmin() && Data["UserID"] !== this.Username) {
return new Result(false, "没有权限编辑此标签");
}
if (ThrowErrorIfFailed(await this.XMOJDatabase.GetTableSize("badge", {
user_id: Data["UserID"]
}))["TableSize"] === 0) {
return new Result(false, "编辑失败,该标签在数据库中不存在");
}
if (this.DenyEdit()) {
return new Result(false, "你被禁止修改标签");
}
Expand All @@ -1203,11 +1208,6 @@ export class Process {
if (check[check[0]["label"] == "NEGATIVE" ? 0 : 1]["score"].toFixed() > 0.85) {
return new Result(false, "您设置的标签内容含有负面词汇,请修改后重试");
}
if (ThrowErrorIfFailed(await this.XMOJDatabase.GetTableSize("badge", {
user_id: Data["UserID"]
}))["TableSize"] === 0) {
return new Result(false, "编辑失败,该标签在数据库中不存在");
}
ThrowErrorIfFailed(await this.XMOJDatabase.Update("badge", {
background_color: Data["BackgroundColor"],
color: Data["Color"],
Expand Down

0 comments on commit 48c064a

Please sign in to comment.