More updates on Deletes, ActivityPub ACS in menu
This commit is contained in:
parent
65e5fa1b77
commit
b0fff20a02
Binary file not shown.
|
@ -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 },
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Reference in New Issue