feat: vacation mode & hide counters
This commit is contained in:
parent
c2a7ae59e8
commit
fa0e7f6413
19 changed files with 314 additions and 95 deletions
|
@ -310,7 +310,7 @@ export class ApiCallService implements OnApplicationShutdown {
|
|||
}
|
||||
}
|
||||
|
||||
if ((ep.meta.requireModerator || ep.meta.requireAdmin) && !user!.isRoot) {
|
||||
if (ep.meta.requireModerator || ep.meta.requireAdmin) {
|
||||
const myRoles = await this.roleService.getUserRoles(user!.id);
|
||||
const isModerator = myRoles.some(r => r.isModerator || r.isAdministrator);
|
||||
const isAdmin = myRoles.some(r => r.isAdministrator);
|
||||
|
@ -324,6 +324,14 @@ export class ApiCallService implements OnApplicationShutdown {
|
|||
id: 'abce13fe-1d9f-4e85-8f00-4a5251155470',
|
||||
});
|
||||
}
|
||||
if (user?.isVacation) {
|
||||
throw new ApiError({
|
||||
message: 'You are on vacation.',
|
||||
code: 'VACATION_MODE',
|
||||
kind: 'permission',
|
||||
id: 'bbe5ef78-fab6-46a2-9e29-64639747096c',
|
||||
});
|
||||
}
|
||||
if (ep.meta.requireModerator && !isModerator) {
|
||||
throw new ApiError({
|
||||
message: 'You are not assigned to a proper role.',
|
||||
|
|
|
@ -28,12 +28,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
constructor(
|
||||
private cacheService: CacheService,
|
||||
private apDbResolverService: ApDbResolverService,
|
||||
private authenticateService: AuthenticateService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
this.cacheService.dispose();
|
||||
this.apDbResolverService.dispose();
|
||||
this.authenticateService.dispose()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,6 +187,7 @@ export const paramDef = {
|
|||
preventAiLearning: { type: 'boolean' },
|
||||
isBot: { type: 'boolean' },
|
||||
isCat: { type: 'boolean' },
|
||||
isVacation: { type: 'boolean' },
|
||||
injectFeaturedNote: { type: 'boolean' },
|
||||
receiveAnnouncementEmail: { type: 'boolean' },
|
||||
alwaysMarkNsfw: { type: 'boolean' },
|
||||
|
@ -341,6 +342,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (typeof ps.noCrawle === 'boolean') profileUpdates.noCrawle = ps.noCrawle;
|
||||
if (typeof ps.preventAiLearning === 'boolean') profileUpdates.preventAiLearning = ps.preventAiLearning;
|
||||
if (typeof ps.isCat === 'boolean') updates.isCat = ps.isCat;
|
||||
if (typeof ps.isVacation === 'boolean') updates.isVacation = ps.isVacation;
|
||||
if (typeof ps.injectFeaturedNote === 'boolean') profileUpdates.injectFeaturedNote = ps.injectFeaturedNote;
|
||||
if (typeof ps.receiveAnnouncementEmail === 'boolean') profileUpdates.receiveAnnouncementEmail = ps.receiveAnnouncementEmail;
|
||||
if (typeof ps.alwaysMarkNsfw === 'boolean') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue