Merge branch '459-activitypub-integration' of ssh://numinibsd/git/base/enigma-bbs into 459-activitypub-integration
This commit is contained in:
commit
0858916490
|
@ -1,5 +1,5 @@
|
|||
// ENiGMA½
|
||||
const SysLog = require('../../logger.js').log;
|
||||
const SysLogger = require('../../logger.js').log;
|
||||
const ServerModule = require('../../server_module.js').ServerModule;
|
||||
const Config = require('../../config.js').get;
|
||||
const { Errors } = require('../../enig_error.js');
|
||||
|
@ -132,14 +132,14 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
try {
|
||||
const normalizedName = _.camelCase(module.moduleInfo.name);
|
||||
if (!WebHandlerModule.isEnabled(normalizedName)) {
|
||||
SysLog.info(
|
||||
SysLogger.info(
|
||||
{ moduleName: normalizedName },
|
||||
'Web handler module not enabled'
|
||||
);
|
||||
return nextModule(null);
|
||||
}
|
||||
|
||||
SysLog.info(
|
||||
SysLogger.info(
|
||||
{ moduleName: normalizedName },
|
||||
'Initializing web handler module'
|
||||
);
|
||||
|
@ -148,7 +148,7 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
return nextModule(err);
|
||||
});
|
||||
} catch (e) {
|
||||
SysLog.error(
|
||||
SysLogger.error(
|
||||
{ error: e.message },
|
||||
'Exception caught loading web handler'
|
||||
);
|
||||
|
@ -170,12 +170,12 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
if (this[name]) {
|
||||
const port = parseInt(config.contentServers.web[service].port);
|
||||
if (isNaN(port)) {
|
||||
SysLog.error(
|
||||
SysLogger.error(
|
||||
{
|
||||
port: config.contentServers.web[service].port,
|
||||
server: ModuleInfo.name,
|
||||
},
|
||||
`Invalid port (${service})`
|
||||
`Invalid web port (${service})`
|
||||
);
|
||||
return nextService(
|
||||
Errors.Invalid(
|
||||
|
@ -205,16 +205,13 @@ exports.getModule = class WebServerModule extends ServerModule {
|
|||
route = new Route(route);
|
||||
|
||||
if (!route.isValid()) {
|
||||
SysLog.error(
|
||||
{ route: route },
|
||||
'Cannot add route: missing or invalid required members'
|
||||
);
|
||||
SysLogger.error({ route: route }, 'Cannot add invalid route');
|
||||
return false;
|
||||
}
|
||||
|
||||
const routeKey = route.getRouteKey();
|
||||
if (routeKey in this.routes) {
|
||||
SysLog.warn(
|
||||
SysLogger.warn(
|
||||
{ route: route, routeKey: routeKey },
|
||||
'Cannot add route: duplicate method/path combination exists'
|
||||
);
|
||||
|
|
|
@ -48,6 +48,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
enigma_assert(webServer, 'ActivityPub Web Handler init without webServer');
|
||||
|
||||
this.log = webServer.logger().child({ webHandler: 'ActivityPub' });
|
||||
this.sysLog = SysLog.child({ webHandler: 'ActivityPub' });
|
||||
|
||||
Events.addListener(Events.getSystemEvents().NewUserPrePersist, eventInfo => {
|
||||
const { user, callback } = eventInfo;
|
||||
|
@ -398,7 +399,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
|
||||
SysLog.info(
|
||||
this.log.info(
|
||||
{
|
||||
remoteActorId: activity.actor,
|
||||
localActorId: _.get(activity, 'object.actor'),
|
||||
|
@ -628,7 +629,12 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
// :TODO: log me
|
||||
}
|
||||
|
||||
SysLog.info({ stats, inboxType }, 'Inbox Delete request complete');
|
||||
this.sysLog.info(
|
||||
{ stats, inboxType },
|
||||
`AP: ${_.startCase(inboxType)} delete request complete (${
|
||||
stats.deleted.length
|
||||
})`
|
||||
);
|
||||
return this.webServer.accepted(resp);
|
||||
}
|
||||
);
|
||||
|
@ -804,7 +810,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
return this.webServer.internalServerError(resp, err);
|
||||
}
|
||||
|
||||
SysLog.info(
|
||||
this.log.info(
|
||||
{
|
||||
username: localUser.username,
|
||||
userId: localUser.userId,
|
||||
|
@ -908,13 +914,13 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
return this.webServer.internalServerError(resp, err);
|
||||
}
|
||||
|
||||
SysLog.info(
|
||||
this.sysLog.info(
|
||||
{
|
||||
inboxType,
|
||||
objectId: targetObjectId,
|
||||
objectType,
|
||||
},
|
||||
`${objectType} Updated`
|
||||
`AP: ${_.startCase(inboxType)} '${objectType}' updated`
|
||||
);
|
||||
|
||||
// Update any assoc Message object
|
||||
|
@ -928,9 +934,9 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
}
|
||||
|
||||
_deliverNoteToSharedInbox(activity, note, cb) {
|
||||
SysLog.info(
|
||||
this.log.info(
|
||||
{ activityId: activity.id, noteId: note.id },
|
||||
'Delivering Note to Public/Shared inbox'
|
||||
"Delivering 'Note' to Public/Shared inbox"
|
||||
);
|
||||
|
||||
Collection.addSharedInboxItem(activity, true, err => {
|
||||
|
@ -966,7 +972,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
actorId,
|
||||
username: localUser.username,
|
||||
},
|
||||
`Delivering private Note to local Actor "${localUser.username}"`
|
||||
`AP: Delivering private 'Note' to user "${localUser.username}"`
|
||||
);
|
||||
|
||||
Collection.addInboxItem(activity, localUser, false, err => {
|
||||
|
@ -1006,14 +1012,15 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
if (_.isObject(localAddressedTo)) {
|
||||
localAddressedTo = localAddressedTo.username;
|
||||
}
|
||||
this.log.info(
|
||||
|
||||
this.sysLog.info(
|
||||
{
|
||||
localAddressedTo,
|
||||
activityId,
|
||||
noteId: note.id,
|
||||
messageId,
|
||||
},
|
||||
'Note persisted as local Message'
|
||||
`AP: Saved 'Note' to "${localAddressedTo}" as message ${messageId}`
|
||||
);
|
||||
} else if (err.code === 'SQLITE_CONSTRAINT') {
|
||||
return cb(null);
|
||||
|
@ -1218,7 +1225,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
|||
_prepareNewUserAsActor(user, cb) {
|
||||
this.sysLog.info(
|
||||
{ username: user.username, userId: user.userId },
|
||||
`Preparing ActivityPub settings for "${user.username}"`
|
||||
`AP: Preparing ActivityPub settings for "${user.username}"`
|
||||
);
|
||||
|
||||
return prepareLocalUserAsActor(user, { force: false }, cb);
|
||||
|
|
Loading…
Reference in New Issue