From dd8ab851f2d2a06e50c24466660668b0376abbb3 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Tue, 25 Apr 2023 11:45:13 -0600 Subject: [PATCH 1/3] Less restrictive for subject capture...again --- core/activitypub/note.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/activitypub/note.js b/core/activitypub/note.js index d83c30ab..cb751528 100644 --- a/core/activitypub/note.js +++ b/core/activitypub/note.js @@ -405,7 +405,7 @@ module.exports = class Note extends ActivityPubObject { // or 32 characters in length, whichever comes first // - If not end of string, we'll sub in '...' // - let subject = message.message.replace(/^@[^ ]+ /, '').trim(); + let subject = message.message.replace(/^@[^ ,]+ /, '').trim(); const m = /^(.+)\r?\n/.exec(subject); if (m && m[1]) { subject = m[1]; @@ -423,7 +423,7 @@ module.exports = class Note extends ActivityPubObject { return; } - const m = /^(@[^ ]+) ./.exec(message.message); + const m = /^(@[^ ,]+) ./.exec(message.message); if (m && m[1]) { message.toUserName = m[1]; } From 31f10d0c78dd3bc8c305106ce5fe167e84bce498 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Tue, 25 Apr 2023 11:46:03 -0600 Subject: [PATCH 2/3] Fixes --- art/themes/luciano_blocktronics/theme.hjson | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/art/themes/luciano_blocktronics/theme.hjson b/art/themes/luciano_blocktronics/theme.hjson index 1f5448bd..edec6669 100644 --- a/art/themes/luciano_blocktronics/theme.hjson +++ b/art/themes/luciano_blocktronics/theme.hjson @@ -1395,6 +1395,23 @@ } } + activityPubPostPublicMessage: { + 0: { + mci: { + TL1: { width: 19, textOverflow: "..." } + ET2: { width: 19, textOverflow: "..." } + ET3: { width: 19, textOverflow: "..." } + ET4: { width: 21, textOverflow: "..." } + //TL4: { width: 25 } + } + } + 1: { + mci: { + MT1: { height: 14 } + } + } + } + activityPubPublicMessages: { config: { dateTimeFormat: ddd MMM Do From a5a72d8270e6132c705c2258b97600f73eada399 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Tue, 25 Apr 2023 11:46:19 -0600 Subject: [PATCH 3/3] Split out logging a bit, fix accept header parsing --- .../luciano_blocktronics/activitypub_menu.ans | Bin 3992 -> 4016 bytes core/logger.js | 2 +- core/servers/content/web.js | 15 +++++----- .../content/web_handlers/activitypub.js | 27 +++++++++++------- .../content/web_handlers/system_general.js | 2 -- core/web_log.js | 2 +- 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/art/themes/luciano_blocktronics/activitypub_menu.ans b/art/themes/luciano_blocktronics/activitypub_menu.ans index ae151f7d9909bdac181f9d492821f187ea815b6a..f582e85a0d2cd9766f9edc30602b7735ab607d1b 100644 GIT binary patch delta 218 zcmbOszd?RO0k=$nf^@WjwXs=lL4I+GLP2R#PG+(~ZfbFHVtVT2gM7l1H*%{^zQXMq zBOPsMZET*K168h2mYG_ProLD@+Sn*p0U1Db0cF6JC={nA7A0pWq~#YWBqo>S7eTa4 z_UCb!oXe#?Ie}Al@?##I$rHF0C!gXInC!r-HTe#&=;T^np~>95GF%FYMX8BETg-DO eFXuI%Jb{sYay~EL=8wE}j4URGhOU!~`Bed+*F&WM delta 136 zcmdlWKSO>)0rzA#9szy@7?6%Ov^F-MEW)cac|N!55|iC{wI)aLiA-+e f6`btPsXF--kiU;lWHT3EEhCGup|S4dZhln&gG?vo diff --git a/core/logger.js b/core/logger.js index 83eac3ad..82ed5594 100644 --- a/core/logger.js +++ b/core/logger.js @@ -30,7 +30,7 @@ module.exports = class Log { const serializers = Log.standardSerializers(); this.log = bunyan.createLogger({ - name: 'ENiGMA½ BBS', + name: 'ENiGMA½', streams: logStreams, serializers: serializers, }); diff --git a/core/servers/content/web.js b/core/servers/content/web.js index 9bc8ebb2..72bcff50 100644 --- a/core/servers/content/web.js +++ b/core/servers/content/web.js @@ -1,5 +1,5 @@ // ENiGMA½ -const Log = require('../../logger.js').log; +const SysLog = require('../../logger.js').log; const ServerModule = require('../../server_module.js').ServerModule; const Config = require('../../config.js').get; const { Errors } = require('../../enig_error.js'); @@ -75,7 +75,6 @@ exports.getModule = class WebServerModule extends ServerModule { constructor() { super(); - //this.log = Log.child({ server: 'Web' }); this.log = WebLog.createWebLog(); const config = Config(); @@ -133,14 +132,14 @@ exports.getModule = class WebServerModule extends ServerModule { try { const normalizedName = _.camelCase(module.moduleInfo.name); if (!WebHandlerModule.isEnabled(normalizedName)) { - this.log.info( + SysLog.info( { moduleName: normalizedName }, 'Web handler module not enabled' ); return nextModule(null); } - Log.info( + SysLog.info( { moduleName: normalizedName }, 'Initializing web handler module' ); @@ -149,7 +148,7 @@ exports.getModule = class WebServerModule extends ServerModule { return nextModule(err); }); } catch (e) { - this.log.error( + SysLog.error( { error: e.message }, 'Exception caught loading web handler' ); @@ -171,7 +170,7 @@ exports.getModule = class WebServerModule extends ServerModule { if (this[name]) { const port = parseInt(config.contentServers.web[service].port); if (isNaN(port)) { - this.log.error( + SysLog.error( { port: config.contentServers.web[service].port, server: ModuleInfo.name, @@ -206,7 +205,7 @@ exports.getModule = class WebServerModule extends ServerModule { route = new Route(route); if (!route.isValid()) { - this.log.error( + SysLog.error( { route: route }, 'Cannot add route: missing or invalid required members' ); @@ -215,7 +214,7 @@ exports.getModule = class WebServerModule extends ServerModule { const routeKey = route.getRouteKey(); if (routeKey in this.routes) { - this.log.warn( + SysLog.warn( { route: route, routeKey: routeKey }, 'Cannot add route: duplicate method/path combination exists' ); diff --git a/core/servers/content/web_handlers/activitypub.js b/core/servers/content/web_handlers/activitypub.js index 1add01c0..e9b01a81 100644 --- a/core/servers/content/web_handlers/activitypub.js +++ b/core/servers/content/web_handlers/activitypub.js @@ -6,6 +6,7 @@ const { getActorId, prepareLocalUserAsActor, } = require('../../../activitypub/util'); +const SysLog = require('../../../logger').log; const { ActivityStreamMediaType, WellKnownActivity, @@ -182,7 +183,8 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { } // Additionally, serve activity JSON if the proper 'Accept' header was sent - const accept = req.headers['accept'].split(',').map(v => v.trim()) || ['*/*']; + const accept = (req.headers.accept && + req.headers.accept.split(',').map(v => v.trim())) || ['*/*']; const headerValues = [ ActivityStreamMediaType, 'application/ld+json', @@ -396,7 +398,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { _inboxAcceptFollowActivity(resp, activity) { // Currently Accept's to Follow's are really just a formality; // we'll log it, but that's about it for now - this.log.info( + SysLog.info( { remoteActorId: activity.actor, localActorId: _.get(activity, 'object.actor'), @@ -626,7 +628,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { // :TODO: log me } - this.log.info({ stats, inboxType }, 'Inbox Delete request complete'); + SysLog.info({ stats, inboxType }, 'Inbox Delete request complete'); return this.webServer.accepted(resp); } ); @@ -802,7 +804,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { return this.webServer.internalServerError(resp, err); } - this.log.info( + SysLog.info( { username: localUser.username, userId: localUser.userId, @@ -906,7 +908,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { return this.webServer.internalServerError(resp, err); } - this.log.info( + SysLog.info( { inboxType, objectId: targetObjectId, @@ -926,7 +928,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { } _deliverNoteToSharedInbox(activity, note, cb) { - this.log.info( + SysLog.info( { activityId: activity.id, noteId: note.id }, 'Delivering Note to Public/Shared inbox' ); @@ -957,9 +959,14 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { return cb(null); // not found/etc., just bail } - this.log.info( - { activityId: activity.id, noteId: note.id, actorId }, - 'Delivering Note to local Actor Private inbox' + this.sysLog.info( + { + activityId: activity.id, + noteId: note.id, + actorId, + username: localUser.username, + }, + `Delivering private Note to local Actor "${localUser.username}"` ); Collection.addInboxItem(activity, localUser, false, err => { @@ -1209,7 +1216,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { } _prepareNewUserAsActor(user, cb) { - this.log.info( + this.sysLog.info( { username: user.username, userId: user.userId }, `Preparing ActivityPub settings for "${user.username}"` ); diff --git a/core/servers/content/web_handlers/system_general.js b/core/servers/content/web_handlers/system_general.js index e5b79804..6ca9534d 100644 --- a/core/servers/content/web_handlers/system_general.js +++ b/core/servers/content/web_handlers/system_general.js @@ -27,8 +27,6 @@ exports.getModule = class SystemGeneralWebHandler extends WebHandlerModule { this.webServer = webServer; EngiAssert(webServer, 'System General Web Handler init without webServer'); - this.log = webServer.logger().child({ webHandler: 'SysGeneral' }); - const domain = getWebDomain(); if (!domain) { return cb(Errors.UnexpectedState('Web server does not have "domain" set')); diff --git a/core/web_log.js b/core/web_log.js index d463a324..5791b4b6 100644 --- a/core/web_log.js +++ b/core/web_log.js @@ -19,7 +19,7 @@ module.exports = class WebLog { serializers.res = bunyan.stdSerializers.res; const webLog = bunyan.createLogger({ - name: 'ENiGMA½ BBS[Web]', + name: 'ENiGMA½', streams: [rotatingFile], serializers, });