mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat: add accept invite
This commit is contained in:
@@ -438,6 +438,18 @@ export class DataCenter {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* accept invitation
|
||||
* @param {string} inviteCode
|
||||
*/
|
||||
async acceptInvitation(inviteCode: string, providerStr = 'affine') {
|
||||
const provider = this.providerMap.get(providerStr);
|
||||
if (provider) {
|
||||
return await provider.acceptInvitation(inviteCode);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
onMessage(cb: (message: Message) => void) {
|
||||
return this._messageCenter.onMessage(cb);
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ export class AffineProvider extends BaseProvider {
|
||||
ws_details: Record<string, WorkspaceDetail>;
|
||||
metadata: Record<string, { avatar: string; name: string }>;
|
||||
}) {
|
||||
this._logger('receive server message');
|
||||
Object.entries(ws_details).forEach(([id, detail]) => {
|
||||
const { name, avatar } = metadata[id];
|
||||
assert(name);
|
||||
@@ -442,4 +443,8 @@ export class AffineProvider extends BaseProvider {
|
||||
public override async getWorkspaceMembers(id: string) {
|
||||
return this._apis.getWorkspaceMembers({ id });
|
||||
}
|
||||
|
||||
public override async acceptInvitation(invitingCode: string): Promise<void> {
|
||||
await this._apis.acceptInviting({ invitingCode });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,4 +233,14 @@ export class BaseProvider {
|
||||
workspaceId;
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* accept invitation
|
||||
* @param {string} inviteCode
|
||||
* @returns
|
||||
*/
|
||||
public async acceptInvitation(inviteCode: string): Promise<void> {
|
||||
inviteCode;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user