Skip to content

Commit

Permalink
fix(core): legacy bans causing issues on search
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Oct 9, 2024
1 parent 72b1507 commit 5e14d38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion core/components/PlayerDatabase/databaseTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type DatabaseActionBaseType = {
author: string;
timestamp: number;
//FIXME: the revocation object itself should be optional instead of nullable properties
//BUT DO REMEMBER THE `'XXX' IN YYY` ISSUE!
revocation: {
timestamp: number | null;
author: string | null;
Expand All @@ -35,7 +36,7 @@ export type DatabaseActionBanType = {
} & DatabaseActionBaseType;
export type DatabaseActionWarnType = {
type: 'warn';
expiration: false; //FIXME: remove
expiration: false; //FIXME: remove - BUT DO REMEMBER THE `'XXX' IN YYY` ISSUE!
acked: boolean; //if the player has acknowledged the warning
} & DatabaseActionBaseType;
export type DatabaseActionType = DatabaseActionBanType | DatabaseActionWarnType;
Expand Down
9 changes: 6 additions & 3 deletions core/components/PlayerDatabase/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,12 @@ export default class PlayerDatabase {
if (hwidsArray && !Array.isArray(hwidsArray)) throw new Error('hwidsArray should be an array or undefined');
const idsFilter = (action: DatabaseActionType) => idsArray.some((fi) => action.ids.includes(fi))
const hwidsFilter = (action: DatabaseActionType) => {
if (!('hwids' in action)) return false;
const count = hwidsArray!.filter((fi) => action.hwids!.includes(fi)).length
return count >= this.config.requiredBanHwidMatches;
if ('hwids' in action && action.hwids){
const count = hwidsArray!.filter((fi) => action.hwids?.includes(fi)).length;
return count >= this.config.requiredBanHwidMatches;
} else {
return false;
}
}

try {
Expand Down

0 comments on commit 5e14d38

Please sign in to comment.