♻️ cli: better information about file history and key (#525)
This commit is contained in:
@@ -20,11 +20,11 @@ async function makeUserCache(platform: TdrivePlatform) {
|
|||||||
.getProvider<DatabaseServiceAPI>("database")
|
.getProvider<DatabaseServiceAPI>("database")
|
||||||
.getRepository<User>(User_TYPE, User);
|
.getRepository<User>(User_TYPE, User);
|
||||||
const cache: { [id: string]: User } = {};
|
const cache: { [id: string]: User } = {};
|
||||||
return async id => {
|
return async (id): Promise<[boolean, User]> => {
|
||||||
if (id in cache) return cache[id];
|
if (id in cache) return [true, cache[id]];
|
||||||
const user = await usersRepo.findOne({ id });
|
const user = await usersRepo.findOne({ id });
|
||||||
if (user) cache[id] = user;
|
if (user) cache[id] = user;
|
||||||
return user;
|
return [false, user];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,8 +36,10 @@ interface ListArguments {
|
|||||||
async function report(platform: TdrivePlatform, args: ListArguments) {
|
async function report(platform: TdrivePlatform, args: ListArguments) {
|
||||||
const users = await makeUserCache(platform);
|
const users = await makeUserCache(platform);
|
||||||
async function formatUser(id) {
|
async function formatUser(id) {
|
||||||
const user = await users(id);
|
const [wasKnown, user] = await users(id);
|
||||||
return user?.email_canonical || id;
|
return user?.email_canonical
|
||||||
|
? user.email_canonical + (wasKnown ? "" : ` (${id})`)
|
||||||
|
: `${JSON.stringify(id)} (user id not found)`;
|
||||||
}
|
}
|
||||||
const drivesRepo = await platform
|
const drivesRepo = await platform
|
||||||
.getProvider<DatabaseServiceAPI>("database")
|
.getProvider<DatabaseServiceAPI>("database")
|
||||||
@@ -60,7 +62,7 @@ async function report(platform: TdrivePlatform, args: ListArguments) {
|
|||||||
console.error(` - URL encoded: ${encodeURIComponent(dfile.editing_session_key)}`);
|
console.error(` - URL encoded: ${encodeURIComponent(dfile.editing_session_key)}`);
|
||||||
console.error(` - applicationId: ${parsed.applicationId}`);
|
console.error(` - applicationId: ${parsed.applicationId}`);
|
||||||
console.error(` - companyId: ${parsed.companyId}`);
|
console.error(` - companyId: ${parsed.companyId}`);
|
||||||
console.error(` - instanceId: ${parsed.instanceId}`);
|
console.error(` - instanceId: ${JSON.stringify(parsed.instanceId)}`);
|
||||||
console.error(
|
console.error(
|
||||||
` - userId: ${await formatUser(parsed.userId)} (${
|
` - userId: ${await formatUser(parsed.userId)} (${
|
||||||
parsed.userId === dfile.creator ? "same as creator ID" : "not the creator"
|
parsed.userId === dfile.creator ? "same as creator ID" : "not the creator"
|
||||||
|
|||||||
Reference in New Issue
Block a user