chore: use this.baseUrl instead of BASE_URL
This commit is contained in:
parent
aaa3a34d60
commit
0547940523
@ -49,7 +49,7 @@ async function getFeaturedUser( BASE_URL: string, host: string, accessTokens: st
|
||||
return data.map((u) => {
|
||||
return {
|
||||
source: 'past_interactions',
|
||||
account: Converter.userDetail(u, host),
|
||||
account: Converter.userDetail(u),
|
||||
};
|
||||
});
|
||||
} catch (e: any) {
|
||||
|
@ -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), BASE_URL);
|
||||
const data = await client.getStatus(convertId(_request.params.id, IdType.SharkeyId));
|
||||
reply.send(convertStatus(data.data));
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
@ -71,7 +71,7 @@ export class ApiStatusMastodon {
|
||||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const data = await client.getStatusRebloggedBy(convertId(_request.params.id, IdType.SharkeyId), BASE_URL);
|
||||
const data = await client.getStatusRebloggedBy(convertId(_request.params.id, IdType.SharkeyId));
|
||||
reply.send(data.data.map((account: Entity.Account) => convertAccount(account)));
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
@ -86,7 +86,7 @@ export class ApiStatusMastodon {
|
||||
const accessTokens = _request.headers.authorization;
|
||||
const client = getClient(BASE_URL, accessTokens);
|
||||
try {
|
||||
const data = await client.getStatusFavouritedBy(convertId(_request.params.id, IdType.SharkeyId), BASE_URL);
|
||||
const data = await client.getStatusFavouritedBy(convertId(_request.params.id, IdType.SharkeyId));
|
||||
reply.send(data.data.map((account: Entity.Account) => convertAccount(account)));
|
||||
} 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))), BASE_URL)
|
||||
: await client.getPublicTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query))), BASE_URL);
|
||||
? await client.getLocalTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query))))
|
||||
: await client.getPublicTimeline(convertTimelinesArgsId(argsToBools(limitToInt(query))));
|
||||
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)), BASE_URL);
|
||||
const data = await client.getHomeTimeline(convertTimelinesArgsId(limitToInt(query)));
|
||||
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)), BASE_URL);
|
||||
const data = await client.getTagTimeline(params.hashtag, convertTimelinesArgsId(limitToInt(query)));
|
||||
reply.send(data.data.map((status: Entity.Status) => convertStatus(status)));
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
|
@ -156,7 +156,7 @@ export interface MegalodonInterface {
|
||||
* @param id The account ID.
|
||||
* @return An account.
|
||||
*/
|
||||
getAccount(id: string, host?: string): Promise<Response<Entity.Account>>
|
||||
getAccount(id: string): Promise<Response<Entity.Account>>
|
||||
/**
|
||||
* Statuses posted to the given account.
|
||||
*
|
||||
@ -182,8 +182,7 @@ export interface MegalodonInterface {
|
||||
exclude_replies?: boolean
|
||||
exclude_reblogs?: boolean
|
||||
only_media?: boolean
|
||||
},
|
||||
host?: string
|
||||
}
|
||||
): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* Favourites timeline of any user.
|
||||
@ -683,7 +682,7 @@ export interface MegalodonInterface {
|
||||
* @param id The target status id.
|
||||
* @return Status
|
||||
*/
|
||||
getStatus(id: string, host?: string): Promise<Response<Entity.Status>>
|
||||
getStatus(id: 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.
|
||||
*
|
||||
@ -734,14 +733,14 @@ export interface MegalodonInterface {
|
||||
* @param id The target status id.
|
||||
* @return Array of accounts.
|
||||
*/
|
||||
getStatusRebloggedBy(id: string, host?: string): Promise<Response<Array<Entity.Account>>>
|
||||
getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>>
|
||||
/**
|
||||
* See who favourited a status
|
||||
*
|
||||
* @param id The target status id.
|
||||
* @return Array of accounts.
|
||||
*/
|
||||
getStatusFavouritedBy(id: string, host?: string): Promise<Response<Array<Entity.Account>>>
|
||||
getStatusFavouritedBy(id: string): Promise<Response<Array<Entity.Account>>>
|
||||
/**
|
||||
* Favourite a status.
|
||||
*
|
||||
@ -926,7 +925,7 @@ export interface MegalodonInterface {
|
||||
max_id?: string
|
||||
since_id?: string
|
||||
min_id?: string
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>>
|
||||
}): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* View local timeline.
|
||||
*
|
||||
@ -943,7 +942,7 @@ export interface MegalodonInterface {
|
||||
max_id?: string
|
||||
since_id?: string
|
||||
min_id?: string
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>>
|
||||
}): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* View hashtag timeline.
|
||||
*
|
||||
@ -965,8 +964,7 @@ export interface MegalodonInterface {
|
||||
max_id?: string
|
||||
since_id?: string
|
||||
min_id?: string
|
||||
},
|
||||
host?: string
|
||||
}
|
||||
): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* View home timeline.
|
||||
@ -984,7 +982,7 @@ export interface MegalodonInterface {
|
||||
max_id?: string
|
||||
since_id?: string
|
||||
min_id?: string
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>>
|
||||
}): Promise<Response<Array<Entity.Status>>>
|
||||
/**
|
||||
* View list timeline.
|
||||
*
|
||||
|
@ -291,8 +291,7 @@ export default class Misskey implements MegalodonInterface {
|
||||
exclude_replies: boolean
|
||||
exclude_reblogs: boolean
|
||||
only_media?: boolean
|
||||
},
|
||||
host?: string
|
||||
}
|
||||
): Promise<Response<Array<Entity.Status>>> {
|
||||
if (options && options.pinned) {
|
||||
return this.client
|
||||
@ -343,7 +342,7 @@ export default class Misskey implements MegalodonInterface {
|
||||
}
|
||||
}
|
||||
return this.client.post<Array<MisskeyAPI.Entity.Note>>('/api/users/notes', params).then(res => {
|
||||
const statuses: Array<Entity.Status> = res.data.map(note => MisskeyAPI.Converter.note(note, host))
|
||||
const statuses: Array<Entity.Status> = res.data.map(note => MisskeyAPI.Converter.note(note, this.baseUrl))
|
||||
return Object.assign(res, {
|
||||
data: statuses
|
||||
})
|
||||
@ -1132,12 +1131,12 @@ export default class Misskey implements MegalodonInterface {
|
||||
/**
|
||||
* POST /api/notes/show
|
||||
*/
|
||||
public async getStatus(id: string, host: string): Promise<Response<Entity.Status>> {
|
||||
public async getStatus(id: 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, host) }))
|
||||
.then(res => ({ ...res, data: MisskeyAPI.Converter.note(res.data, this.baseUrl) }))
|
||||
}
|
||||
|
||||
public async editStatus(
|
||||
@ -1214,14 +1213,14 @@ export default class Misskey implements MegalodonInterface {
|
||||
/**
|
||||
* POST /api/notes/renotes
|
||||
*/
|
||||
public async getStatusRebloggedBy(id: string, host?: string): Promise<Response<Array<Entity.Account>>> {
|
||||
public async getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>> {
|
||||
return this.client
|
||||
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/renotes', {
|
||||
noteId: id
|
||||
})
|
||||
.then(res => ({
|
||||
...res,
|
||||
data: res.data.map(n => MisskeyAPI.Converter.user(n.user, host))
|
||||
data: res.data.map(n => MisskeyAPI.Converter.user(n.user, this.baseUrl))
|
||||
}))
|
||||
}
|
||||
|
||||
@ -1492,7 +1491,7 @@ export default class Misskey implements MegalodonInterface {
|
||||
max_id?: string
|
||||
since_id?: string
|
||||
min_id?: string
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>> {
|
||||
}): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (options) {
|
||||
if (options.only_media !== undefined) {
|
||||
@ -1523,7 +1522,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, host)) }))
|
||||
.then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n, this.baseUrl)) }))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1535,7 +1534,7 @@ export default class Misskey implements MegalodonInterface {
|
||||
max_id?: string
|
||||
since_id?: string
|
||||
min_id?: string
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>> {
|
||||
}): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {}
|
||||
if (options) {
|
||||
if (options.only_media !== undefined) {
|
||||
@ -1566,7 +1565,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, host)) }))
|
||||
.then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n, this.baseUrl)) }))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1581,8 +1580,7 @@ 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
|
||||
@ -1616,7 +1614,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, host)) }))
|
||||
.then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n, this.baseUrl)) }))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1628,7 +1626,7 @@ export default class Misskey implements MegalodonInterface {
|
||||
max_id?: string
|
||||
since_id?: string
|
||||
min_id?: string
|
||||
}, host?: string): Promise<Response<Array<Entity.Status>>> {
|
||||
}): Promise<Response<Array<Entity.Status>>> {
|
||||
let params = {
|
||||
withFiles: false
|
||||
}
|
||||
@ -1656,7 +1654,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, host)) }))
|
||||
.then(res => ({ ...res, data: res.data.map(n => MisskeyAPI.Converter.note(n, this.baseUrl)) }))
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user