upd: apply host to alot of fields
This commit is contained in:
parent
1b9897f83b
commit
df62b3786a
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -682,7 +682,7 @@ export interface MegalodonInterface {
|
||||
* @param id The target status id.
|
||||
* @return Status
|
||||
*/
|
||||
getStatus(id: string): Promise<Response<Entity.Status>>
|
||||
getStatus(id: string, host?: string): Promise<Response<Entity.Status>>
|
||||
/**
|
||||
* 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<Response<Array<Entity.Status>>>
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* View local timeline.
|
||||
*
|
||||
@ -942,7 +942,7 @@ export interface MegalodonInterface {
|
||||
max_id?: string
|
||||
since_id?: string
|
||||
min_id?: string
|
||||
}): Promise<Response<Array<Entity.Status>>>
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* View hashtag timeline.
|
||||
*
|
||||
@ -964,7 +964,8 @@ export interface MegalodonInterface {
|
||||
max_id?: string
|
||||
since_id?: string
|
||||
min_id?: string
|
||||
}
|
||||
},
|
||||
host?: string
|
||||
): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* View home timeline.
|
||||
@ -982,7 +983,7 @@ export interface MegalodonInterface {
|
||||
max_id?: string
|
||||
since_id?: string
|
||||
min_id?: string
|
||||
}): Promise<Response<Array<Entity.Status>>>
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* View list timeline.
|
||||
*
|
||||
|
@ -1094,12 +1094,12 @@ export default class Misskey implements MegalodonInterface {
|
||||
/**
|
||||
* POST /api/notes/show
|
||||
*/
|
||||
public async getStatus(id: string): Promise<Response<Entity.Status>> {
|
||||
public async getStatus(id: string, host: string): Promise<Response<Entity.Status>> {
|
||||
return this.client
|
||||
.post<MisskeyAPI.Entity.Note>('/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<Response<Array<Entity.Status>>> {
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (options) {
|
||||
if (options.only_media !== undefined) {
|
||||
@ -1480,7 +1480,7 @@ export default class Misskey implements MegalodonInterface {
|
||||
}
|
||||
return this.client
|
||||
.post<Array<MisskeyAPI.Entity.Note>>('/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<Response<Array<Entity.Status>>> {
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (options) {
|
||||
if (options.only_media !== undefined) {
|
||||
@ -1523,7 +1523,7 @@ export default class Misskey implements MegalodonInterface {
|
||||
}
|
||||
return this.client
|
||||
.post<Array<MisskeyAPI.Entity.Note>>('/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<Response<Array<Entity.Status>>> {
|
||||
let params = {
|
||||
tag: hashtag
|
||||
@ -1572,7 +1573,7 @@ export default class Misskey implements MegalodonInterface {
|
||||
}
|
||||
return this.client
|
||||
.post<Array<MisskeyAPI.Entity.Note>>('/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<Response<Array<Entity.Status>>> {
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {
|
||||
withFiles: false
|
||||
}
|
||||
@ -1612,7 +1613,7 @@ export default class Misskey implements MegalodonInterface {
|
||||
}
|
||||
return this.client
|
||||
.post<Array<MisskeyAPI.Entity.Note>>('/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)) }))
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user