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

View File

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

View File

@ -197,13 +197,13 @@ export interface AcceptInvitingParams {
export async function acceptInviting( export async function acceptInviting(
params: AcceptInvitingParams params: AcceptInvitingParams
): Promise<void> { ): Promise<Permission> {
await bareClient try {
.post(`api/invitation/${params.invitingCode}`) return bareClient.post(`api/invitation/${params.invitingCode}`).json();
.catch(error => { } catch (error) {
sendMessage(messageCode.acceptInvitingFailed); sendMessage(messageCode.acceptInvitingFailed);
throw new RequestError('accept inviting failed', error); throw new RequestError('accept inviting failed', error);
}); }
} }
export async function uploadBlob(params: { blob: Blob }): Promise<string> { 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 { WorkspaceUnitCollectionScope } from '../workspace-unit-collection';
import type { WorkspaceUnitCtorParams, WorkspaceUnit } from '../workspace-unit'; import type { WorkspaceUnitCtorParams, WorkspaceUnit } from '../workspace-unit';
import { Member } from './affine/apis'; import { Member } from './affine/apis';
import { Permission } from './affine/apis/workspace.js';
const defaultLogger = () => { const defaultLogger = () => {
return; return;
@ -233,8 +234,10 @@ export class BaseProvider {
* @param {string} inviteCode * @param {string} inviteCode
* @returns * @returns
*/ */
public async acceptInvitation(inviteCode: string): Promise<void> { public async acceptInvitation(
inviteCode: string
): Promise<Permission | null> {
inviteCode; inviteCode;
return; return null;
} }
} }