fix(api): exempt bots from being considered unclaimed users (#45)
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
@@ -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};
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user