mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-27 20:03:08 +02:00
fix: megalodon reblogged and favourited user info, add createdAt to note
This commit is contained in:
parent
74213ba2b9
commit
a7778e6425
5 changed files with 11 additions and 9 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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),
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -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, '&')
|
||||
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue