forked from cory/tildefriends
format/prettier
This commit is contained in:
55
core/core.js
55
core/core.js
@ -272,7 +272,13 @@ function broadcast(message) {
|
||||
* @param {*} argv
|
||||
* @returns
|
||||
*/
|
||||
function broadcastAppEventToUser(user, packageOwner, packageName, eventName, argv) {
|
||||
function broadcastAppEventToUser(
|
||||
user,
|
||||
packageOwner,
|
||||
packageName,
|
||||
eventName,
|
||||
argv
|
||||
) {
|
||||
let promises = [];
|
||||
for (let process of Object.values(gProcesses)) {
|
||||
if (
|
||||
@ -533,21 +539,40 @@ async function getProcessBlob(blobId, key, options) {
|
||||
url: options?.url,
|
||||
},
|
||||
};
|
||||
process.sendIdentities = async function() {
|
||||
process.sendIdentities = async function () {
|
||||
process.app.send({
|
||||
action: 'identities',
|
||||
identities: await ssb.getIdentities(process?.credentials?.session?.name),
|
||||
identity: await getActiveIdentity(process?.credentials?.session?.name, options.packageOwner, options.packageName),
|
||||
identities: await ssb.getIdentities(
|
||||
process?.credentials?.session?.name
|
||||
),
|
||||
identity: await getActiveIdentity(
|
||||
process?.credentials?.session?.name,
|
||||
options.packageOwner,
|
||||
options.packageName
|
||||
),
|
||||
});
|
||||
};
|
||||
process.setActiveIdentity = async function(identity) {
|
||||
if (process?.credentials?.session?.name && options.packageOwner && options.packageName) {
|
||||
await new Database(process?.credentials?.session?.name).set(`id:${options.packageOwner}:${options.packageName}`, identity);
|
||||
process.setActiveIdentity = async function (identity) {
|
||||
if (
|
||||
process?.credentials?.session?.name &&
|
||||
options.packageOwner &&
|
||||
options.packageName
|
||||
) {
|
||||
await new Database(process?.credentials?.session?.name).set(
|
||||
`id:${options.packageOwner}:${options.packageName}`,
|
||||
identity
|
||||
);
|
||||
}
|
||||
process.sendIdentities();
|
||||
broadcastAppEventToUser(process?.credentials?.session?.name, options.packageOwner, options.packageName, 'setActiveIdentity', [identity]);
|
||||
broadcastAppEventToUser(
|
||||
process?.credentials?.session?.name,
|
||||
options.packageOwner,
|
||||
options.packageName,
|
||||
'setActiveIdentity',
|
||||
[identity]
|
||||
);
|
||||
};
|
||||
process.createIdentity = async function() {
|
||||
process.createIdentity = async function () {
|
||||
if (
|
||||
process.credentials &&
|
||||
process.credentials.session &&
|
||||
@ -557,7 +582,7 @@ async function getProcessBlob(blobId, key, options) {
|
||||
await process.sendIdentities();
|
||||
return id;
|
||||
}
|
||||
}
|
||||
};
|
||||
if (process.credentials?.permissions?.administration) {
|
||||
imports.core.globalSettingsDescriptions = function () {
|
||||
let settings = Object.assign({}, k_global_settings);
|
||||
@ -655,8 +680,13 @@ async function getProcessBlob(blobId, key, options) {
|
||||
});
|
||||
}
|
||||
};
|
||||
imports.ssb.setActiveIdentity = id => process.setActiveIdentity(id);
|
||||
imports.ssb.getActiveIdentity = () => getActiveIdentity(process.credentials?.session?.name, options.packageOwner, options.packageName);
|
||||
imports.ssb.setActiveIdentity = (id) => process.setActiveIdentity(id);
|
||||
imports.ssb.getActiveIdentity = () =>
|
||||
getActiveIdentity(
|
||||
process.credentials?.session?.name,
|
||||
options.packageOwner,
|
||||
options.packageName
|
||||
);
|
||||
imports.ssb.getOwnerIdentities = function () {
|
||||
if (options.packageOwner) {
|
||||
return ssb.getIdentities(options.packageOwner);
|
||||
@ -1502,7 +1532,6 @@ function storePermission(user, packageOwner, packageName, permission, allow) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function getActiveIdentity(user, packageOwner, packageName) {
|
||||
if (user && packageOwner && packageName) {
|
||||
let id = await new Database(user).get(`id:${packageOwner}:${packageName}`);
|
||||
|
Reference in New Issue
Block a user