fix: megalodon reblogged and favourited user info, add createdAt to note

This commit is contained in:
Mar0xy 2023-09-25 03:55:21 +02:00
parent 74213ba2b9
commit a7778e6425
No known key found for this signature in database
GPG Key ID: 56569BBE47D2C828
5 changed files with 11 additions and 9 deletions

View File

@ -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));
const data = await client.getStatusRebloggedBy(convertId(_request.params.id, IdType.SharkeyId), BASE_URL);
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));
const data = await client.getStatusFavouritedBy(convertId(_request.params.id, IdType.SharkeyId), BASE_URL);
reply.send(data.data.map((account: Entity.Account) => convertAccount(account)));
} catch (e: any) {
console.error(e);

View File

@ -19,6 +19,7 @@ namespace Entity {
content: string
plain_content: string | null
created_at: string
createdAt?: string
emojis: Emoji[]
replies_count: number
reblogs_count: number

View File

@ -734,14 +734,14 @@ export interface MegalodonInterface {
* @param id The target status id.
* @return Array of accounts.
*/
getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>>
getStatusRebloggedBy(id: string, host?: string): Promise<Response<Array<Entity.Account>>>
/**
* See who favourited a status
*
* @param id The target status id.
* @return Array of accounts.
*/
getStatusFavouritedBy(id: string): Promise<Response<Array<Entity.Account>>>
getStatusFavouritedBy(id: string, host?: string): Promise<Response<Array<Entity.Account>>>
/**
* Favourite a status.
*

View File

@ -1177,25 +1177,25 @@ export default class Misskey implements MegalodonInterface {
/**
* POST /api/notes/renotes
*/
public async getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>> {
public async getStatusRebloggedBy(id: string, host?: 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))
data: res.data.map(n => MisskeyAPI.Converter.user(n.user, host))
}))
}
public async getStatusFavouritedBy(_id: string): Promise<Response<Array<Entity.Account>>> {
public async getStatusFavouritedBy(_id: string, host?: string): Promise<Response<Array<Entity.Account>>> {
return this.client.post<Array<MisskeyAPI.Entity.Reaction>>("/api/notes/reactions", {
noteId: _id,
})
.then(async (res) => ({
...res,
data: (
await Promise.all(res.data.map((n) => this.getAccount(n.user.id)))
await Promise.all(res.data.map((n) => this.getAccount(n.user.id, host)))
).map((p) => p.data),
}));
}

View File

@ -256,7 +256,7 @@ namespace MisskeyAPI {
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,
reblog: n.renote ? note(n.renote, n.user.host ? n.user.host : host ? host : null) : null,
content: n.text
? n.text
.replace(/&/g, '&amp;')
@ -269,6 +269,7 @@ namespace MisskeyAPI {
: '',
plain_content: n.text ? n.text : null,
created_at: n.createdAt,
createdAt: n.createdAt,
emojis: mapEmojis(n.emojis).concat(mapReactionEmojis(n.reactionEmojis)),
replies_count: n.repliesCount,
reblogs_count: n.renoteCount,