mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
fix(api): SSO discovery, channel create and deleted bots (#3390)
This commit is contained in:
1 parent
edc913096a
commit
0967bf3136
17 files changed
+508
-156
No files matched your search
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type {ChannelID, GuildID, UserID} from '@app/api/BrandedTypes';
|
||||
import {type ChannelID, createChannelID, type GuildID, type UserID} from '@app/api/BrandedTypes';
|
||||
import {mapChannelToResponse} from '@app/api/channel/ChannelMappers';
|
||||
import type {ChannelRepository} from '@app/api/channel/ChannelRepository';
|
||||
import {withThreadParentFieldsMany} from '@app/api/channel/services/thread/ThreadParentSettings';
|
||||
@@ -112,6 +112,7 @@ export class GuildChannelService {
|
||||
userId: params.userId,
|
||||
guildId: params.guildId,
|
||||
permission: Permissions.MANAGE_CHANNELS,
|
||||
channelId: params.data.parent_id ? createChannelID(params.data.parent_id) : undefined,
|
||||
});
|
||||
const response = await this.channelOps.createChannel(params, auditLogReason);
|
||||
const [masked] = await maskChannelResponseThreadBits(params.guildId, params.viewer, [response]);
|
||||
@@ -155,11 +156,17 @@ export class GuildChannelService {
|
||||
await this.channelOps.sanitizeTextChannelNames(params);
|
||||
}
|
||||
|
||||
private async checkPermission(params: {userId: UserID; guildId: GuildID; permission: bigint}): Promise<void> {
|
||||
private async checkPermission(params: {
|
||||
userId: UserID;
|
||||
guildId: GuildID;
|
||||
permission: bigint;
|
||||
channelId?: ChannelID;
|
||||
}): Promise<void> {
|
||||
const hasPermission = await this.gatewayService.checkPermission({
|
||||
guildId: params.guildId,
|
||||
userId: params.userId,
|
||||
permission: params.permission,
|
||||
channelId: params.channelId,
|
||||
});
|
||||
if (!hasPermission) throw new MissingPermissionsError();
|
||||
const guildData = await this.gatewayService.getGuildData({guildId: params.guildId, userId: params.userId});
|
||||
|
||||
@@ -104,6 +104,7 @@ export class ChannelOperationsService {
|
||||
guildId: params.guildId,
|
||||
userId: params.userId,
|
||||
permission: Permissions.MANAGE_ROLES,
|
||||
channelId: parentId ?? undefined,
|
||||
});
|
||||
if (!canManageRoles) throw new MissingPermissionsError();
|
||||
const basePermissions = await this.gatewayService.getUserPermissions({
|
||||
@@ -736,6 +737,7 @@ export class ChannelOperationsService {
|
||||
ctx,
|
||||
'max_channels_per_category',
|
||||
maxChannels,
|
||||
'guild',
|
||||
);
|
||||
if (count >= maxChannels) {
|
||||
throw new MaxCategoryChannelsError(maxChannels);
|
||||
@@ -747,7 +749,13 @@ export class ChannelOperationsService {
|
||||
let maxChannels = MAX_GUILD_CHANNELS;
|
||||
const guild = await this.guildRepository.findUnique(guildId);
|
||||
const ctx = createLimitMatchContext({user: null, guildFeatures: guild?.features ?? null});
|
||||
maxChannels = resolveLimitSafe(this.limitConfigService.getConfigSnapshot(), ctx, 'max_guild_channels', maxChannels);
|
||||
maxChannels = resolveLimitSafe(
|
||||
this.limitConfigService.getConfigSnapshot(),
|
||||
ctx,
|
||||
'max_guild_channels',
|
||||
maxChannels,
|
||||
'guild',
|
||||
);
|
||||
if (count >= maxChannels) {
|
||||
throw new MaxGuildChannelsError(maxChannels);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user