style: apply prettier formatting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,9 +12,7 @@ export function addMember(row: AgentGroupMember): void {
|
||||
}
|
||||
|
||||
export function removeMember(userId: string, agentGroupId: string): void {
|
||||
getDb()
|
||||
.prepare('DELETE FROM agent_group_members WHERE user_id = ? AND agent_group_id = ?')
|
||||
.run(userId, agentGroupId);
|
||||
getDb().prepare('DELETE FROM agent_group_members WHERE user_id = ? AND agent_group_id = ?').run(userId, agentGroupId);
|
||||
}
|
||||
|
||||
export function getMembers(agentGroupId: string): AgentGroupMember[] {
|
||||
|
||||
@@ -269,7 +269,9 @@ describe('messaging group agents', () => {
|
||||
});
|
||||
createMessagingGroupAgent({ ...mga(), id: 'mga-2', messaging_group_id: 'mg-2' });
|
||||
|
||||
const dests = getDestinations('ag-1').map((d) => d.local_name).sort();
|
||||
const dests = getDestinations('ag-1')
|
||||
.map((d) => d.local_name)
|
||||
.sort();
|
||||
expect(dests).toEqual(['gen', 'gen-2']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,9 +14,9 @@ export function upsertUserDm(row: UserDm): void {
|
||||
}
|
||||
|
||||
export function getUserDm(userId: string, channelType: string): UserDm | undefined {
|
||||
return getDb()
|
||||
.prepare('SELECT * FROM user_dms WHERE user_id = ? AND channel_type = ?')
|
||||
.get(userId, channelType) as UserDm | undefined;
|
||||
return getDb().prepare('SELECT * FROM user_dms WHERE user_id = ? AND channel_type = ?').get(userId, channelType) as
|
||||
| UserDm
|
||||
| undefined;
|
||||
}
|
||||
|
||||
export function getUserDmsForUser(userId: string): UserDm[] {
|
||||
|
||||
@@ -19,12 +19,7 @@ import {
|
||||
getSession,
|
||||
createPendingApproval,
|
||||
} from './db/sessions.js';
|
||||
import {
|
||||
getAgentGroup,
|
||||
createAgentGroup,
|
||||
updateAgentGroup,
|
||||
getAgentGroupByFolder,
|
||||
} from './db/agent-groups.js';
|
||||
import { getAgentGroup, createAgentGroup, updateAgentGroup, getAgentGroupByFolder } from './db/agent-groups.js';
|
||||
import { createDestination, getDestinationByName, hasDestination, normalizeName } from './db/agent-destinations.js';
|
||||
import { getMessagingGroup, getMessagingGroupByPlatform } from './db/messaging-groups.js';
|
||||
import { pickApprovalDelivery, pickApprover } from './access.js';
|
||||
@@ -382,9 +377,7 @@ async function deliverMessage(
|
||||
if (msg.channel_type && msg.platform_id) {
|
||||
const mg = getMessagingGroupByPlatform(msg.channel_type, msg.platform_id);
|
||||
if (!mg) {
|
||||
throw new Error(
|
||||
`unknown messaging group for ${msg.channel_type}/${msg.platform_id} (message ${msg.id})`,
|
||||
);
|
||||
throw new Error(`unknown messaging group for ${msg.channel_type}/${msg.platform_id} (message ${msg.id})`);
|
||||
}
|
||||
const isOriginChat = session.messaging_group_id === mg.id;
|
||||
if (!isOriginChat && !hasDestination(session.agent_group_id, 'channel', mg.id)) {
|
||||
|
||||
@@ -208,10 +208,7 @@ function extractAndUpsertUser(event: InboundEvent): string | null {
|
||||
return userId;
|
||||
}
|
||||
|
||||
function enforceAccess(
|
||||
userId: string | null,
|
||||
agentGroupId: string,
|
||||
): { allowed: boolean; reason: string } {
|
||||
function enforceAccess(userId: string | null, agentGroupId: string): { allowed: boolean; reason: string } {
|
||||
if (!userId) return { allowed: false, reason: 'unknown_user' };
|
||||
const decision = canAccessAgentGroup(userId, agentGroupId);
|
||||
if (decision.allowed) return { allowed: true, reason: decision.reason };
|
||||
|
||||
Reference in New Issue
Block a user