Merge branch '459-activitypub-integration' of ssh://numinibsd/git/base/enigma-bbs into 459-activitypub-integration

This commit is contained in:
Bryan Ashby 2023-04-25 11:46:37 -06:00
commit 60b17a64ae
8 changed files with 45 additions and 24 deletions

View File

@ -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

View File

@ -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];
}

View File

@ -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,
});

View File

@ -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'
);

View File

@ -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}"`
);

View File

@ -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'));

View File

@ -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,
});