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( return Collection.addToCollection(
'outbox', 'outbox',
owningUser, owningUser,
outboxItem.id, outboxItem.id,
outboxItem, outboxItem,
false, isPrivate,
cb cb
); );
} }

View File

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