Skip to content

Commit

Permalink
add invert and proper compile
Browse files Browse the repository at this point in the history
  • Loading branch information
jtgi committed Mar 8, 2024
1 parent 97d39a0 commit a76ec05
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/lib/validations.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const ruleDefinitions: Record<RuleName, RuleDefinition> = {
friendlyName: "User Is Cohost",
description: "Check if the user is a cohost",
hidden: false,
invertable: false,
invertable: true,
args: {},
},

Expand Down Expand Up @@ -517,16 +517,18 @@ export function userFollowerCount(props: CheckFunctionArgs) {
}
}

export function userIsCohost(args: CheckFunctionArgs) {
const { channel } = args;
export async function userIsCohost(args: CheckFunctionArgs) {
const { channel, rule } = args;

const isUserCohost = isCohost({
const isUserCohost = await isCohost({
fid: args.cast.author.fid,
channel: channel.id,
});

if (!isUserCohost) {
if (rule.invert && !isUserCohost) {
return `User is not a cohost`;
} else if (!rule.invert && isUserCohost) {
return `User is a cohost`;
}
}

Expand Down

0 comments on commit a76ec05

Please sign in to comment.