mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-27 22:53:20 +03:00
feat: fix access permission api
This commit is contained in:
parent
0b623a522b
commit
cf47098631
@ -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) {
|
||||
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
@ -197,13 +197,13 @@ export interface AcceptInvitingParams {
|
||||
|
||||
export async function acceptInviting(
|
||||
params: AcceptInvitingParams
|
||||
): Promise<void> {
|
||||
await bareClient
|
||||
.post(`api/invitation/${params.invitingCode}`)
|
||||
.catch(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> {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user