forked from EduCraft/curriculum-project-hub
feat: archive bindings on Feishu lifecycle events
This commit is contained in:
@@ -66,7 +66,7 @@ export async function upsertScopedFeishuIdentityInTransaction(
|
||||
const principalId = scopedFeishuPrincipalId("USER", connectionId, openId);
|
||||
const userId = deterministicFeishuUserId(connectionId, openId);
|
||||
|
||||
const connection = await lockActiveConnection(prisma, connectionId);
|
||||
const connection = await requireActiveFeishuApplicationConnectionInTransaction(prisma, connectionId);
|
||||
if (input.expectedOrganizationId !== undefined &&
|
||||
input.expectedOrganizationId !== connection.organizationId) {
|
||||
throw new Error("Feishu identity Organization scope mismatch");
|
||||
@@ -114,7 +114,7 @@ export async function resolveScopedFeishuIdentity(
|
||||
const connectionId = nonEmpty(input.connectionId, "Feishu connectionId");
|
||||
const openId = nonEmpty(input.openId, "Feishu openId");
|
||||
return prisma.$transaction(async (tx) => {
|
||||
const connection = await lockActiveConnection(tx, connectionId);
|
||||
const connection = await requireActiveFeishuApplicationConnectionInTransaction(tx, connectionId);
|
||||
if (input.expectedOrganizationId !== undefined &&
|
||||
input.expectedOrganizationId !== connection.organizationId) {
|
||||
throw new Error("Feishu identity Organization scope mismatch");
|
||||
@@ -127,7 +127,12 @@ export async function resolveScopedFeishuIdentity(
|
||||
});
|
||||
}
|
||||
|
||||
async function lockActiveConnection(
|
||||
/**
|
||||
* Lock and prove that a Feishu application connection is currently usable.
|
||||
* Callers handling provider-originated data use this before trusting a
|
||||
* connection-scoped identifier.
|
||||
*/
|
||||
export async function requireActiveFeishuApplicationConnectionInTransaction(
|
||||
prisma: Prisma.TransactionClient,
|
||||
connectionId: string,
|
||||
): Promise<{ readonly organizationId: string }> {
|
||||
|
||||
Reference in New Issue
Block a user