mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-27 23:15:04 +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
|
* 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) {
|
||||||
|
@ -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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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> {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user