fix(api): exempt bots from being considered unclaimed users (#45)

This commit is contained in:
hampus-fluxer
2026-01-06 03:45:28 +01:00
committed by GitHub
parent 1cef2290fe
commit 6f21a7e37b
17 changed files with 45 additions and 51 deletions

View File

@@ -306,7 +306,7 @@ export const MessageController = (app: HonoApp) => {
const channelId = createChannelID(ctx.req.valid('param').channel_id);
const requestCache = ctx.get('requestCache');
if (!user.passwordHash && !isPersonalNotesChannel({userId: user.id, channelId})) {
if (user.isUnclaimedAccount() && !isPersonalNotesChannel({userId: user.id, channelId})) {
throw new UnclaimedAccountRestrictedError('send messages');
}

View File

@@ -166,7 +166,7 @@ export const MessageInteractionController = (app: HonoApp) => {
const sessionId = ctx.req.valid('query').session_id;
const requestCache = ctx.get('requestCache');
if (!user.passwordHash && !isPersonalNotesChannel({userId: user.id, channelId})) {
if (user.isUnclaimedAccount() && !isPersonalNotesChannel({userId: user.id, channelId})) {
throw new UnclaimedAccountRestrictedError('add reactions');
}

View File

@@ -73,7 +73,7 @@ export class CallService {
}
const caller = await this.userRepository.findUnique(userId);
const isUnclaimedCaller = caller != null && !caller.passwordHash && !caller.isBot;
const isUnclaimedCaller = caller?.isUnclaimedAccount() ?? false;
if (isUnclaimedCaller && channel.type === ChannelTypes.DM) {
return {ringable: false};
}

View File

@@ -35,17 +35,13 @@ export class DMPermissionValidator {
async validate({recipients, userId}: {recipients: Array<User>; userId: UserID}): Promise<void> {
const senderUser = await this.deps.userRepository.findUnique(userId);
if (senderUser && !senderUser.passwordHash && !senderUser.isBot) {
if (senderUser && senderUser.isUnclaimedAccount()) {
throw new UnclaimedAccountRestrictedError('send direct messages');
}
const targetUser = recipients.find((recipient) => recipient.id !== userId);
if (!targetUser) return;
if (!targetUser.passwordHash && !targetUser.isBot) {
throw new UnclaimedAccountRestrictedError('receive direct messages');
}
const senderBlockedTarget = await this.deps.userRepository.getRelationship(
userId,
targetUser.id,