mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-13 06:57:05 +03:00
Add canSubmitChapter and fix all userInfo functions running
This commit is contained in:
@@ -43,6 +43,7 @@ addDefaults(config, {
|
|||||||
discordFailedReportChannelWebhookURL: null,
|
discordFailedReportChannelWebhookURL: null,
|
||||||
discordReportChannelWebhookURL: null,
|
discordReportChannelWebhookURL: null,
|
||||||
discordMaliciousReportWebhookURL: null,
|
discordMaliciousReportWebhookURL: null,
|
||||||
|
minReputationToSubmitChapter: 0,
|
||||||
getTopUsersCacheTimeMinutes: 240,
|
getTopUsersCacheTimeMinutes: 240,
|
||||||
globalSalt: null,
|
globalSalt: null,
|
||||||
mode: "",
|
mode: "",
|
||||||
|
|||||||
@@ -105,6 +105,10 @@ async function dbGetBanned(userID: HashedUserID): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function dbCanSubmitChapter(userID: HashedUserID): Promise<boolean> {
|
||||||
|
return (await isUserVIP(userID)) || (await getReputation(userID)) > config.minReputationToSubmitChapter;
|
||||||
|
}
|
||||||
|
|
||||||
type cases = Record<string, any>
|
type cases = Record<string, any>
|
||||||
|
|
||||||
const executeIfFunction = (f: any) =>
|
const executeIfFunction = (f: any) =>
|
||||||
@@ -119,16 +123,17 @@ const functionSwitch = (cases: cases) => (defaultCase: string) => (key: string)
|
|||||||
const dbGetValue = (userID: HashedUserID, property: string): Promise<string|SegmentUUID|number> => {
|
const dbGetValue = (userID: HashedUserID, property: string): Promise<string|SegmentUUID|number> => {
|
||||||
return functionSwitch({
|
return functionSwitch({
|
||||||
userID,
|
userID,
|
||||||
userName: dbGetUsername(userID),
|
userName: () => dbGetUsername(userID),
|
||||||
ignoredSegmentCount: dbGetIgnoredSegmentCount(userID),
|
ignoredSegmentCount: () => dbGetIgnoredSegmentCount(userID),
|
||||||
viewCount: dbGetViewsForUser(userID),
|
viewCount: () => dbGetViewsForUser(userID),
|
||||||
ignoredViewCount: dbGetIgnoredViewsForUser(userID),
|
ignoredViewCount: () => dbGetIgnoredViewsForUser(userID),
|
||||||
warnings: dbGetWarningsForUser(userID),
|
warnings: () => dbGetWarningsForUser(userID),
|
||||||
warningReason: dbGetActiveWarningReasonForUser(userID),
|
warningReason: () => dbGetActiveWarningReasonForUser(userID),
|
||||||
banned: dbGetBanned(userID),
|
banned: () => dbGetBanned(userID),
|
||||||
reputation: getReputation(userID),
|
reputation: () => getReputation(userID),
|
||||||
vip: isUserVIP(userID),
|
vip: () => isUserVIP(userID),
|
||||||
lastSegmentID: dbGetLastSegmentForUser(userID),
|
lastSegmentID: () => dbGetLastSegmentForUser(userID),
|
||||||
|
canSubmitChapter: () => dbCanSubmitChapter(userID)
|
||||||
})("")(property);
|
})("")(property);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export interface SBSConfig {
|
|||||||
discordMaliciousReportWebhookURL?: string;
|
discordMaliciousReportWebhookURL?: string;
|
||||||
neuralBlockURL?: string;
|
neuralBlockURL?: string;
|
||||||
discordNeuralBlockRejectWebhookURL?: string;
|
discordNeuralBlockRejectWebhookURL?: string;
|
||||||
|
minReputationToSubmitChapter: number;
|
||||||
userCounterURL?: string;
|
userCounterURL?: string;
|
||||||
proxySubmission?: string;
|
proxySubmission?: string;
|
||||||
behindProxy: string | boolean;
|
behindProxy: string | boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user