Skip to content

Commit c71e56d

Browse files
committed
update private channel attachment message & allow google drive attachments in private channels
1 parent 07942d5 commit c71e56d

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const nerimitySupporterCdnMessage = 'To ensure a safe and verified environment, sending attachments in private channels requires a [Nerimity supporter badge](https://nerimity.com/app/settings/badges).';

src/routes/channels/ChannelCdnGenerateToken.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { channelVerification } from '@src/middleware/channelVerification';
77
import { hasBit, USER_BADGES } from '@src/common/Bitwise';
88
import { ServerCache } from '@src/cache/ServerCache';
99
import { ChannelType } from '@src/types/Channel';
10+
import { nerimitySupporterCdnMessage } from '@src/common/nerimitySupporterCdnMessage';
1011

1112
export function ChannelCdnGenerateToken(Router: Router) {
1213
Router.post(
@@ -28,12 +29,12 @@ async function route(req: Request, res: Response) {
2829
const isServerNotPublicAndNotSupporter = req.serverCache && !isServerPublic(req.serverCache) && !isSupporterOrModerator(req.userCache);
2930

3031
if (!isMod && isServerNotPublicAndNotSupporter) {
31-
return res.status(400).json(generateError('You must be a Nerimity supporter to send attachment messages to a private server.'));
32+
return res.status(400).json(generateError(nerimitySupporterCdnMessage));
3233
}
3334
const isPrivateChannelAndNotSupporter = req.channelCache.type === ChannelType.SERVER_TEXT && !req.channelCache.canBePublic && !isSupporterOrModerator(req.userCache);
3435

3536
if (!isMod && isPrivateChannelAndNotSupporter) {
36-
return res.status(400).json(generateError('You must be a Nerimity supporter to send attachment messages to a private channel.'));
37+
return res.status(400).json(generateError(nerimitySupporterCdnMessage));
3738
}
3839

3940
const [genRes, error] = await generateToken({

src/routes/channels/channelMessageCreate.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { checkAndUpdateRateLimit } from '../../cache/RateLimitCache';
2424
import { ServerMemberCache } from '../../cache/ServerMemberCache';
2525
import env from '../../common/env';
2626
import { generateId } from '../../common/flakeId';
27+
import { nerimitySupporterCdnMessage } from '@src/common/nerimitySupporterCdnMessage';
2728

2829
export function channelMessageCreate(Router: Router) {
2930
Router.post(
@@ -187,17 +188,19 @@ async function route(req: Request, res: Response) {
187188
return res.status(400).json(generateError('You must confirm your email to send attachment messages.'));
188189
}
189190

190-
const isMod = hasBit(req.userCache.badges, USER_BADGES.MOD.bit);
191+
if (body.nerimityCdnFileId) {
192+
const isMod = hasBit(req.userCache.badges, USER_BADGES.MOD.bit);
191193

192-
const isServerNotPublicAndNotSupporter = req.serverCache && !isServerPublic(req.serverCache) && !isSupporterOrModerator(req.userCache);
194+
const isServerNotPublicAndNotSupporter = req.serverCache && !isServerPublic(req.serverCache) && !isSupporterOrModerator(req.userCache);
193195

194-
if (!isMod && isServerNotPublicAndNotSupporter) {
195-
return res.status(400).json(generateError('You must be a Nerimity supporter to send attachment messages to a private server.'));
196-
}
197-
const isPrivateChannelAndNotSupporter = req.channelCache.type === ChannelType.SERVER_TEXT && !req.channelCache.canBePublic && !isSupporterOrModerator(req.userCache);
196+
if (!isMod && isServerNotPublicAndNotSupporter) {
197+
return res.status(400).json(generateError(nerimitySupporterCdnMessage));
198+
}
199+
const isPrivateChannelAndNotSupporter = req.channelCache.type === ChannelType.SERVER_TEXT && !req.channelCache.canBePublic && !isSupporterOrModerator(req.userCache);
198200

199-
if (!isMod && isPrivateChannelAndNotSupporter) {
200-
return res.status(400).json(generateError('You must be a Nerimity supporter to send attachment messages to a private channel.'));
201+
if (!isMod && isPrivateChannelAndNotSupporter) {
202+
return res.status(400).json(generateError(nerimitySupporterCdnMessage));
203+
}
201204
}
202205
}
203206

0 commit comments

Comments
 (0)