Skip to content

Commit 2193303

Browse files
authored
Merge pull request #2401 from trycompai/main
[comp] Production Deploy
2 parents 116cf79 + 70398e4 commit 2193303

6 files changed

Lines changed: 40 additions & 24 deletions

File tree

apps/api/src/trigger/browser-automation/run-browser-automation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ async function sendTaskStatusChangeEmails(params: {
4646
where: {
4747
organizationId,
4848
deactivated: false,
49+
user: { role: { not: 'admin' } },
4950
},
5051
select: {
5152
role: true,
@@ -113,6 +114,7 @@ async function sendTaskStatusChangeEmails(params: {
113114
db,
114115
recipient.email,
115116
'taskAssignments',
117+
organizationId,
116118
);
117119

118120
if (isUnsubscribed) {

apps/api/src/trigger/integration-platform/run-task-integration-checks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async function sendTaskStatusChangeEmails(params: {
4444
where: {
4545
organizationId,
4646
deactivated: false,
47+
user: { role: { not: 'admin' } },
4748
},
4849
select: {
4950
role: true,
@@ -111,6 +112,7 @@ async function sendTaskStatusChangeEmails(params: {
111112
db,
112113
recipient.email,
113114
'taskAssignments',
115+
organizationId,
114116
);
115117

116118
if (isUnsubscribed) {

packages/email/lib/check-unsubscribe.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,9 @@ export async function isUserUnsubscribed(
117117
return false;
118118
}
119119

120-
// Platform admins only receive notifications for organizations they own
120+
// Platform admins never receive email notifications
121121
if (user.role === 'admin') {
122-
if (!organizationId || !db.member) {
123-
return true; // No org context — block notifications
124-
}
125-
const adminMemberRecords = await db.member.findMany({
126-
where: {
127-
organizationId,
128-
user: { email },
129-
deactivated: false,
130-
},
131-
select: { role: true },
132-
});
133-
const adminRoles = adminMemberRecords.flatMap((m) =>
134-
m.role.split(',').map((r) => r.trim()),
135-
);
136-
if (!adminRoles.includes('owner')) {
137-
return true; // Not an owner in this org — block notifications
138-
}
139-
// Platform admin IS an owner — fall through to normal notification logic
122+
return true;
140123
}
141124

142125
// If legacy all-or-nothing flag is set, user is unsubscribed from everything

packages/integration-platform/src/manifests/google-workspace/checks/employee-access.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ export const employeeAccessCheck: IntegrationCheck = {
127127

128128
ctx.log(`Fetched ${allUsers.length} total users`);
129129

130+
if (userFilterConfig.targetOrgUnits?.length) {
131+
const ouCounts = new Map<string, number>();
132+
for (const user of allUsers) {
133+
const ou = user.orgUnitPath ?? '/';
134+
ouCounts.set(ou, (ouCounts.get(ou) ?? 0) + 1);
135+
}
136+
ctx.log(
137+
`Filtering to OUs: ${userFilterConfig.targetOrgUnits.join(', ')}. ` +
138+
`User OUs: ${[...ouCounts.entries()].map(([ou, count]) => `${ou} (${count})`).join(', ')}`,
139+
);
140+
}
141+
130142
// Same rules as 2FA check and employee sync (sync.controller.ts)
131143
const activeUsers = filterGoogleWorkspaceUsersForChecks(allUsers, userFilterConfig);
132144

packages/integration-platform/src/manifests/google-workspace/checks/two-factor-auth.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ export const twoFactorAuthCheck: IntegrationCheck = {
5151

5252
ctx.log(`Fetched ${allUsers.length} total users`);
5353

54+
if (userFilterConfig.targetOrgUnits?.length) {
55+
const ouCounts = new Map<string, number>();
56+
for (const user of allUsers) {
57+
const ou = user.orgUnitPath ?? '/';
58+
ouCounts.set(ou, (ouCounts.get(ou) ?? 0) + 1);
59+
}
60+
ctx.log(
61+
`Filtering to OUs: ${userFilterConfig.targetOrgUnits.join(', ')}. ` +
62+
`User OUs: ${[...ouCounts.entries()].map(([ou, count]) => `${ou} (${count})`).join(', ')}`,
63+
);
64+
}
65+
5466
// Org units + sync email filter — same rules as employee sync (sync.controller.ts)
5567
const usersToCheck = filterGoogleWorkspaceUsersForChecks(allUsers, userFilterConfig);
5668

packages/integration-platform/src/manifests/google-workspace/variables.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@ export const targetOrgUnitsVariable: CheckVariable = {
1717
'/admin/directory/v1/customer/my_customer/orgunits?type=all',
1818
);
1919

20+
const rootOption = { value: '/', label: '/ (Root)' };
21+
2022
if (!response.organizationUnits) {
21-
return [{ value: '/', label: '/ (Root)' }];
23+
return [rootOption];
2224
}
2325

24-
return response.organizationUnits.map((ou) => ({
25-
value: ou.orgUnitPath,
26-
label: `${ou.orgUnitPath} (${ou.name})`,
27-
}));
26+
return [
27+
rootOption,
28+
...response.organizationUnits.map((ou) => ({
29+
value: ou.orgUnitPath,
30+
label: `${ou.orgUnitPath} (${ou.name})`,
31+
})),
32+
];
2833
} catch {
2934
return [{ value: '/', label: '/ (Root)' }];
3035
}

0 commit comments

Comments
 (0)