forked from cory/tildefriends
getIdentityInfo => C.
This commit is contained in:
36
core/core.js
36
core/core.js
@ -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,
|
||||
};
|
||||
|
Reference in New Issue
Block a user