Add a thing to remove apps from your app list. Should I have called in 'uninstall'?

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3916 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-06-20 18:13:19 +00:00
parent c9e01f220d
commit 718383205b
3 changed files with 46 additions and 1 deletions

View File

@ -459,6 +459,34 @@ async function blobHandler(request, response, blobId, uri) {
response.writeHead(200, {"Content-Type": "text/plain; charset=utf-8"});
response.end("/" + newBlobId);
} else if (uri == "/delete") {
let match;
if (match = /^\/\~(\w+)\/(\w+)$/.exec(blobId)) {
var user = match[1];
var appName = match[2];
var credentials = auth.query(request.headers);
if (credentials && credentials.session &&
(credentials.session.name == user ||
(credentials.permissions.administration && user == 'core'))) {
var database = new Database(user);
var apps = new Set();
try {
apps = new Set(JSON.parse(database.get('apps')));
} catch {
}
if (apps.delete(appName)) {
database.set('apps', JSON.stringify([...apps]));
}
database.remove('path:' + appName);
} else {
response.writeHead(401, {"Content-Type": "text/plain; charset=utf-8"});
response.end("401 Unauthorized");
return;
}
}
response.writeHead(200, {"Content-Type": "text/plain; charset=utf-8"});
response.end('OK');
} else {
var data;
var type;
@ -581,7 +609,7 @@ loadSettings().then(function() {
return staticDirectoryHandler(request, response, 'deps/split/', match[1]);
} else if (match = /^\/smoothie\/([\.\w-/]*)$/.exec(request.uri)) {
return staticDirectoryHandler(request, response, 'deps/smoothie/', match[1]);
} else if (match = /^(.*)(\/save?)$/.exec(request.uri)) {
} else if (match = /^(.*)(\/(?:save|delete)?)$/.exec(request.uri)) {
return blobHandler(request, response, match[1], match[2]);
} else if (match = /^\/trace$/.exec(request.uri)) {
var data = trace();