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