Update on recording to outbox

This commit is contained in:
Bryan Ashby 2023-01-22 11:02:45 -07:00
parent d03718d55e
commit 8f131630ff
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
2 changed files with 23 additions and 19 deletions

View File

@ -57,13 +57,13 @@ module.exports = class Collection extends ActivityPubObject {
);
}
static addOutboxItem(owningUser, outboxItem, cb) {
static addOutboxItem(owningUser, outboxItem, isPrivate, cb) {
return Collection.addToCollection(
'outbox',
owningUser,
outboxItem.id,
outboxItem,
false,
isPrivate,
cb
);
}

View File

@ -58,10 +58,11 @@ exports.getModule = class ActivityPubScannerTosser extends MessageScanTossModule
this._webServer(),
(err, respBody, res) => {
if (err) {
return callback(err);
}
if (res.statusCode !== 202 && res.statusCode !== 200) {
this.log.warn(
{ error: err.message, inbox: remoteActor.inbox },
'Failed to send "Note" Activity to Inbox'
);
} else if (res.statusCode !== 202 && res.statusCode !== 200) {
this.log.warn(
{
inbox: remoteActor.inbox,
@ -72,25 +73,28 @@ exports.getModule = class ActivityPubScannerTosser extends MessageScanTossModule
);
}
//
// We sent successfully; update some properties
// in the original message to indicate export
// and updated mapping of message -> Activity record
//
// carry on regardless if we sent and record
// the item in the user's Outbox collection
return callback(null, activity, fromUser);
}
);
},
(activity, fromUser, callback) => {
Collection.addOutboxItem(fromUser, activity, (err, localId) => {
// If we failed to send above,
Collection.addOutboxItem(
fromUser,
activity,
message.isPrivate(),
(err, localId) => {
if (!err) {
this.log.debug(
{ localId, activityId: activity.id },
'Note Activity persisted to database'
'Note Activity persisted to "outbox" collection"'
);
}
return callback(err, activity);
});
}
);
},
(activity, callback) => {
// mark exported