Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWS: fix a few obvious bugs that typescript caught #8886

Open
wants to merge 3 commits into
base: multi-wiki-support
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Command.prototype.execute = function() {
}
var recipeName = this.params[0],
bagList = (this.params[1] || "").split(" "),
recipeDescription = this.params[2] || recipeNameName;
recipeDescription = this.params[2];
// Create recipe
var result = $tw.mws.store.createRecipe(recipeName,bagList,recipeDescription);
if(result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function loadPluginBags() {
const bagName = makePluginBagName(type,publisher,name);
const result = $tw.mws.store.createBag(bagName,pluginFields.description || "(no description)",{allowPrivilegedCharacters: true});
if(result) {
console.log(`Error creating plugin bag ${bagname}: ${JSON.stringify(result)}`);
console.log(`Error creating plugin bag ${bagName}: ${JSON.stringify(result)}`);
}
$tw.mws.store.saveBagTiddler(pluginFields,bagName);
},
Expand Down
4 changes: 2 additions & 2 deletions plugins/tiddlywiki/multiwikiserver/modules/mws-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if($tw.node) {
querystring = require("querystring"),
crypto = require("crypto"),
zlib = require("zlib"),
aclMiddleware = require('$:/plugins/tiddlywiki/multiwikiserver/modules/routes/helpers/acl-middleware.js').middleware;
aclMiddleware = require('$:/plugins/tiddlywiki/multiwikiserver/routes/helpers/acl-middleware.js').middleware;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure that this change is wrong. There is no TW title without the modules subdirectory.

Copy link
Contributor Author

@Arlen22 Arlen22 Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most plugins, except evernote and text-slicer, leave it out. Core appears to leave it in. I don't have an opinion either way.

}

/*
Expand Down Expand Up @@ -432,7 +432,7 @@ Server.prototype.requestHandler = function(request,response,options) {

// Authenticate the user
const authenticatedUser = this.authenticateUser(request, response);
const authenticatedUsername = authenticatedUser?.username;
const authenticatedUsername = authenticatedUser && authenticatedUser.username;
Arlen22 marked this conversation as resolved.
Show resolved Hide resolved

// Compose the state object
var self = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ POST /admin/delete-acl
/*global $tw: false */
"use strict";

var aclMiddleware = require("$:/plugins/tiddlywiki/multiwikiserver/modules/routes/helpers/acl-middleware.js").middleware;
var aclMiddleware = require("$:/plugins/tiddlywiki/multiwikiserver/routes/helpers/acl-middleware.js").middleware;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upstream title was right.


exports.method = "POST";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DELETE /bags/:bag_name/tiddler/:title
/*global $tw: false */
"use strict";

var aclMiddleware = require("$:/plugins/tiddlywiki/multiwikiserver/modules/routes/helpers/acl-middleware.js").middleware;
var aclMiddleware = require("$:/plugins/tiddlywiki/multiwikiserver/routes/helpers/acl-middleware.js").middleware;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upstream title is right --- please check all of them


exports.method = "DELETE";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GET /bags/:bag_name/tiddler/:title/blob
/*global $tw: false */
"use strict";

var aclMiddleware = require("$:/plugins/tiddlywiki/multiwikiserver/modules/routes/helpers/acl-middleware.js").middleware;
var aclMiddleware = require("$:/plugins/tiddlywiki/multiwikiserver/routes/helpers/acl-middleware.js").middleware;

exports.method = "GET";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fallback=<url> // Optional redirect if the tiddler is not found
/*global $tw: false */
"use strict";

var aclMiddleware = require("$:/plugins/tiddlywiki/multiwikiserver/modules/routes/helpers/acl-middleware.js").middleware;
var aclMiddleware = require("$:/plugins/tiddlywiki/multiwikiserver/routes/helpers/acl-middleware.js").middleware;

exports.method = "GET";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*\
title: $:/plugins/tiddlywiki/multiwikiserver/modules/routes/helpers/acl-middleware.js
title: $:/plugins/tiddlywiki/multiwikiserver/routes/helpers/acl-middleware.js
type: application/javascript
module-type: library

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ exports.processIncomingStream = function(options) {
} else {
const partFile = parts.find(part => part.name === "file-to-upload" && !!part.filename);
if(!partFile) {
return state.sendResponse(400, {"Content-Type": "text/plain"},"Missing file to upload");
return options.state.sendResponse(400, {"Content-Type": "text/plain"},"Missing file to upload");
}
const type = partFile.headers["content-type"];
const tiddlerFields = {
Expand Down
6 changes: 2 additions & 4 deletions plugins/tiddlywiki/multiwikiserver/modules/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ exports.startup = function() {
const store = setupStore();
$tw.mws = {
store: store,
serverManager: new ServerManager({
store: store
})
serverManager: new ServerManager()
};
}

Expand All @@ -44,7 +42,7 @@ function setupStore() {
return store;
}

function ServerManager(store) {
function ServerManager() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think removing it, is not right. But @Jermolene there is an inconsistency. Here it says: ServerManager(store) but in line 25 it says:

	serverManager: new ServerManager({
			store: store
		})

Which seems to be an options object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option is not used anywhere. Store is passed in somewhere else, not here.

this.servers = [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ SqlTiddlerDatabase.prototype.listUsersByRoleId = function(roleId) {
};

SqlTiddlerDatabase.prototype.updateUser = function (userId, username, email, roleId) {
const existingUser = this.engine.runStatement(`
const existingUser = this.engine.runStatementGet(`
SELECT user_id FROM users
WHERE email = $email AND user_id != $userId
`, {
Expand Down
Loading