diff --git a/art/themes/luciano_blocktronics/activitypub_not_enabled.ans b/art/themes/luciano_blocktronics/activitypub_not_enabled.ans new file mode 100644 index 00000000..86cd4e19 Binary files /dev/null and b/art/themes/luciano_blocktronics/activitypub_not_enabled.ans differ diff --git a/core/servers/content/web_handlers/activitypub.js b/core/servers/content/web_handlers/activitypub.js index 9403731d..98592db6 100644 --- a/core/servers/content/web_handlers/activitypub.js +++ b/core/servers/content/web_handlers/activitypub.js @@ -505,14 +505,30 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { if (inboxType !== collectionName) { this.log.warn( { inboxType, collectionName, objectId }, - 'Will not Delete object(s) from mismatched collection!' + 'Will not Delete object: Collection mismatch' ); return nextObjInfo(null); } - // Validate signature + if ( + !this._isSignatureEqual( + activity.signature, + objInfo.object.signature + ) + ) { + this.log.warn( + { inboxType, collectionName, objectId }, + 'Will not Delete object: Signature mismatch' + ); + return nextObjInfo(null); + } - break; + return this._deleteObjectWithStats( + collectionName, + objInfo.object, + stats, + nextObjInfo + ); case Collections.Actors: // Validate signature; Delete Actor and Following entries if any @@ -526,21 +542,15 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { } return nextObjInfo(null); - } else { - // it's unparsable, so we'll delete it - Collection.removeById(collectionName, objectId, err => { - if (err) { - this.log.warn( - { objectId, collectionName }, - 'Failed to remove object' - ); - stats.failed.push({ collectionName, objectId }); - } else { - stats.deleted.push({ collectionName, objectId }); - } - return nextObjInfo(null); - }); } + + // Malformed; we'll go ahead and remove + return this._deleteObjectWithStats( + collectionName, + objInfo.object, + stats, + nextObjInfo + ); }, err => { if (err) { @@ -556,6 +566,32 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule { return this.webServer.accepted(resp); } + _deleteObjectWithStats(collectionName, object, stats, cb) { + const objectId = _.isString(object) ? object : object.id; + const type = object.type; + Collection.removeById(collectionName, objectId, err => { + if (err) { + this.log.warn( + { objectId, collectionName, type }, + 'Failed to remove object' + ); + stats.failed.push({ collectionName, objectId, type }); + } else { + stats.deleted.push({ collectionName, objectId, type }); + } + + return cb(null); + }); + } + + _isSignatureEqual(sigA, sigB) { + return ( + sigA.type === sigB.type && + sigA.creator === sigB.creator && + sigA.signatureValue === sigB.signatureValue + ); + } + _inboxFollowActivity(resp, remoteActor, activity) { this.log.info( { remoteActorId: remoteActor.id, localActorId: activity.object }, diff --git a/misc/menu_templates/activitypub.in.hjson b/misc/menu_templates/activitypub.in.hjson index 87579043..97c44e5c 100644 --- a/misc/menu_templates/activitypub.in.hjson +++ b/misc/menu_templates/activitypub.in.hjson @@ -3,19 +3,35 @@ activityPubMenu: { desc: ActivityPub Menu art: activitypub_menu - prompt: activiytPubMenuCommand + prompt: activityPubMenuCommand submit: [ { value: {command: "S"} - action: @menu:activityPubActorSearch + action: [ + { + acs: "AE1" + action: @menu:activityPubActorSearch + } + { + action: @menu:activityPubNotEnabled + } + ] } { value: {command: "C"} action: @menu:activityPubUserConfig } { - value: {command: "S"} - action: @menu:activityPubSocialManager + value: {command: "M"} + action: [ + { + acs: "AE1" + action: @menu:activityPubSocialManager + } + { + action: @menu:activityPubNotEnabled + } + ] } { value: {command: "Q"} @@ -25,10 +41,6 @@ value: { command: "E" } action: @menu:privateMailMenu } - { - value: { command: "G" } - action: @menu:fullLogoffSequence - } ] } @@ -82,6 +94,7 @@ } } } + activityPubUserConfig: { desc: ActivityPub Config module: ./activitypub/user_config @@ -174,6 +187,7 @@ } } } + activityPubSocialManager: { desc: ActivityPub Social Manager module: ./activitypub/social_manager @@ -207,6 +221,15 @@ } } } + + activityPubNotEnabled: { + desc: ActivityPub Not Enabled + art: activitypub_not_enabled + config: { + cls: true + pause: true + } + } } prompts: {