Prettier
This commit is contained in:
parent
d615b53f1f
commit
848044bec6
|
@ -49,18 +49,18 @@ class Route {
|
|||
isValid() {
|
||||
return (
|
||||
(this.pathRegExp instanceof RegExp &&
|
||||
-1 !==
|
||||
[
|
||||
'GET',
|
||||
'HEAD',
|
||||
'POST',
|
||||
'PUT',
|
||||
'DELETE',
|
||||
'CONNECT',
|
||||
'OPTIONS',
|
||||
'TRACE',
|
||||
].indexOf(this.method)) ||
|
||||
!_.isFunction(this.handler)
|
||||
-1 !==
|
||||
[
|
||||
'GET',
|
||||
'HEAD',
|
||||
'POST',
|
||||
'PUT',
|
||||
'DELETE',
|
||||
'CONNECT',
|
||||
'OPTIONS',
|
||||
'TRACE',
|
||||
].indexOf(this.method)) ||
|
||||
!_.isFunction(this.handler)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -96,13 +96,13 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
}
|
||||
|
||||
buildUrl(pathAndQuery) {
|
||||
//
|
||||
// Create a URL such as
|
||||
// https://l33t.codes:44512/ + |pathAndQuery|
|
||||
//
|
||||
// Prefer HTTPS over HTTP. Be explicit about the port
|
||||
// only if non-standard. Allow users to override full prefix in config.
|
||||
//
|
||||
//
|
||||
// Create a URL such as
|
||||
// https://l33t.codes:44512/ + |pathAndQuery|
|
||||
//
|
||||
// Prefer HTTPS over HTTP. Be explicit about the port
|
||||
// only if non-standard. Allow users to override full prefix in config.
|
||||
//
|
||||
const config = Config();
|
||||
if (_.isString(config.contentServers.web.overrideUrlPrefix)) {
|
||||
return `${config.contentServers.web.overrideUrlPrefix}${pathAndQuery}`;
|
||||
|
@ -113,15 +113,15 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
if (config.contentServers.web.https.enabled) {
|
||||
schema = 'https://';
|
||||
port =
|
||||
443 === config.contentServers.web.https.port
|
||||
? ''
|
||||
: `:${config.contentServers.web.https.port}`;
|
||||
443 === config.contentServers.web.https.port
|
||||
? ''
|
||||
: `:${config.contentServers.web.https.port}`;
|
||||
} else {
|
||||
schema = 'http://';
|
||||
port =
|
||||
80 === config.contentServers.web.http.port
|
||||
? ''
|
||||
: `:${config.contentServers.web.http.port}`;
|
||||
80 === config.contentServers.web.http.port
|
||||
? ''
|
||||
: `:${config.contentServers.web.http.port}`;
|
||||
}
|
||||
|
||||
return `${schema}${config.contentServers.web.domain}${port}${pathAndQuery}`;
|
||||
|
@ -168,11 +168,17 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
try {
|
||||
const normalizedName = _.camelCase(module.moduleInfo.name);
|
||||
if (!WebHandlerModule.isEnabled(normalizedName)) {
|
||||
Log.info({ moduleName: normalizedName }, 'Skipping web handler module - not enabled.');
|
||||
Log.info(
|
||||
{ moduleName: normalizedName },
|
||||
'Skipping web handler module - not enabled.'
|
||||
);
|
||||
return nextModule(null);
|
||||
}
|
||||
|
||||
Log.info({ moduleName: normalizedName }, 'Initializing web handler module.');
|
||||
Log.info(
|
||||
{ moduleName: normalizedName },
|
||||
'Initializing web handler module.'
|
||||
);
|
||||
|
||||
moduleInst.init(err => {
|
||||
return nextModule(err);
|
||||
|
@ -329,8 +335,8 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
|
||||
const headers = {
|
||||
'Content-Type':
|
||||
mimeTypes.contentType(paths.basename(filePath)) ||
|
||||
mimeTypes.contentType('.bin'),
|
||||
mimeTypes.contentType(paths.basename(filePath)) ||
|
||||
mimeTypes.contentType('.bin'),
|
||||
'Content-Length': stats.size,
|
||||
};
|
||||
|
||||
|
@ -362,8 +368,8 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
|
||||
const headers = {
|
||||
'Content-Type':
|
||||
mimeTypes.contentType(paths.basename(filePath)) ||
|
||||
mimeTypes.contentType('.bin'),
|
||||
mimeTypes.contentType(paths.basename(filePath)) ||
|
||||
mimeTypes.contentType('.bin'),
|
||||
'Content-Length': stats.size,
|
||||
};
|
||||
|
||||
|
|
|
@ -58,7 +58,10 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
|
||||
userFromAccount(accountName, (err, user) => {
|
||||
if (err) {
|
||||
Log.info({ accountName: accountName }, 'Unable to find user from account retrieving self url.');
|
||||
Log.info(
|
||||
{ accountName: accountName },
|
||||
'Unable to find user from account retrieving self url.'
|
||||
);
|
||||
return this._notFound(resp);
|
||||
}
|
||||
|
||||
|
@ -71,23 +74,21 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
|
||||
if (sendActor) {
|
||||
return this._selfAsActorHandler(user, req, resp);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return this._standardSelfHandler(user, req, resp);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_selfAsActorHandler(user, req, resp) {
|
||||
|
||||
const sUrl = selfUrl(this.webServer, user);
|
||||
const selfUrl = selfUrl(this.webServer, user);
|
||||
|
||||
const bodyJson = {
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
'https://w3id.org/security/v1',
|
||||
],
|
||||
id: sUrl,
|
||||
id: selfUrl,
|
||||
type: 'Person',
|
||||
preferredUsername: user.username,
|
||||
name: user.getSanitizedName('real'),
|
||||
|
@ -105,11 +106,14 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
};
|
||||
|
||||
const publicKeyPem = user.getProperty(UserProps.PublicKeyMain);
|
||||
if (!(_.isEmpty(publicKeyPem))) {
|
||||
bodyJson['publicKey'] = { id: sUrl + '#main-key', owner: sUrl, publicKeyPem: user.getProperty(UserProps.PublicKeyMain) };
|
||||
}
|
||||
else {
|
||||
Log.debug({ User: user.username }, 'User does not have a publickey.');
|
||||
if (!_.isEmpty(publicKeyPem)) {
|
||||
bodyJson['publicKey'] = {
|
||||
id: selfUrl + '#main-key',
|
||||
owner: sUrl,
|
||||
publicKeyPem: user.getProperty(UserProps.PublicKeyMain),
|
||||
};
|
||||
} else {
|
||||
Log.debug({ username: user.username }, 'User does not have a publickey.');
|
||||
}
|
||||
|
||||
const body = JSON.stringify(bodyJson);
|
||||
|
|
1916
core/user.js
1916
core/user.js
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue