mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
fix(server): don't set the wrong context on logger (#10088)

This commit is contained in:
@@ -280,11 +280,14 @@ export class PermissionService {
|
||||
if (count > 0) {
|
||||
return true;
|
||||
} else {
|
||||
this.logger.log("User's WorkspaceRole is lower than required", {
|
||||
const info = {
|
||||
workspaceId: ws,
|
||||
userId: user,
|
||||
requiredRole: WorkspaceRole[permission],
|
||||
});
|
||||
};
|
||||
this.logger.log(
|
||||
`User's WorkspaceRole is lower than required (${JSON.stringify(info)})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,7 +630,7 @@ export class PermissionService {
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
this.logger.log("User's role is lower than required", {
|
||||
const info = {
|
||||
workspaceId: ws,
|
||||
docId: doc,
|
||||
userId: user,
|
||||
@@ -640,7 +643,10 @@ export class PermissionService {
|
||||
: undefined,
|
||||
requiredRole: DocRole[role],
|
||||
action,
|
||||
});
|
||||
};
|
||||
this.logger.log(
|
||||
`User's role is lower than required (${JSON.stringify(info)})`
|
||||
);
|
||||
}
|
||||
|
||||
// check whether user has workspace related permission
|
||||
|
||||
@@ -326,18 +326,18 @@ export class WorkspaceDocResolver {
|
||||
docId.guid
|
||||
);
|
||||
|
||||
const info = {
|
||||
workspaceId,
|
||||
docId: rawDocId,
|
||||
};
|
||||
if (!isPublic) {
|
||||
this.logger.log('Expect to revoke public doc, but it is not public', {
|
||||
workspaceId,
|
||||
docId: rawDocId,
|
||||
});
|
||||
this.logger.log(
|
||||
`Expect to revoke public doc, but it is not public (${JSON.stringify(info)})`
|
||||
);
|
||||
throw new DocIsNotPublic('Doc is not public');
|
||||
}
|
||||
|
||||
this.logger.log('Revoke public doc', {
|
||||
workspaceId,
|
||||
docId: rawDocId,
|
||||
});
|
||||
this.logger.log(`Revoke public doc (${JSON.stringify(info)})`);
|
||||
|
||||
return this.permission.revokePublicPage(docId.workspace, docId.guid);
|
||||
}
|
||||
@@ -487,11 +487,12 @@ export class DocResolver {
|
||||
input.userIds,
|
||||
input.role
|
||||
);
|
||||
this.logger.log('Grant doc user roles', {
|
||||
const info = {
|
||||
...pairs,
|
||||
userIds: input.userIds,
|
||||
role: input.role,
|
||||
});
|
||||
};
|
||||
this.logger.log(`Grant doc user roles (${JSON.stringify(info)})`);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -522,10 +523,11 @@ export class DocResolver {
|
||||
user.id
|
||||
);
|
||||
await this.permission.revokePage(doc.workspace, doc.guid, input.userId);
|
||||
this.logger.log('Revoke doc user roles', {
|
||||
const info = {
|
||||
...pairs,
|
||||
userId: input.userId,
|
||||
});
|
||||
};
|
||||
this.logger.log(`Revoke doc user roles (${JSON.stringify(info)})`);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -564,18 +566,15 @@ export class DocResolver {
|
||||
input.role
|
||||
);
|
||||
|
||||
const info = {
|
||||
...pairs,
|
||||
userId: input.userId,
|
||||
role: input.role,
|
||||
};
|
||||
if (input.role === DocRole.Owner) {
|
||||
this.logger.log('Transfer doc owner', {
|
||||
...pairs,
|
||||
userId: input.userId,
|
||||
role: input.role,
|
||||
});
|
||||
this.logger.log(`Transfer doc owner (${JSON.stringify(info)})`);
|
||||
} else {
|
||||
this.logger.log('Update doc user role', {
|
||||
...pairs,
|
||||
userId: input.userId,
|
||||
role: input.role,
|
||||
});
|
||||
this.logger.log(`Update doc user role (${JSON.stringify(info)})`);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -587,7 +586,9 @@ export class DocResolver {
|
||||
@Args('input') input: UpdateDocDefaultRoleInput
|
||||
) {
|
||||
if (input.role === DocRole.Owner) {
|
||||
this.logger.log('Doc default role can not be owner', input);
|
||||
this.logger.log(
|
||||
`Doc default role can not be owner (${JSON.stringify(input)})`
|
||||
);
|
||||
throw new DocDefaultRoleCanNotBeOwner();
|
||||
}
|
||||
const doc = new DocID(input.docId, input.workspaceId);
|
||||
@@ -615,11 +616,12 @@ export class DocResolver {
|
||||
} catch (error) {
|
||||
if (error instanceof DocAccessDenied) {
|
||||
this.logger.log(
|
||||
'User does not have permission to update page default role',
|
||||
{
|
||||
...pairs,
|
||||
userId: user.id,
|
||||
}
|
||||
`User does not have permission to update page default role (${JSON.stringify(
|
||||
{
|
||||
...pairs,
|
||||
userId: user.id,
|
||||
}
|
||||
)})`
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
|
||||
@@ -54,7 +54,7 @@ export class CreateCommand extends CommandRunner {
|
||||
|
||||
this.logger.log(`Creating ${fileName}...`);
|
||||
writeFileSync(filePath, content);
|
||||
this.logger.log('Migration file created at', filePath);
|
||||
this.logger.log(`Migration file created at ${filePath}`);
|
||||
this.logger.log('Done');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user