From 4e1592daa41f81667f914f37d36795e8c6c046c3 Mon Sep 17 00:00:00 2001 From: Ms Kimsible <1877318+kimsible@users.noreply.github.com> Date: Wed, 25 Aug 2021 11:38:10 +0200 Subject: Alert user for low quota and video auto-block on upload page (#4336) * Replace wording of instance contact * Add contact-us button to no-quota alert on upload page * Add alert for accounts with auto-blocked videos on upload page * Add alert for accounts without enough quota + refacto on upload page * Using ng-container and ng-template * Add alert for daily quota * Add hook filter for upload page alert messages * Add instance name as subtitle in contact modal * Fix eslint max-len on string * Fix missing word in quota left daily message - upload page Co-authored-by: Kimsible --- client/src/app/core/users/user.model.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'client/src/app/core') diff --git a/client/src/app/core/users/user.model.ts b/client/src/app/core/users/user.model.ts index 7d03e1c40..5e1fb1c8d 100644 --- a/client/src/app/core/users/user.model.ts +++ b/client/src/app/core/users/user.model.ts @@ -133,4 +133,30 @@ export class User implements UserServerModel { isUploadDisabled () { return this.videoQuota === 0 || this.videoQuotaDaily === 0 } + + isAutoBlocked () { + return this.role === UserRole.USER && this.adminFlags !== UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST + } + + hasNoQuotaLeft () { + // unlimited videoQuota + if (this.videoQuota === -1) return false + + // no more videoQuota + if (!this.videoQuotaUsed) return true + + // videoQuota left lower than 10% + return this.videoQuotaUsed > this.videoQuota * 0.9 + } + + hasNoQuotaLeftDaily () { + // unlimited videoQuotaDaily + if (this.videoQuotaDaily === -1) return false + + // no more videoQuotaDaily + if (!this.videoQuotaUsedDaily) return true + + // videoQuotaDaily left lower than 10% + return this.videoQuotaUsedDaily > this.videoQuotaDaily * 0.9 + } } -- cgit v1.2.3