Add intiial 'flavor' for ActivityPub messages
This commit is contained in:
parent
01cd91b045
commit
ef118325ba
|
@ -21,6 +21,7 @@ const EMAIL_REGEX =
|
||||||
43:20/100.2 { flavor : 'ftn', remote : '43:20/100.2' }
|
43:20/100.2 { flavor : 'ftn', remote : '43:20/100.2' }
|
||||||
foo@host.com { name : 'foo', flavor : 'email', remote : 'foo@host.com' }
|
foo@host.com { name : 'foo', flavor : 'email', remote : 'foo@host.com' }
|
||||||
Bar <baz@foobar.net> { name : 'Bar', flavor : 'email', remote : 'baz@foobar.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) {
|
function getAddressedToInfo(input) {
|
||||||
input = input.trim();
|
input = input.trim();
|
||||||
|
@ -55,6 +56,20 @@ function getAddressedToInfo(input) {
|
||||||
return { name: input, flavor: Message.AddressFlavor.Local };
|
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 lessThanPos = input.indexOf('<');
|
||||||
const greaterThanPos = input.indexOf('>');
|
const greaterThanPos = input.indexOf('>');
|
||||||
if (lessThanPos > 0 && greaterThanPos > lessThanPos) {
|
if (lessThanPos > 0 && greaterThanPos > lessThanPos) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ const ADDRESS_FLAVOR = {
|
||||||
Email: 'email', // From email
|
Email: 'email', // From email
|
||||||
QWK: 'qwk', // QWK packet
|
QWK: 'qwk', // QWK packet
|
||||||
NNTP: 'nntp', // NNTP article POST; often a email address
|
NNTP: 'nntp', // NNTP article POST; often a email address
|
||||||
|
ActivityPub: 'activitypub', // ActivityPub, Mastodon, etc.
|
||||||
};
|
};
|
||||||
|
|
||||||
const STATE_FLAGS0 = {
|
const STATE_FLAGS0 = {
|
||||||
|
|
|
@ -229,6 +229,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// :TODO: This stuff should probably be lifted out so it can be called ad-hoc from the queue
|
||||||
const accept = Activity.makeAccept(
|
const accept = Activity.makeAccept(
|
||||||
this.webServer,
|
this.webServer,
|
||||||
localActor,
|
localActor,
|
||||||
|
@ -281,6 +282,11 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
||||||
'Unexpected status code'
|
'Unexpected status code'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.log.trace(
|
||||||
|
{ inbox: actor.inbox },
|
||||||
|
'Remote server received our "Accept" successfully'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue