make dialog announcement cap configurable
This commit is contained in:
parent
4926afc264
commit
5364e8da26
5 changed files with 15 additions and 2 deletions
|
|
@ -250,6 +250,8 @@ id: 'aidx'
|
|||
#maxAltTextLength: 20000
|
||||
# Amount of characters that will be saved for remote media descriptions (alt text). Longer descriptions will be truncated to this length. (minimum: 1)
|
||||
#maxRemoteAltTextLength: 100000
|
||||
# Amount of dialog-style announcements that can be active at a time. (minimum: 1)
|
||||
#maxDialogAnnouncements: 5
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
#proxy: http://127.0.0.1:3128
|
||||
|
|
|
|||
|
|
@ -345,6 +345,8 @@ id: 'aidx'
|
|||
#maxBioLength: 1500
|
||||
# Amount of characters that will be saved for remote user bios. Longer descriptions will be truncated to this length. (minimum: 1)
|
||||
#maxRemoteBioLength: 15000
|
||||
# Amount of dialog-style announcements that can be active at a time. (minimum: 1)
|
||||
#maxDialogAnnouncements: 5
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
#proxy: http://127.0.0.1:3128
|
||||
|
|
|
|||
|
|
@ -348,6 +348,8 @@ id: 'aidx'
|
|||
#maxBioLength: 1500
|
||||
# Amount of characters that will be saved for remote user bios. Longer descriptions will be truncated to this length. (minimum: 1)
|
||||
#maxRemoteBioLength: 15000
|
||||
# Amount of dialog-style announcements that can be active at a time. (minimum: 1)
|
||||
#maxDialogAnnouncements: 5
|
||||
|
||||
# Proxy for HTTP/HTTPS
|
||||
#proxy: http://127.0.0.1:3128
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ type Source = {
|
|||
maxRemoteAltTextLength?: number;
|
||||
maxBioLength?: number;
|
||||
maxRemoteBioLength?: number;
|
||||
maxDialogAnnouncements?: number;
|
||||
|
||||
clusterLimit?: number;
|
||||
|
||||
|
|
@ -265,6 +266,7 @@ export type Config = {
|
|||
maxRemoteAltTextLength: number;
|
||||
maxBioLength: number;
|
||||
maxRemoteBioLength: number;
|
||||
maxDialogAnnouncements: number;
|
||||
clusterLimit: number | undefined;
|
||||
id: string;
|
||||
outgoingAddress: string | undefined;
|
||||
|
|
@ -467,6 +469,7 @@ export function loadConfig(): Config {
|
|||
maxRemoteAltTextLength: config.maxRemoteAltTextLength ?? 100000,
|
||||
maxBioLength: config.maxBioLength ?? 1500,
|
||||
maxRemoteBioLength: config.maxRemoteBioLength ?? 15000,
|
||||
maxDialogAnnouncements: config.maxDialogAnnouncements ?? 5,
|
||||
clusterLimit: config.clusterLimit,
|
||||
outgoingAddress: config.outgoingAddress,
|
||||
outgoingAddressFamily: config.outgoingAddressFamily,
|
||||
|
|
@ -664,7 +667,7 @@ function applyEnvOverrides(config: Source) {
|
|||
_apply_top(['sentryForFrontend', 'browserTracingIntegration', 'routeLabel']);
|
||||
_apply_top([['clusterLimit', 'deliverJobConcurrency', 'inboxJobConcurrency', 'relashionshipJobConcurrency', 'deliverJobPerSec', 'inboxJobPerSec', 'relashionshipJobPerSec', 'deliverJobMaxAttempts', 'inboxJobMaxAttempts']]);
|
||||
_apply_top([['outgoingAddress', 'outgoingAddressFamily', 'proxy', 'proxySmtp', 'mediaDirectory', 'mediaProxy', 'proxyRemoteFiles', 'videoThumbnailGenerator']]);
|
||||
_apply_top([['maxFileSize', 'maxNoteLength', 'maxRemoteNoteLength', 'maxAltTextLength', 'maxRemoteAltTextLength', 'maxBioLength', 'maxRemoteBioLength', 'pidFile', 'filePermissionBits']]);
|
||||
_apply_top([['maxFileSize', 'maxNoteLength', 'maxRemoteNoteLength', 'maxAltTextLength', 'maxRemoteAltTextLength', 'maxBioLength', 'maxRemoteBioLength', 'maxDialogAnnouncements', 'pidFile', 'filePermissionBits']]);
|
||||
_apply_top(['import', ['downloadTimeout', 'maxFileSize']]);
|
||||
_apply_top([['signToActivityPubGet', 'checkActivityPubGetSignature', 'setupPassword', 'disallowExternalApRedirect']]);
|
||||
_apply_top(['logging', 'sql', ['disableQueryTruncation', 'enableQueryParamLogging']]);
|
||||
|
|
|
|||
|
|
@ -15,10 +15,14 @@ import { AnnouncementEntityService } from '@/core/entities/AnnouncementEntitySer
|
|||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import type { Config } from '@/config.js';
|
||||
|
||||
@Injectable()
|
||||
export class AnnouncementService {
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
private config: Config,
|
||||
|
||||
@Inject(DI.announcementsRepository)
|
||||
private announcementsRepository: AnnouncementsRepository,
|
||||
|
||||
|
|
@ -241,7 +245,7 @@ export class AnnouncementService {
|
|||
display: 'dialog',
|
||||
})
|
||||
.getCount();
|
||||
if (dialogCount >= 5) {
|
||||
if (dialogCount >= this.config.maxDialogAnnouncements) {
|
||||
throw new IdentifiableError('c0d15f15-f18e-4a40-bcb1-f310d58204ee', 'Too many dialog announcements.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue