관리자 승인과 사용자 OAuth 증명을 분리하고 기존 Kakao stable ID를 영구 폐기한다. 로그인 ID와 닉네임 변경은 현재 장수에 revision 기반으로 투영하며 과거 기록은 당시 이름으로 보존한다.
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { isCanonicalIsoTimestamp } from '@sammo-ts/common';
|
|
|
|
import type { GatewayUserFlushEvent } from '../auth/flushStore.js';
|
|
import type { TurnDaemonTransport } from '../daemon/transport.js';
|
|
|
|
export const enqueueAccountIdentityForUser = async (
|
|
turnDaemon: TurnDaemonTransport,
|
|
userId: string,
|
|
displayName: string,
|
|
identityRevision: string
|
|
): Promise<void> => {
|
|
await turnDaemon.sendCommand({
|
|
type: 'adjustGeneralIdentity',
|
|
requestId: `general:adjustIdentity:${userId}:${identityRevision}`,
|
|
userId,
|
|
displayName,
|
|
identityRevision,
|
|
});
|
|
};
|
|
|
|
export const createAccountIdentityFlushHandler =
|
|
(turnDaemon: TurnDaemonTransport) =>
|
|
async (event: GatewayUserFlushEvent): Promise<void> => {
|
|
if (event.reason !== 'admin-account-identity-updated') return;
|
|
if (!event.displayName || !event.identityRevision || !isCanonicalIsoTimestamp(event.identityRevision)) return;
|
|
await enqueueAccountIdentityForUser(turnDaemon, event.userId, event.displayName, event.identityRevision);
|
|
};
|