mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Add incr on block.
This commit is contained in:
parent
968574dda1
commit
7e587198dd
@ -54,6 +54,11 @@ async function fetchUserBlock(userId: string) {
|
|||||||
return redis.get(key);
|
return redis.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function incrementUserBlock(userId: string) {
|
||||||
|
const key = `user:block:${userId}`;
|
||||||
|
return redis.incr(key);
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
fetchWebsite,
|
fetchWebsite,
|
||||||
storeWebsite,
|
storeWebsite,
|
||||||
@ -65,5 +70,6 @@ export default {
|
|||||||
storeSession,
|
storeSession,
|
||||||
deleteSession,
|
deleteSession,
|
||||||
fetchUserBlock,
|
fetchUserBlock,
|
||||||
|
incrementUserBlock,
|
||||||
enabled: redis.enabled,
|
enabled: redis.enabled,
|
||||||
};
|
};
|
||||||
|
@ -99,6 +99,8 @@ export async function findSession(req: NextApiRequestCollect) {
|
|||||||
|
|
||||||
async function checkUserBlock(userId: string) {
|
async function checkUserBlock(userId: string) {
|
||||||
if (process.env.ENABLE_BLOCKER && (await cache.fetchUserBlock(userId))) {
|
if (process.env.ENABLE_BLOCKER && (await cache.fetchUserBlock(userId))) {
|
||||||
|
await cache.incrementUserBlock(userId);
|
||||||
|
|
||||||
throw new Error('Usage Limit.');
|
throw new Error('Usage Limit.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user