Add intiial 'flavor' for ActivityPub messages

This commit is contained in:
Bryan Ashby 2023-01-11 09:47:07 -07:00
parent 01cd91b045
commit ef118325ba
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
3 changed files with 22 additions and 0 deletions

View File

@ -21,6 +21,7 @@ const EMAIL_REGEX =
43:20/100.2 { flavor : 'ftn', remote : '43:20/100.2' }
foo@host.com { name : 'foo', flavor : 'email', remote : 'foo@host.com' }
Bar <baz@foobar.net> { name : 'Bar', flavor : 'email', remote : 'baz@foobar.com' }
@JoeUser@some.host.com { name : 'Joe User', flavor : 'activitypub', remote 'JoeUser@some.host.com' }
*/
function getAddressedToInfo(input) {
input = input.trim();
@ -55,6 +56,20 @@ function getAddressedToInfo(input) {
return { name: input, flavor: Message.AddressFlavor.Local };
}
if (firstAtPos === 0) {
const secondAtPos = input.indexOf('@', 1);
if (secondAtPos > 0) {
const m = input.slice(1).match(EMAIL_REGEX);
if (m) {
return {
name: input.slice(1, secondAtPos),
flavor: Message.AddressFlavor.ActivityPub,
remote: input.slice(firstAtPos),
};
}
}
}
const lessThanPos = input.indexOf('<');
const greaterThanPos = input.indexOf('>');
if (lessThanPos > 0 && greaterThanPos > lessThanPos) {

View File

@ -56,6 +56,7 @@ const ADDRESS_FLAVOR = {
Email: 'email', // From email
QWK: 'qwk', // QWK packet
NNTP: 'nntp', // NNTP article POST; often a email address
ActivityPub: 'activitypub', // ActivityPub, Mastodon, etc.
};
const STATE_FLAGS0 = {

View File

@ -229,6 +229,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
return;
}
// :TODO: This stuff should probably be lifted out so it can be called ad-hoc from the queue
const accept = Activity.makeAccept(
this.webServer,
localActor,
@ -281,6 +282,11 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
'Unexpected status code'
);
}
this.log.trace(
{ inbox: actor.inbox },
'Remote server received our "Accept" successfully'
);
}
);
});