MCPcopy Index your code
hub / github.com/simstudioai/sim / isSenderAllowed

Function isSenderAllowed

apps/sim/app/api/webhooks/agentmail/route.ts:285–312  ·  view source on GitHub ↗
(email: string, workspaceId: string)

Source from the content-addressed store, hash-verified

283})
284
285async function isSenderAllowed(email: string, workspaceId: string): Promise<boolean> {
286 const [allowedSenderResult, memberResult] = await Promise.all([
287 db
288 .select({ id: mothershipInboxAllowedSender.id })
289 .from(mothershipInboxAllowedSender)
290 .where(
291 and(
292 eq(mothershipInboxAllowedSender.workspaceId, workspaceId),
293 eq(mothershipInboxAllowedSender.email, email)
294 )
295 )
296 .limit(1),
297 db
298 .select({ userId: permissions.userId })
299 .from(permissions)
300 .innerJoin(user, eq(permissions.userId, user.id))
301 .where(
302 and(
303 eq(permissions.entityType, 'workspace'),
304 eq(permissions.entityId, workspaceId),
305 sql`lower(${user.email}) = ${email}`
306 )
307 )
308 .limit(1),
309 ])
310
311 return !!(allowedSenderResult[0] || memberResult[0])
312}
313
314async function getRecentTaskCount(workspaceId: string): Promise<number> {
315 const oneHourAgo = new Date(Date.now() - 60 * 60 * 1000)

Callers 1

route.tsFile · 0.85

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected