diff --git a/packages/backend/src/server/api/mastodon/endpoints/status.ts b/packages/backend/src/server/api/mastodon/endpoints/status.ts index 20ef0a76c..aae551b06 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/status.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/status.ts @@ -24,7 +24,7 @@ export class ApiStatusMastodon { const accessTokens = _request.headers.authorization; const client = getClient(BASE_URL, accessTokens); try { - const data = await client.getStatus(convertId(_request.params.id, IdType.SharkeyId)); + const data = await client.getStatus(convertId(_request.params.id, IdType.SharkeyId), BASE_URL); reply.send(convertStatus(data.data)); } catch (e: any) { console.error(e); diff --git a/packages/backend/src/server/api/mastodon/endpoints/timeline.ts b/packages/backend/src/server/api/mastodon/endpoints/timeline.ts index a17120516..70f0a4ad9 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/timeline.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/timeline.ts @@ -51,8 +51,8 @@ export class ApiTimelineMastodon { try { const query: any = _request.query; const data = query.local === 'true' - ? await client.getLocalTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query)))) - : await client.getPublicTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query)))); + ? await client.getLocalTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query))), BASE_URL) + : await client.getPublicTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query))), BASE_URL); reply.send(data.data.map((status: Entity.Status) => convertStatus(status))); } catch (e: any) { console.error(e); @@ -69,7 +69,7 @@ export class ApiTimelineMastodon { const client = getClient(BASE_URL, accessTokens); try { const query: any = _request.query; - const data = await client.getHomeTimeline(convertTimelinesArgsId(limitToInt(query))); + const data = await client.getHomeTimeline(convertTimelinesArgsId(limitToInt(query)), BASE_URL); reply.send(data.data.map((status: Entity.Status) => convertStatus(status))); } catch (e: any) { console.error(e); @@ -87,7 +87,7 @@ export class ApiTimelineMastodon { try { const query: any = _request.query; const params: any = _request.params; - const data = await client.getTagTimeline(params.hashtag, convertTimelinesArgsId(limitToInt(query))); + const data = await client.getTagTimeline(params.hashtag, convertTimelinesArgsId(limitToInt(query)), BASE_URL); reply.send(data.data.map((status: Entity.Status) => convertStatus(status))); } catch (e: any) { console.error(e); diff --git a/packages/megalodon/src/megalodon.ts b/packages/megalodon/src/megalodon.ts index 19cd5c555..7550438c5 100644 --- a/packages/megalodon/src/megalodon.ts +++ b/packages/megalodon/src/megalodon.ts @@ -682,7 +682,7 @@ export interface MegalodonInterface { * @param id The target status id. * @return Status */ - getStatus(id: string): Promise> + getStatus(id: string, host?: string): Promise> /** * Edit a given status to change its text, sensitivity, media attachments, or poll. Note that editing a poll’s options will reset the votes. * @@ -925,7 +925,7 @@ export interface MegalodonInterface { max_id?: string since_id?: string min_id?: string - }): Promise>> + }, host?: string): Promise>> /** * View local timeline. * @@ -942,7 +942,7 @@ export interface MegalodonInterface { max_id?: string since_id?: string min_id?: string - }): Promise>> + }, host?: string): Promise>> /** * View hashtag timeline. * @@ -964,7 +964,8 @@ export interface MegalodonInterface { max_id?: string since_id?: string min_id?: string - } + }, + host?: string ): Promise>> /** * View home timeline. @@ -982,7 +983,7 @@ export interface MegalodonInterface { max_id?: string since_id?: string min_id?: string - }): Promise>> + }, host?: string): Promise>> /** * View list timeline. * diff --git a/packages/megalodon/src/misskey.ts b/packages/megalodon/src/misskey.ts index 39c768591..2891b2cd0 100644 --- a/packages/megalodon/src/misskey.ts +++ b/packages/megalodon/src/misskey.ts @@ -1094,12 +1094,12 @@ export default class Misskey implements MegalodonInterface { /** * POST /api/notes/show */ - public async getStatus(id: string): Promise> { + public async getStatus(id: string, host: string): Promise> { return this.client .post('/api/notes/show', { noteId: id }) - .then(res => ({ ...res, data: MisskeyAPI.Converter.note(res.data) })) + .then(res => ({ ...res, data: MisskeyAPI.Converter.note(res.data, host) })) } public async editStatus( @@ -1449,7 +1449,7 @@ export default class Misskey implements MegalodonInterface { max_id?: string since_id?: string min_id?: string - }): Promise>> { + }, host?: string): Promise>> { let params = {} if (options) { if (options.only_media !== undefined) { @@ -1480,7 +1480,7 @@ export default class Misskey implements MegalodonInterface { } return this.client .post>('/api/notes/global-timeline', params) - .then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n)) })) + .then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n, host)) })) } /** @@ -1492,7 +1492,7 @@ export default class Misskey implements MegalodonInterface { max_id?: string since_id?: string min_id?: string - }): Promise>> { + }, host?: string): Promise>> { let params = {} if (options) { if (options.only_media !== undefined) { @@ -1523,7 +1523,7 @@ export default class Misskey implements MegalodonInterface { } return this.client .post>('/api/notes/local-timeline', params) - .then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n)) })) + .then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n, host)) })) } /** @@ -1538,7 +1538,8 @@ export default class Misskey implements MegalodonInterface { max_id?: string since_id?: string min_id?: string - } + }, + host?: string ): Promise>> { let params = { tag: hashtag @@ -1572,7 +1573,7 @@ export default class Misskey implements MegalodonInterface { } return this.client .post>('/api/notes/search-by-tag', params) - .then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n)) })) + .then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n, host)) })) } /** @@ -1584,7 +1585,7 @@ export default class Misskey implements MegalodonInterface { max_id?: string since_id?: string min_id?: string - }): Promise>> { + }, host?: string): Promise>> { let params = { withFiles: false } @@ -1612,7 +1613,7 @@ export default class Misskey implements MegalodonInterface { } return this.client .post>('/api/notes/timeline', params) - .then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n)) })) + .then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n, host)) })) } /** diff --git a/packages/megalodon/src/misskey/api_client.ts b/packages/megalodon/src/misskey/api_client.ts index ead094aca..aa0cabcff 100644 --- a/packages/megalodon/src/misskey/api_client.ts +++ b/packages/megalodon/src/misskey/api_client.ts @@ -253,7 +253,7 @@ namespace MisskeyAPI { id: n.id, uri: n.uri ? n.uri : host ? `https://${host}/notes/${n.id}` : '', url: n.url ? n.url : host ? `https://${host}/notes/${n.id}` : '', - account: user(n.user, host ? host : null), + account: user(n.user, n.user.host ? n.user.host : host ? host : null), in_reply_to_id: n.replyId, in_reply_to_account_id: null, reblog: n.renote ? note(n.renote) : null,