fix(frontend): 照会処理を統一 (#15536)
* fix(frontend): 照会処理を統一 * fix * doLookup -> apLookup
This commit is contained in:
parent
7fb8fccd57
commit
59567a7ccc
@ -120,6 +120,7 @@ import { i18n } from '@/i18n.js';
|
|||||||
import { instance } from '@/instance.js';
|
import { instance } from '@/instance.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
|
import { apLookup } from '@/scripts/lookup.js';
|
||||||
import { useRouter } from '@/router/supplier.js';
|
import { useRouter } from '@/router/supplier.js';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
||||||
@ -260,13 +261,7 @@ async function search() {
|
|||||||
text: i18n.ts.lookupConfirm,
|
text: i18n.ts.lookupConfirm,
|
||||||
});
|
});
|
||||||
if (!confirm.canceled) {
|
if (!confirm.canceled) {
|
||||||
const promise = misskeyApi('ap/show', {
|
const res = await apLookup(searchParams.value.query);
|
||||||
uri: searchParams.value.query,
|
|
||||||
});
|
|
||||||
|
|
||||||
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
|
|
||||||
|
|
||||||
const res = await promise;
|
|
||||||
|
|
||||||
if (res.type === 'User') {
|
if (res.type === 'User') {
|
||||||
router.push(`/@${res.object.username}@${res.object.host}`);
|
router.push(`/@${res.object.username}@${res.object.host}`);
|
||||||
|
@ -29,45 +29,7 @@ export async function lookup(router?: Router) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (query.startsWith('https://')) {
|
if (query.startsWith('https://')) {
|
||||||
const promise = misskeyApi('ap/show', {
|
const res = await apLookup(query);
|
||||||
uri: query,
|
|
||||||
});
|
|
||||||
|
|
||||||
os.promiseDialog(promise, null, (err) => {
|
|
||||||
let title = i18n.ts.somethingHappened;
|
|
||||||
let text = err.message + '\n' + err.id;
|
|
||||||
|
|
||||||
switch (err.id) {
|
|
||||||
case '974b799e-1a29-4889-b706-18d4dd93e266':
|
|
||||||
title = i18n.ts._remoteLookupErrors._federationNotAllowed.title;
|
|
||||||
text = i18n.ts._remoteLookupErrors._federationNotAllowed.description;
|
|
||||||
break;
|
|
||||||
case '1a5eab56-e47b-48c2-8d5e-217b897d70db':
|
|
||||||
title = i18n.ts._remoteLookupErrors._uriInvalid.title;
|
|
||||||
text = i18n.ts._remoteLookupErrors._uriInvalid.description;
|
|
||||||
break;
|
|
||||||
case '81b539cf-4f57-4b29-bc98-032c33c0792e':
|
|
||||||
title = i18n.ts._remoteLookupErrors._requestFailed.title;
|
|
||||||
text = i18n.ts._remoteLookupErrors._requestFailed.description;
|
|
||||||
break;
|
|
||||||
case '70193c39-54f3-4813-82f0-70a680f7495b':
|
|
||||||
title = i18n.ts._remoteLookupErrors._responseInvalid.title;
|
|
||||||
text = i18n.ts._remoteLookupErrors._responseInvalid.description;
|
|
||||||
break;
|
|
||||||
case 'dc94d745-1262-4e63-a17d-fecaa57efc82':
|
|
||||||
title = i18n.ts._remoteLookupErrors._noSuchObject.title;
|
|
||||||
text = i18n.ts._remoteLookupErrors._noSuchObject.description;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
os.alert({
|
|
||||||
type: 'error',
|
|
||||||
title,
|
|
||||||
text,
|
|
||||||
});
|
|
||||||
}, i18n.ts.fetchingAsApObject);
|
|
||||||
|
|
||||||
const res = await promise;
|
|
||||||
|
|
||||||
if (res.type === 'User') {
|
if (res.type === 'User') {
|
||||||
_router.push(`/@${res.object.username}@${res.object.host}`);
|
_router.push(`/@${res.object.username}@${res.object.host}`);
|
||||||
@ -78,3 +40,45 @@ export async function lookup(router?: Router) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function apLookup(query: string) {
|
||||||
|
const promise = misskeyApi('ap/show', {
|
||||||
|
uri: query,
|
||||||
|
});
|
||||||
|
|
||||||
|
os.promiseDialog(promise, null, (err) => {
|
||||||
|
let title = i18n.ts.somethingHappened;
|
||||||
|
let text = err.message + '\n' + err.id;
|
||||||
|
|
||||||
|
switch (err.id) {
|
||||||
|
case '974b799e-1a29-4889-b706-18d4dd93e266':
|
||||||
|
title = i18n.ts._remoteLookupErrors._federationNotAllowed.title;
|
||||||
|
text = i18n.ts._remoteLookupErrors._federationNotAllowed.description;
|
||||||
|
break;
|
||||||
|
case '1a5eab56-e47b-48c2-8d5e-217b897d70db':
|
||||||
|
title = i18n.ts._remoteLookupErrors._uriInvalid.title;
|
||||||
|
text = i18n.ts._remoteLookupErrors._uriInvalid.description;
|
||||||
|
break;
|
||||||
|
case '81b539cf-4f57-4b29-bc98-032c33c0792e':
|
||||||
|
title = i18n.ts._remoteLookupErrors._requestFailed.title;
|
||||||
|
text = i18n.ts._remoteLookupErrors._requestFailed.description;
|
||||||
|
break;
|
||||||
|
case '70193c39-54f3-4813-82f0-70a680f7495b':
|
||||||
|
title = i18n.ts._remoteLookupErrors._responseInvalid.title;
|
||||||
|
text = i18n.ts._remoteLookupErrors._responseInvalid.description;
|
||||||
|
break;
|
||||||
|
case 'dc94d745-1262-4e63-a17d-fecaa57efc82':
|
||||||
|
title = i18n.ts._remoteLookupErrors._noSuchObject.title;
|
||||||
|
text = i18n.ts._remoteLookupErrors._noSuchObject.description;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
os.alert({
|
||||||
|
type: 'error',
|
||||||
|
title,
|
||||||
|
text,
|
||||||
|
});
|
||||||
|
}, i18n.ts.fetchingAsApObject);
|
||||||
|
|
||||||
|
return await promise;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user