Skip to content

Commit f460845

Browse files
fix(mothership): ban-check the workspace billed account on inbox tasks
1 parent 5e5c03e commit f460845

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

apps/sim/lib/mothership/inbox/executor.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { buildUserSkillTool } from '@/lib/mothership/skills'
2525
import { uploadFile } from '@/lib/uploads/core/storage-service'
2626
import { createFileContent, type MessageContent } from '@/lib/uploads/utils/file-utils'
2727
import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils'
28+
import { getWorkspaceBilledAccountUserId } from '@/lib/workspaces/utils'
2829

2930
const logger = createLogger('InboxExecutor')
3031

@@ -96,20 +97,25 @@ export async function executeInboxTask(taskId: string): Promise<void> {
9697

9798
// Blocked senders and banned accounts must not drive the agent; the sender
9899
// email is checked directly (domain list + the sender's own account ban)
99-
// because non-members resolve to the workspace owner. Fails closed on
100-
// lookup errors. No email response in any of these paths — never mail a
101-
// suspended account.
100+
// because non-members resolve to the workspace owner, and the workspace
101+
// billed account is checked to match preprocessExecution's gate. Fails
102+
// closed on lookup errors. No email response in any of these paths —
103+
// never mail a suspended account.
102104
let blockReason: string | null = null
103105
try {
104-
const [senderBlocked, [bannedUserId]] = await Promise.all([
106+
const [senderBlocked, billedAccountUserId] = await Promise.all([
105107
isEmailBlocked(inboxTask.fromEmail),
106-
getActivelyBannedUserIds([userId]),
108+
getWorkspaceBilledAccountUserId(ws.id),
107109
])
108-
if (senderBlocked || bannedUserId) {
109-
logger.warn('Blocking inbox task: sender or resolved user is banned', {
110+
const bannedUserIds = await getActivelyBannedUserIds(
111+
billedAccountUserId ? [userId, billedAccountUserId] : [userId]
112+
)
113+
if (senderBlocked || bannedUserIds.length > 0) {
114+
logger.warn('Blocking inbox task: sender, resolved user, or billed account is banned', {
110115
taskId,
111116
userId,
112117
senderBlocked,
118+
bannedUserIds,
113119
})
114120
blockReason = 'User account is suspended'
115121
}

0 commit comments

Comments
 (0)