fix: provide user info for copilot (#6606)

This commit is contained in:
Peng Xiao 2024-04-18 11:10:17 +08:00 committed by GitHub
parent ccb3bed91e
commit 10653eccbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
import { apis } from '@affine/electron-api';
import type { OAuthProviderType } from '@affine/graphql';
import { AIProvider } from '@blocksuite/presets';
import {
ApplicationFocused,
ApplicationStarted,
@ -34,6 +35,17 @@ export class AuthService extends Service {
) {
super();
AIProvider.provide('userInfo', () => {
const account = this.session.account$.value;
if (!account) return null;
return {
avatarUrl: account.avatar ?? '',
email: account.email ?? '',
id: account.id,
name: account.label,
};
});
this.session.account$
.pipe(
map(a => ({