feat: fix access permission api

This commit is contained in:
MingLiang Wang 2023-01-12 18:13:44 +08:00
parent 0b623a522b
commit cf47098631
4 changed files with 16 additions and 12 deletions

View File

@ -416,13 +416,14 @@ export class DataCenter {
/**
* accept invitation
* @param {string} inviteCode
* @returns {Promise<Permission | null>} permission
*/
async acceptInvitation(inviteCode: string, providerStr = 'affine') {
const provider = this.providerMap.get(providerStr);
if (provider) {
return await provider.acceptInvitation(inviteCode);
}
return [];
return null;
}
onMessage(cb: (message: Message) => void) {

View File

@ -399,7 +399,7 @@ export class AffineProvider extends BaseProvider {
return this._apis.getWorkspaceMembers({ id });
}
public override async acceptInvitation(invitingCode: string): Promise<void> {
await this._apis.acceptInviting({ invitingCode });
public override async acceptInvitation(invitingCode: string) {
return await this._apis.acceptInviting({ invitingCode });
}
}

View File

@ -197,13 +197,13 @@ export interface AcceptInvitingParams {
export async function acceptInviting(
params: AcceptInvitingParams
): Promise<void> {
await bareClient
.post(`api/invitation/${params.invitingCode}`)
.catch(error => {
sendMessage(messageCode.acceptInvitingFailed);
throw new RequestError('accept inviting failed', error);
});
): Promise<Permission> {
try {
return bareClient.post(`api/invitation/${params.invitingCode}`).json();
} catch (error) {
sendMessage(messageCode.acceptInvitingFailed);
throw new RequestError('accept inviting failed', error);
}
}
export async function uploadBlob(params: { blob: Blob }): Promise<string> {

View File

@ -4,6 +4,7 @@ import { Logger, User } from '../types';
import type { WorkspaceUnitCollectionScope } from '../workspace-unit-collection';
import type { WorkspaceUnitCtorParams, WorkspaceUnit } from '../workspace-unit';
import { Member } from './affine/apis';
import { Permission } from './affine/apis/workspace.js';
const defaultLogger = () => {
return;
@ -233,8 +234,10 @@ export class BaseProvider {
* @param {string} inviteCode
* @returns
*/
public async acceptInvitation(inviteCode: string): Promise<void> {
public async acceptInvitation(
inviteCode: string
): Promise<Permission | null> {
inviteCode;
return;
return null;
}
}