getIdentityInfo => C.

This commit is contained in:
2024-05-05 13:48:22 -04:00
parent a28f6985ed
commit 421955f2a0
5 changed files with 179 additions and 48 deletions

View File

@ -545,7 +545,7 @@ async function getProcessBlob(blobId, key, options) {
{
action: 'identities',
},
await getIdentityInfo(
await ssb.getIdentityInfo(
process?.credentials?.session?.name,
options?.packageOwner,
options?.packageName
@ -785,6 +785,7 @@ async function getProcessBlob(blobId, key, options) {
);
}
};
imports.ssb.getIdentityInfo = undefined;
imports.fetch = function (url, options) {
return http.fetch(url, options, gGlobalSettings.fetch_hosts);
};
@ -1553,43 +1554,10 @@ function storePermission(user, packageOwner, packageName, permission, allow) {
}
}
async function getIdentityInfo(user, packageOwner, packageName) {
let identities = await ssb.getIdentities(user);
let names = new Object();
for (let identity of identities) {
names[identity] = identity;
}
await ssb.sqlAsync(
`
SELECT author, name FROM (
SELECT
messages.author,
RANK() OVER (PARTITION BY messages.author ORDER BY messages.sequence DESC) AS author_rank,
messages.content ->> 'name' AS name
FROM messages
JOIN json_each(?) AS ids
ON messages.author = ids.value
WHERE json_extract(messages.content, '$.type') = 'about' AND content ->> 'about' = messages.author AND name IS NOT NULL)
WHERE author_rank = 1
`,
[JSON.stringify(identities)],
function (row) {
names[row.author] = row.name;
}
);
return {
identities: identities,
identity: await ssb.getActiveIdentity(user, packageOwner, packageName),
names: names,
};
}
export {
gGlobalSettings as globalSettings,
setGlobalSettings,
enableStats,
invoke,
getSessionProcessBlob,
getIdentityInfo,
};