fix: inability to query local content via remote url

This commit is contained in:
Julian Lam
2024-05-07 10:58:39 -04:00
parent 9761526710
commit ac74d9c55e
2 changed files with 16 additions and 6 deletions

View File

@@ -75,8 +75,13 @@ async function searchInContent(data) {
} else { } else {
let result; let result;
if (data.uid && activitypub.helpers.isUri(data.query)) { if (data.uid && activitypub.helpers.isUri(data.query)) {
const local = await activitypub.helpers.resolveLocalId(data.query);
if (local.type === 'post') {
result = [[local.id], []];
} else {
result = await fetchRemoteObject(data.uid, data.query); result = await fetchRemoteObject(data.uid, data.query);
} }
}
if (result) { if (result) {
[pids, tids] = result; [pids, tids] = result;

View File

@@ -44,6 +44,10 @@ module.exports = function (User) {
if (!data.findUids && data.uid) { if (!data.findUids && data.uid) {
const handle = activitypub.helpers.isWebfinger(data.query); const handle = activitypub.helpers.isWebfinger(data.query);
if (handle || activitypub.helpers.isUri(data.query)) { if (handle || activitypub.helpers.isUri(data.query)) {
const local = await activitypub.helpers.resolveLocalId(data.query);
if (local.type === 'user') {
uids = [local.id];
} else {
const assertion = await activitypub.actors.assert([handle || data.query]); const assertion = await activitypub.actors.assert([handle || data.query]);
if (assertion === true) { if (assertion === true) {
uids = [handle ? await User.getUidByUserslug(handle) : query]; uids = [handle ? await User.getUidByUserslug(handle) : query];
@@ -52,6 +56,7 @@ module.exports = function (User) {
} }
} }
} }
}
if (!uids.length) { if (!uids.length) {
const searchMethod = data.findUids || findUids; const searchMethod = data.findUids || findUids;