mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Add increment to usage.
This commit is contained in:
parent
dc6da1e41f
commit
a3639d59a3
2 changed files with 8 additions and 0 deletions
|
|
@ -54,6 +54,11 @@ async function fetchUserBlock(userId: string) {
|
|||
return redis.get(key);
|
||||
}
|
||||
|
||||
async function incrementUserBlock(userId: string) {
|
||||
const key = `user:block:${userId}`;
|
||||
return redis.incr(key);
|
||||
}
|
||||
|
||||
export default {
|
||||
fetchWebsite,
|
||||
storeWebsite,
|
||||
|
|
@ -65,5 +70,6 @@ export default {
|
|||
storeSession,
|
||||
deleteSession,
|
||||
fetchUserBlock,
|
||||
incrementUserBlock,
|
||||
enabled: redis.enabled,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ export async function findSession(req: NextApiRequestCollect) {
|
|||
|
||||
async function checkUserBlock(userId: string) {
|
||||
if (process.env.ENABLE_BLOCKER && (await cache.fetchUserBlock(userId))) {
|
||||
await cache.incrementUserBlock(userId);
|
||||
|
||||
throw new Error('Usage Limit.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue