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 accessTokens = _request.headers.authorization;
|
||||||
const client = getClient(BASE_URL, accessTokens);
|
const client = getClient(BASE_URL, accessTokens);
|
||||||
try {
|
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));
|
reply.send(convertStatus(data.data));
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
@ -51,8 +51,8 @@ export class ApiTimelineMastodon {
|
|||||||
try {
|
try {
|
||||||
const query: any = _request.query;
|
const query: any = _request.query;
|
||||||
const data = query.local === 'true'
|
const data = query.local === 'true'
|
||||||
? await client.getLocalTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query))))
|
? await client.getLocalTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query))), BASE_URL)
|
||||||
: await client.getPublicTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query))));
|
: await client.getPublicTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query))), BASE_URL);
|
||||||
reply.send(data.data.map((status: Entity.Status) => convertStatus(status)));
|
reply.send(data.data.map((status: Entity.Status) => convertStatus(status)));
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@ -69,7 +69,7 @@ export class ApiTimelineMastodon {
|
|||||||
const client = getClient(BASE_URL, accessTokens);
|
const client = getClient(BASE_URL, accessTokens);
|
||||||
try {
|
try {
|
||||||
const query: any = _request.query;
|
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)));
|
reply.send(data.data.map((status: Entity.Status) => convertStatus(status)));
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@ -87,7 +87,7 @@ export class ApiTimelineMastodon {
|
|||||||
try {
|
try {
|
||||||
const query: any = _request.query;
|
const query: any = _request.query;
|
||||||
const params: any = _request.params;
|
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)));
|
reply.send(data.data.map((status: Entity.Status) => convertStatus(status)));
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
@ -682,7 +682,7 @@ export interface MegalodonInterface {
|
|||||||
* @param id The target status id.
|
* @param id The target status id.
|
||||||
* @return Status
|
* @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.
|
* 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
|
max_id?: string
|
||||||
since_id?: string
|
since_id?: string
|
||||||
min_id?: string
|
min_id?: string
|
||||||
}): Promise<Response<Array<Entity.Status>>>
|
}, host?: string): Promise<Response<Array<Entity.Status>>>
|
||||||
/**
|
/**
|
||||||
* View local timeline.
|
* View local timeline.
|
||||||
*
|
*
|
||||||
@ -942,7 +942,7 @@ export interface MegalodonInterface {
|
|||||||
max_id?: string
|
max_id?: string
|
||||||
since_id?: string
|
since_id?: string
|
||||||
min_id?: string
|
min_id?: string
|
||||||
}): Promise<Response<Array<Entity.Status>>>
|
}, host?: string): Promise<Response<Array<Entity.Status>>>
|
||||||
/**
|
/**
|
||||||
* View hashtag timeline.
|
* View hashtag timeline.
|
||||||
*
|
*
|
||||||
@ -964,7 +964,8 @@ export interface MegalodonInterface {
|
|||||||
max_id?: string
|
max_id?: string
|
||||||
since_id?: string
|
since_id?: string
|
||||||
min_id?: string
|
min_id?: string
|
||||||
}
|
},
|
||||||
|
host?: string
|
||||||
): Promise<Response<Array<Entity.Status>>>
|
): Promise<Response<Array<Entity.Status>>>
|
||||||
/**
|
/**
|
||||||
* View home timeline.
|
* View home timeline.
|
||||||
@ -982,7 +983,7 @@ export interface MegalodonInterface {
|
|||||||
max_id?: string
|
max_id?: string
|
||||||
since_id?: string
|
since_id?: string
|
||||||
min_id?: string
|
min_id?: string
|
||||||
}): Promise<Response<Array<Entity.Status>>>
|
}, host?: string): Promise<Response<Array<Entity.Status>>>
|
||||||
/**
|
/**
|
||||||
* View list timeline.
|
* View list timeline.
|
||||||
*
|
*
|
||||||
|
@ -1094,12 +1094,12 @@ export default class Misskey implements MegalodonInterface {
|
|||||||
/**
|
/**
|
||||||
* POST /api/notes/show
|
* 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
|
return this.client
|
||||||
.post<MisskeyAPI.Entity.Note>('/api/notes/show', {
|
.post<MisskeyAPI.Entity.Note>('/api/notes/show', {
|
||||||
noteId: id
|
noteId: id
|
||||||
})
|
})
|
||||||
.then(res => ({ ...res, data: MisskeyAPI.Converter.note(res.data) }))
|
.then(res => ({ ...res, data: MisskeyAPI.Converter.note(res.data, host) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
public async editStatus(
|
public async editStatus(
|
||||||
@ -1449,7 +1449,7 @@ export default class Misskey implements MegalodonInterface {
|
|||||||
max_id?: string
|
max_id?: string
|
||||||
since_id?: string
|
since_id?: string
|
||||||
min_id?: string
|
min_id?: string
|
||||||
}): Promise<Response<Array<Entity.Status>>> {
|
}, host?: string): Promise<Response<Array<Entity.Status>>> {
|
||||||
let params = {}
|
let params = {}
|
||||||
if (options) {
|
if (options) {
|
||||||
if (options.only_media !== undefined) {
|
if (options.only_media !== undefined) {
|
||||||
@ -1480,7 +1480,7 @@ export default class Misskey implements MegalodonInterface {
|
|||||||
}
|
}
|
||||||
return this.client
|
return this.client
|
||||||
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/global-timeline', params)
|
.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
|
max_id?: string
|
||||||
since_id?: string
|
since_id?: string
|
||||||
min_id?: string
|
min_id?: string
|
||||||
}): Promise<Response<Array<Entity.Status>>> {
|
}, host?: string): Promise<Response<Array<Entity.Status>>> {
|
||||||
let params = {}
|
let params = {}
|
||||||
if (options) {
|
if (options) {
|
||||||
if (options.only_media !== undefined) {
|
if (options.only_media !== undefined) {
|
||||||
@ -1523,7 +1523,7 @@ export default class Misskey implements MegalodonInterface {
|
|||||||
}
|
}
|
||||||
return this.client
|
return this.client
|
||||||
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/local-timeline', params)
|
.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
|
max_id?: string
|
||||||
since_id?: string
|
since_id?: string
|
||||||
min_id?: string
|
min_id?: string
|
||||||
}
|
},
|
||||||
|
host?: string
|
||||||
): Promise<Response<Array<Entity.Status>>> {
|
): Promise<Response<Array<Entity.Status>>> {
|
||||||
let params = {
|
let params = {
|
||||||
tag: hashtag
|
tag: hashtag
|
||||||
@ -1572,7 +1573,7 @@ export default class Misskey implements MegalodonInterface {
|
|||||||
}
|
}
|
||||||
return this.client
|
return this.client
|
||||||
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/search-by-tag', params)
|
.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
|
max_id?: string
|
||||||
since_id?: string
|
since_id?: string
|
||||||
min_id?: string
|
min_id?: string
|
||||||
}): Promise<Response<Array<Entity.Status>>> {
|
}, host?: string): Promise<Response<Array<Entity.Status>>> {
|
||||||
let params = {
|
let params = {
|
||||||
withFiles: false
|
withFiles: false
|
||||||
}
|
}
|
||||||
@ -1612,7 +1613,7 @@ export default class Misskey implements MegalodonInterface {
|
|||||||
}
|
}
|
||||||
return this.client
|
return this.client
|
||||||
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/timeline', params)
|
.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,
|
id: n.id,
|
||||||
uri: n.uri ? n.uri : host ? `https://${host}/notes/${n.id}` : '',
|
uri: n.uri ? n.uri : host ? `https://${host}/notes/${n.id}` : '',
|
||||||
url: n.url ? n.url : 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_id: n.replyId,
|
||||||
in_reply_to_account_id: null,
|
in_reply_to_account_id: null,
|
||||||
reblog: n.renote ? note(n.renote) : null,
|
reblog: n.renote ? note(n.renote) : null,
|
||||||
|
Loading…
Reference in New Issue
Block a user