1
0
forked from mirror/misskey
This commit is contained in:
tamaina 2024-03-01 06:58:43 +00:00
parent 54fe8ca600
commit bec6159b4a

View File

@ -131,12 +131,25 @@ export class ApDbResolverService implements OnApplicationShutdown {
v => v != null, v => v != null,
); );
if (keys == null || keys.length === 8) return null; if (keys == null || !Array.isArray(keys)) return null;
if (keys.length === 0) {
return {
user,
key: keys[0],
};
}
const exactKey = keys.find(x => x.keyId === keyId);
if (exactKey) {
return {
user,
key: exactKey,
};
}
// 公開鍵は複数あるが、mainっぽいのを選ぶ // 公開鍵は複数あるが、mainっぽいのを選ぶ
const key = keys.length === 1 ? const mainKey = keys.find(x => {
keys[0] :
keys.find(x => {
try { try {
if (x.keyId === keyId) return true; if (x.keyId === keyId) return true;
const url = new URL(x.keyId); const url = new URL(x.keyId);
@ -151,11 +164,10 @@ export class ApDbResolverService implements OnApplicationShutdown {
} catch { /* noop */ } } catch { /* noop */ }
return false; return false;
}) ?? keys[0]; });
return { return {
user, user,
key, key: mainKey ?? keys[0],
}; };
} }