feat: Like(Note) and Undo(Like); federating likes

This commit is contained in:
Julian Lam
2024-02-01 15:59:29 -05:00
parent 94361721b1
commit 607c4623c7
9 changed files with 108 additions and 20 deletions

View File

@@ -94,7 +94,7 @@ Helpers.resolveLocalUid = async (input) => {
const { host, pathname } = new URL(input);
if (host === nconf.get('url_parsed').host) {
const [type, value] = pathname.replace(nconf.get('relative_path'), '').split('/').filter(Boolean)[1];
const [type, value] = pathname.replace(nconf.get('relative_path'), '').split('/').filter(Boolean);
if (type === 'uid') {
return value;
}
@@ -111,3 +111,17 @@ Helpers.resolveLocalUid = async (input) => {
return await user.getUidByUserslug(slug);
};
Helpers.resolveLocalPid = async (uri) => {
const { host, pathname } = new URL(uri);
if (host === nconf.get('url_parsed').host) {
const [type, value] = pathname.replace(nconf.get('relative_path'), '').split('/').filter(Boolean);
if (type !== 'post') {
throw new Error('[[error:activitypub.invalid-id]]');
}
return value;
}
throw new Error('[[error:activitypub.invalid-id]]');
};