mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Add fallback to Object intent for FEP-3b86 in remote interaction helper (#38130)
This commit is contained in:
@@ -13,7 +13,8 @@
|
||||
- [FEP-f1d5: NodeInfo in Fediverse Software](https://codeberg.org/fediverse/fep/src/branch/main/fep/f1d5/fep-f1d5.md)
|
||||
- [FEP-8fcf: Followers collection synchronization across servers](https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md)
|
||||
- [FEP-5feb: Search indexing consent for actors](https://codeberg.org/fediverse/fep/src/branch/main/fep/5feb/fep-5feb.md)
|
||||
- [FEP-044f: Consent-respecting quote posts](https://codeberg.org/fediverse/fep/src/branch/main/fep/044f/fep-044f.md): partial support for incoming quote-posts
|
||||
- [FEP-044f: Consent-respecting quote posts](https://codeberg.org/fediverse/fep/src/branch/main/fep/044f/fep-044f.md)
|
||||
- [FEP-3b86: Activity Intents](https://codeberg.org/fediverse/fep/src/branch/main/fep/3b86/fep-3b86.md): offer handlers for `Object` and `Create` (with support for the `content` parameter only), has support for the `Follow`, `Announce`, `Like` and `Object` intents
|
||||
|
||||
## ActivityPub in Mastodon
|
||||
|
||||
|
||||
@@ -39,26 +39,27 @@ const findLink = (rel: string, data: unknown): JRDLink | undefined => {
|
||||
}
|
||||
};
|
||||
|
||||
const intentParams = (intent: string) => {
|
||||
const intentParams = (intent: string): [string, string] | null => {
|
||||
switch (intent) {
|
||||
case 'follow':
|
||||
return ['https://w3id.org/fep/3b86/Follow', 'object'] as [string, string];
|
||||
return ['https://w3id.org/fep/3b86/Follow', 'object'];
|
||||
case 'reblog':
|
||||
return ['https://w3id.org/fep/3b86/Announce', 'object'] as [
|
||||
string,
|
||||
string,
|
||||
];
|
||||
return ['https://w3id.org/fep/3b86/Announce', 'object'];
|
||||
case 'favourite':
|
||||
return ['https://w3id.org/fep/3b86/Like', 'object'] as [string, string];
|
||||
return ['https://w3id.org/fep/3b86/Like', 'object'];
|
||||
case 'vote':
|
||||
case 'reply':
|
||||
return ['https://w3id.org/fep/3b86/Object', 'object'] as [string, string];
|
||||
return ['https://w3id.org/fep/3b86/Object', 'object'];
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const findTemplateLink = (data: unknown, intent: string) => {
|
||||
const findTemplateLink = (
|
||||
data: unknown,
|
||||
intent: string,
|
||||
): [string, string] | [null, null] => {
|
||||
// Find the FEP-3b86 handler for the specific intent
|
||||
const [needle, param] = intentParams(intent) ?? [
|
||||
'http://ostatus.org/schema/1.0/subscribe',
|
||||
'uri',
|
||||
@@ -66,14 +67,21 @@ const findTemplateLink = (data: unknown, intent: string) => {
|
||||
|
||||
const match = findLink(needle, data);
|
||||
|
||||
if (match) {
|
||||
return [match.template, param] as [string, string];
|
||||
if (match?.template) {
|
||||
return [match.template, param];
|
||||
}
|
||||
|
||||
const fallback = findLink('http://ostatus.org/schema/1.0/subscribe', data);
|
||||
// If the specific intent wasn't found, try the FEP-3b86 handler for the `Object` intent
|
||||
let fallback = findLink('https://w3id.org/fep/3b86/Object', data);
|
||||
if (fallback?.template) {
|
||||
return [fallback.template, 'object'];
|
||||
}
|
||||
|
||||
if (fallback) {
|
||||
return [fallback.template, 'uri'] as [string, string];
|
||||
// If it's still not found, try the legacy OStatus subscribe handler
|
||||
fallback = findLink('http://ostatus.org/schema/1.0/subscribe', data);
|
||||
|
||||
if (fallback?.template) {
|
||||
return [fallback.template, 'uri'];
|
||||
}
|
||||
|
||||
return [null, null];
|
||||
|
||||
Reference in New Issue
Block a user