Skip to content

Node.js based forum software built for the modern web

feat: handle incoming like/dislike/follow Activity Intents, publish support in webfinger

Julian Lam8f7cb7d944b0
diff --git a/public/src/client/intents.js b/public/src/client/intents.js
index 7c9f9d46fa..8dabbadddc 100644
--- a/public/src/client/intents.js
+++ b/public/src/client/intents.js
@@ -4,22 +4,29 @@ export function init() {
switch(ajaxify.data.intent) {
case 'create': {
if (ajaxify.data?.cid) {
- ajaxify.go(`category/${ajaxify.data.cid}`);
+ ajaxify.go(`category/${encodeURIComponent(ajaxify.data.cid)}`);
app.newTopic(ajaxify.data.cid);
} else if (ajaxify.data?.tid) {
if (ajaxify.data?.toPid) {
- ajaxify.go(`/post/${ajaxify.data.toPid}`);
+ ajaxify.go(`/post/${encodeURIComponent(ajaxify.data.toPid)}`);
} else {
- ajaxify.go(`topic/${ajaxify.data.tid}`);
+ ajaxify.go(`topic/${encodeURIComponent(ajaxify.data.tid)}`);
}
app.newReply({ tid: ajaxify.data.tid, toPid: ajaxify.data.toPid });
}
break;
}
+ case 'dislike': // intentional fall-through
case 'like': {
- ajaxify.go(`/post/${ajaxify.data.pid}`);
+ ajaxify.go(`/post/${encodeURIComponent(ajaxify.data.pid)}`);
// intents.confirm
+ break;
+ }
+
+ case 'follow': {
+ ajaxify.go(`/uid/${encodeURIComponent(ajaxify.data.uid)}`);
+ break;
}
}
}
diff --git a/src/controllers/well-known.js b/src/controllers/well-known.js
index ca95338748..319a8ed29d 100644
--- a/src/controllers/well-known.js
+++ b/src/controllers/well-known.js
@@ -97,6 +97,18 @@ async function profile(uid, response) {
'rel': 'https://w3id.org/fep/3b86/Create',
'template': `${nconf.get('url')}/intents/create?toPid={inReplyTo}&cid={audience}`,
},
+ {
+ 'rel': 'https://w3id.org/fep/3b86/Like',
+ 'template': `${nconf.get('url')}/intents/like?pid={object}`,
+ },
+ {
+ 'rel': 'https://w3id.org/fep/3b86/Dislike',
+ 'template': `${nconf.get('url')}/intents/dislike?pid={object}`,
+ },
+ {
+ 'rel': 'https://w3id.org/fep/3b86/Follow',
+ 'template': `${nconf.get('url')}/intents/follow?uid={object}`,
+ },
);
}