Merge pull request '[PR]: [mastodon-client] Various bug fixes' (#10431) from e2net/calckey:fix/various-masto-client-bugs into develop

Reviewed-on: https://codeberg.org/calckey/calckey/pulls/10431
This commit is contained in:
Kainoa Kanter 2023-07-07 22:11:41 +00:00
commit 2e122a2148
5 changed files with 149 additions and 73 deletions

View file

@ -2,8 +2,10 @@ import { Entity } from "megalodon";
import { convertId, IdType } from "../index.js"; import { convertId, IdType } from "../index.js";
function simpleConvert(data: any) { function simpleConvert(data: any) {
data.id = convertId(data.id, IdType.MastodonId); // copy the object to bypass weird pass by reference bugs
return data; const result = Object.assign({}, data);
result.id = convertId(data.id, IdType.MastodonId);
return result;
} }
export function convertAccount(account: Entity.Account) { export function convertAccount(account: Entity.Account) {

View file

@ -30,21 +30,25 @@ export function apiSearchMastodon(router: Router): void {
try { try {
const query: any = convertTimelinesArgsId(limitToInt(ctx.query)); const query: any = convertTimelinesArgsId(limitToInt(ctx.query));
const type = query.type; const type = query.type;
if (type) { const acct =
const data = await client.search(query.q, type, query); !type || type === "accounts"
ctx.body = data.data.accounts.map((account) => convertAccount(account)); ? await client.search(query.q, "accounts", query)
} else { : null;
const acct = await client.search(query.q, "accounts", query); const stat =
const stat = await client.search(query.q, "statuses", query); !type || type === "statuses"
const tags = await client.search(query.q, "hashtags", query); ? await client.search(query.q, "statuses", query)
ctx.body = { : null;
accounts: acct.data.accounts.map((account) => const tags =
convertAccount(account), !type || type === "hashtags"
), ? await client.search(query.q, "hashtags", query)
statuses: stat.data.statuses.map((status) => convertStatus(status)), : null;
hashtags: tags.data.hashtags, ctx.body = {
}; accounts:
} acct?.data?.accounts.map((account) => convertAccount(account)) ?? [],
statuses:
stat?.data?.statuses.map((status) => convertStatus(status)) ?? [],
hashtags: tags?.data?.hashtags ?? [],
};
} catch (e: any) { } catch (e: any) {
console.error(e); console.error(e);
ctx.status = 401; ctx.status = 401;

View file

@ -197,7 +197,19 @@ export function apiStatusMastodon(router: Router): void {
router.get<{ Params: { id: string } }>( router.get<{ Params: { id: string } }>(
"/v1/statuses/:id/favourited_by", "/v1/statuses/:id/favourited_by",
async (ctx) => { async (ctx) => {
ctx.body = []; const BASE_URL = `${ctx.protocol}://${ctx.hostname}`;
const accessTokens = ctx.headers.authorization;
const client = getClient(BASE_URL, accessTokens);
try {
const data = await client.getStatusFavouritedBy(
convertId(ctx.params.id, IdType.CalckeyId),
);
ctx.body = data.data.map((account) => convertAccount(account));
} catch (e: any) {
console.error(e);
ctx.status = 401;
ctx.body = e.response.data;
}
}, },
); );
router.post<{ Params: { id: string } }>( router.post<{ Params: { id: string } }>(

View file

@ -45,13 +45,14 @@ export function apiTimelineMastodon(router: Router): void {
const client = getClient(BASE_URL, accessTokens); const client = getClient(BASE_URL, accessTokens);
try { try {
const query: any = ctx.query; const query: any = ctx.query;
const data = query.local const data =
? await client.getLocalTimeline( query.local === "true"
convertTimelinesArgsId(argsToBools(limitToInt(query))), ? await client.getLocalTimeline(
) convertTimelinesArgsId(argsToBools(limitToInt(query))),
: await client.getPublicTimeline( )
convertTimelinesArgsId(argsToBools(limitToInt(query))), : await client.getPublicTimeline(
); convertTimelinesArgsId(argsToBools(limitToInt(query))),
);
ctx.body = data.data.map((status) => convertStatus(status)); ctx.body = data.data.map((status) => convertStatus(status));
} catch (e: any) { } catch (e: any) {
console.error(e); console.error(e);

View file

@ -10,6 +10,7 @@ import Entity from './entity'
import { MegalodonInterface, WebSocketInterface, NoImplementedError, ArgumentError, UnexpectedError } from './megalodon' import { MegalodonInterface, WebSocketInterface, NoImplementedError, ArgumentError, UnexpectedError } from './megalodon'
import MegalodonEntity from "@/entity"; import MegalodonEntity from "@/entity";
import fs from "node:fs"; import fs from "node:fs";
import MisskeyNotificationType from "./misskey/notification";
type AccountCache = { type AccountCache = {
locks: AsyncLock, locks: AsyncLock,
@ -332,7 +333,7 @@ export default class Misskey implements MegalodonInterface {
if (res.data.pinnedNotes) { if (res.data.pinnedNotes) {
return { return {
...res, ...res,
data: await Promise.all(res.data.pinnedNotes.map(n => this.noteWithMentions(n, this.baseUrlToHost(this.baseUrl), accountCache))) data: await Promise.all(res.data.pinnedNotes.map(n => this.noteWithDetails(n, this.baseUrlToHost(this.baseUrl), accountCache)))
} }
} }
return {...res, data: []} return {...res, data: []}
@ -384,7 +385,7 @@ export default class Misskey implements MegalodonInterface {
}) })
} }
return this.client.post<Array<MisskeyAPI.Entity.Note>>('/api/users/notes', params).then(async res => { return this.client.post<Array<MisskeyAPI.Entity.Note>>('/api/users/notes', params).then(async res => {
const statuses: Array<Entity.Status> = await Promise.all(res.data.map(note => this.noteWithMentions(note, this.baseUrlToHost(this.baseUrl), accountCache))) const statuses: Array<Entity.Status> = await Promise.all(res.data.map(note => this.noteWithDetails(note, this.baseUrlToHost(this.baseUrl), accountCache)))
return Object.assign(res, { return Object.assign(res, {
data: statuses data: statuses
}) })
@ -423,7 +424,7 @@ export default class Misskey implements MegalodonInterface {
} }
return this.client.post<Array<MisskeyAPI.Entity.Favorite>>('/api/users/reactions', params).then(async res => { return this.client.post<Array<MisskeyAPI.Entity.Favorite>>('/api/users/reactions', params).then(async res => {
return Object.assign(res, { return Object.assign(res, {
data: await Promise.all(res.data.map(fav => this.noteWithMentions(fav.note, this.baseUrlToHost(this.baseUrl), accountCache))) data: await Promise.all(res.data.map(fav => this.noteWithDetails(fav.note, this.baseUrlToHost(this.baseUrl), accountCache)))
}) })
}) })
} }
@ -763,7 +764,7 @@ export default class Misskey implements MegalodonInterface {
} }
return this.client.post<Array<MisskeyAPI.Entity.Favorite>>('/api/i/favorites', params).then(async res => { return this.client.post<Array<MisskeyAPI.Entity.Favorite>>('/api/i/favorites', params).then(async res => {
return Object.assign(res, { return Object.assign(res, {
data: await Promise.all(res.data.map(s => this.noteWithMentions(s.note, this.baseUrlToHost(this.baseUrl), accountCache))) data: await Promise.all(res.data.map(s => this.noteWithDetails(s.note, this.baseUrlToHost(this.baseUrl), accountCache)))
}) })
}) })
} }
@ -1221,7 +1222,7 @@ export default class Misskey implements MegalodonInterface {
.post<MisskeyAPI.Entity.CreatedNote>('/api/notes/create', params) .post<MisskeyAPI.Entity.CreatedNote>('/api/notes/create', params)
.then(async res => ({ .then(async res => ({
...res, ...res,
data: await this.noteWithMentions(res.data.createdNote, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache()) data: await this.noteWithDetails(res.data.createdNote, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())
})) }))
} }
@ -1233,7 +1234,7 @@ export default class Misskey implements MegalodonInterface {
.post<MisskeyAPI.Entity.Note>('/api/notes/show', { .post<MisskeyAPI.Entity.Note>('/api/notes/show', {
noteId: id noteId: id
}) })
.then(async res => ({ ...res, data: await this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())})); .then(async res => ({ ...res, data: await this.noteWithDetails(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())}));
} }
private getFreshAccountCache() :AccountCache { private getFreshAccountCache() :AccountCache {
@ -1243,12 +1244,41 @@ export default class Misskey implements MegalodonInterface {
} }
} }
public async noteWithMentions(n: MisskeyAPI.Entity.Note, host: string, cache: AccountCache): Promise<MegalodonEntity.Status> { public async notificationWithDetails(n: MisskeyAPI.Entity.Notification, host: string, cache: AccountCache): Promise<MegalodonEntity.Notification> {
const status = await this.converter.note(n, host); const notification = this.converter.notification(n, host);
return status.mentions.length === 0 ? this.addMentionsToStatus(status, cache) : status; if (n.note)
notification.status = await this.noteWithDetails(n.note, host, cache);
return notification;
}
public async noteWithDetails(n: MisskeyAPI.Entity.Note, host: string, cache: AccountCache): Promise<MegalodonEntity.Status> {
const status = await this.addUserDetailsToStatus(this.converter.note(n, host), cache);
return this.addMentionsToStatus(status, cache);
} }
public async addUserDetailsToStatus(status: Entity.Status, cache: AccountCache) : Promise<Entity.Status> {
if (status.account.followers_count === 0 && status.account.followers_count === 0 && status.account.statuses_count === 0)
status.account = await this.getAccountCached(status.account.id, status.account.acct, cache) ?? status.account;
if (status.reblog != null)
status.reblog = await this.addUserDetailsToStatus(status.reblog, cache);
if (status.quote != null)
status.quote = await this.addUserDetailsToStatus(status.quote, cache);
return status;
}
public async addMentionsToStatus(status: Entity.Status, cache: AccountCache) : Promise<Entity.Status> { public async addMentionsToStatus(status: Entity.Status, cache: AccountCache) : Promise<Entity.Status> {
if (status.mentions.length > 0)
return status;
if (status.reblog != null)
status.reblog = await this.addMentionsToStatus(status.reblog, cache);
if (status.quote != null)
status.quote = await this.addMentionsToStatus(status.quote, cache);
status.mentions = (await this.getMentions(status.plain_content!, cache)).filter(p => p != null); status.mentions = (await this.getMentions(status.plain_content!, cache)).filter(p => p != null);
for (const m of status.mentions.filter((value, index, array) => array.indexOf(value) === index)) { for (const m of status.mentions.filter((value, index, array) => array.indexOf(value) === index)) {
status.content = status.content.replace(`@${m.acct}`, `<a href="${m.url}" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@${m.acct}</a>`); status.content = status.content.replace(`@${m.acct}`, `<a href="${m.url}" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@${m.acct}</a>`);
@ -1257,31 +1287,31 @@ export default class Misskey implements MegalodonInterface {
} }
public async getMentions(text: string, cache: AccountCache): Promise<Entity.Mention[]> { public async getMentions(text: string, cache: AccountCache): Promise<Entity.Mention[]> {
console.log(`getting mentions for message: '${text}'`);
const mentions :Entity.Mention[] = []; const mentions :Entity.Mention[] = [];
if (text == undefined) if (text == undefined)
return mentions; return mentions;
console.log('text is not undefined, continuing');
const mentionMatch = text.matchAll(/(?<=^|\s)@(?<user>.*?)(?:@(?<host>.*?)|)(?=\s|$)/g); const mentionMatch = text.matchAll(/(?<=^|\s)@(?<user>.*?)(?:@(?<host>.*?)|)(?=\s|$)/g);
for (const m of mentionMatch) { for (const m of mentionMatch) {
if (m.groups == null) try {
continue; if (m.groups == null)
continue;
const account = await this.getAccountByNameCached(m.groups.user, m.groups.host, cache); const account = await this.getAccountByNameCached(m.groups.user, m.groups.host, cache);
if (account == null) if (account == null)
continue; continue;
mentions.push({ mentions.push({
id: account.id, id: account.id,
url: account.url, url: account.url,
username: account.username, username: account.username,
acct: account.acct acct: account.acct
}); });
}
catch {}
} }
return mentions; return mentions;
@ -1306,6 +1336,23 @@ export default class Misskey implements MegalodonInterface {
}) })
} }
public async getAccountCached(id: string, acct: string, cache: AccountCache): Promise<Entity.Account | undefined | null> {
return await cache.locks.acquire(acct, async () => {
const cacheHit = cache.accounts.find(p => p.id === id);
const account = cacheHit ?? (await this.getAccount(id)).data;
if (!account) {
return null;
}
if (cacheHit == null) {
cache.accounts.push(account);
}
return account;
})
}
public async editStatus( public async editStatus(
_id: string, _id: string,
_options: { _options: {
@ -1374,11 +1421,11 @@ export default class Misskey implements MegalodonInterface {
return this.client.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/children', params).then(async res => { return this.client.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/children', params).then(async res => {
const accountCache = this.getFreshAccountCache(); const accountCache = this.getFreshAccountCache();
const conversation = await this.client.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/conversation', params); const conversation = await this.client.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/conversation', params);
const parents = await Promise.all(conversation.data.map(n => this.noteWithMentions(n, this.baseUrlToHost(this.baseUrl), accountCache))); const parents = await Promise.all(conversation.data.map(n => this.noteWithDetails(n, this.baseUrlToHost(this.baseUrl), accountCache)));
const context: Entity.Context = { const context: Entity.Context = {
ancestors: parents.reverse(), ancestors: parents.reverse(),
descendants: this.dfs(await Promise.all(res.data.map(n => this.noteWithMentions(n, this.baseUrlToHost(this.baseUrl), accountCache)))) descendants: this.dfs(await Promise.all(res.data.map(n => this.noteWithDetails(n, this.baseUrlToHost(this.baseUrl), accountCache))))
} }
return { return {
...res, ...res,
@ -1446,17 +1493,21 @@ export default class Misskey implements MegalodonInterface {
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/renotes', { .post<Array<MisskeyAPI.Entity.Note>>('/api/notes/renotes', {
noteId: id noteId: id
}) })
.then(res => ({ .then(async res => ({
...res, ...res,
data: res.data.map(n => this.converter.user(n.user)) data: (await Promise.all(res.data.map(n => this.getAccount(n.user.id)))).map(p => p.data)
})) }))
} }
public async getStatusFavouritedBy(_id: string): Promise<Response<Array<Entity.Account>>> { public async getStatusFavouritedBy(id: string): Promise<Response<Array<Entity.Account>>> {
return new Promise((_, reject) => { return this.client
const err = new NoImplementedError('misskey does not support') .post<Array<MisskeyAPI.Entity.Reaction>>('/api/notes/reactions', {
reject(err) noteId: id
}) })
.then(async res => ({
...res,
data: (await Promise.all(res.data.map(n => this.getAccount(n.user.id)))).map(p => p.data)
}))
} }
public async favouriteStatus(id: string): Promise<Response<Entity.Status>> { public async favouriteStatus(id: string): Promise<Response<Entity.Status>> {
@ -1491,7 +1542,7 @@ export default class Misskey implements MegalodonInterface {
}) })
.then(async res => ({ .then(async res => ({
...res, ...res,
data: await this.noteWithMentions(res.data.createdNote, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache()) data: await this.noteWithDetails(res.data.createdNote, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())
})) }))
} }
@ -1506,7 +1557,7 @@ export default class Misskey implements MegalodonInterface {
.post<MisskeyAPI.Entity.Note>('/api/notes/show', { .post<MisskeyAPI.Entity.Note>('/api/notes/show', {
noteId: id noteId: id
}) })
.then(async res => ({...res, data: await this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())})) .then(async res => ({...res, data: await this.noteWithDetails(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())}))
} }
/** /**
@ -1520,7 +1571,7 @@ export default class Misskey implements MegalodonInterface {
.post<MisskeyAPI.Entity.Note>('/api/notes/show', { .post<MisskeyAPI.Entity.Note>('/api/notes/show', {
noteId: id noteId: id
}) })
.then(async res => ({...res, data: await this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())})) .then(async res => ({...res, data: await this.noteWithDetails(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())}))
} }
/** /**
@ -1534,7 +1585,7 @@ export default class Misskey implements MegalodonInterface {
.post<MisskeyAPI.Entity.Note>('/api/notes/show', { .post<MisskeyAPI.Entity.Note>('/api/notes/show', {
noteId: id noteId: id
}) })
.then(async res => ({...res, data: await this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())})) .then(async res => ({...res, data: await this.noteWithDetails(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())}))
} }
public async muteStatus(_id: string): Promise<Response<Entity.Status>> { public async muteStatus(_id: string): Promise<Response<Entity.Status>> {
@ -1562,7 +1613,7 @@ export default class Misskey implements MegalodonInterface {
.post<MisskeyAPI.Entity.Note>('/api/notes/show', { .post<MisskeyAPI.Entity.Note>('/api/notes/show', {
noteId: id noteId: id
}) })
.then(async res => ({...res, data: await this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())})) .then(async res => ({...res, data: await this.noteWithDetails(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())}))
} }
/** /**
@ -1576,7 +1627,7 @@ export default class Misskey implements MegalodonInterface {
.post<MisskeyAPI.Entity.Note>('/api/notes/show', { .post<MisskeyAPI.Entity.Note>('/api/notes/show', {
noteId: id noteId: id
}) })
.then(async res => ({...res, data: await this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())})) .then(async res => ({...res, data: await this.noteWithDetails(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())}))
} }
// ====================================== // ======================================
@ -1662,7 +1713,7 @@ export default class Misskey implements MegalodonInterface {
noteId: status_id noteId: status_id
}) })
.then(async res => { .then(async res => {
const note = await this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache()) const note = await this.noteWithDetails(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())
return {...res, data: note.poll} return {...res, data: note.poll}
}) })
if (!res.data) { if (!res.data) {
@ -1767,7 +1818,7 @@ export default class Misskey implements MegalodonInterface {
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/global-timeline', params) .post<Array<MisskeyAPI.Entity.Note>>('/api/notes/global-timeline', params)
.then(async res => ({ .then(async res => ({
...res, ...res,
data: await Promise.all(res.data.map(n => this.noteWithMentions(n, this.baseUrlToHost(this.baseUrl), accountCache))) data: await Promise.all(res.data.map(n => this.noteWithDetails(n, this.baseUrlToHost(this.baseUrl), accountCache)))
})) }))
} }
@ -1825,7 +1876,7 @@ export default class Misskey implements MegalodonInterface {
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/local-timeline', params) .post<Array<MisskeyAPI.Entity.Note>>('/api/notes/local-timeline', params)
.then(async res => ({ .then(async res => ({
...res, ...res,
data: await Promise.all(res.data.map(n => this.noteWithMentions(n, this.baseUrlToHost(this.baseUrl), accountCache))) data: await Promise.all(res.data.map(n => this.noteWithDetails(n, this.baseUrlToHost(this.baseUrl), accountCache)))
})) }))
} }
@ -1889,7 +1940,7 @@ export default class Misskey implements MegalodonInterface {
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/search-by-tag', params) .post<Array<MisskeyAPI.Entity.Note>>('/api/notes/search-by-tag', params)
.then(async res => ({ .then(async res => ({
...res, ...res,
data: await Promise.all(res.data.map(n => this.noteWithMentions(n, this.baseUrlToHost(this.baseUrl), accountCache))) data: await Promise.all(res.data.map(n => this.noteWithDetails(n, this.baseUrlToHost(this.baseUrl), accountCache)))
})) }))
} }
@ -1944,7 +1995,7 @@ export default class Misskey implements MegalodonInterface {
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/timeline', params) .post<Array<MisskeyAPI.Entity.Note>>('/api/notes/timeline', params)
.then(async res => ({ .then(async res => ({
...res, ...res,
data: await Promise.all(res.data.map(n => this.noteWithMentions(n, this.baseUrlToHost(this.baseUrl), accountCache))) data: await Promise.all(res.data.map(n => this.noteWithDetails(n, this.baseUrlToHost(this.baseUrl), accountCache)))
})) }))
} }
@ -2000,7 +2051,7 @@ export default class Misskey implements MegalodonInterface {
} }
return this.client return this.client
.post<Array<MisskeyAPI.Entity.Note>>('/api/notes/user-list-timeline', params) .post<Array<MisskeyAPI.Entity.Note>>('/api/notes/user-list-timeline', params)
.then(async res => ({ ...res, data: await Promise.all(res.data.map(n => this.noteWithMentions(n, this.baseUrlToHost(this.baseUrl), accountCache))) })) .then(async res => ({ ...res, data: await Promise.all(res.data.map(n => this.noteWithDetails(n, this.baseUrlToHost(this.baseUrl), accountCache))) }))
} }
// ====================================== // ======================================
@ -2236,9 +2287,15 @@ export default class Misskey implements MegalodonInterface {
limit: 20 limit: 20
}) })
} }
const cache = this.getFreshAccountCache();
return this.client return this.client
.post<Array<MisskeyAPI.Entity.Notification>>('/api/i/notifications', params) .post<Array<MisskeyAPI.Entity.Notification>>('/api/i/notifications', params)
.then(res => ({ ...res, data: res.data.map(n => this.converter.notification(n, this.baseUrlToHost(this.baseUrl))) })) .then(async res => ({
...res,
data: await Promise.all(res.data
.filter(p => p.type != MisskeyNotificationType.FollowRequestAccepted) // these aren't supported on mastodon
.map(n => this.notificationWithDetails(n, this.baseUrlToHost(this.baseUrl), cache)))
}))
} }
public async getNotification(_id: string): Promise<Response<Entity.Notification>> { public async getNotification(_id: string): Promise<Response<Entity.Notification>> {
@ -2439,7 +2496,7 @@ export default class Misskey implements MegalodonInterface {
...res, ...res,
data: { data: {
accounts: [], accounts: [],
statuses: await Promise.all(res.data.map(n => this.noteWithMentions(n, this.baseUrlToHost(this.baseUrl), accountCache))), statuses: await Promise.all(res.data.map(n => this.noteWithDetails(n, this.baseUrlToHost(this.baseUrl), accountCache))),
hashtags: [] hashtags: []
} }
})) }))
@ -2577,7 +2634,7 @@ export default class Misskey implements MegalodonInterface {
.post<MisskeyAPI.Entity.Note>('/api/notes/show', { .post<MisskeyAPI.Entity.Note>('/api/notes/show', {
noteId: id noteId: id
}) })
.then(async res => ({...res, data: await this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())})) .then(async res => ({...res, data: await this.noteWithDetails(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())}))
} }
/** /**
@ -2591,7 +2648,7 @@ export default class Misskey implements MegalodonInterface {
.post<MisskeyAPI.Entity.Note>('/api/notes/show', { .post<MisskeyAPI.Entity.Note>('/api/notes/show', {
noteId: id noteId: id
}) })
.then(async res => ({...res, data: await this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())})) .then(async res => ({...res, data: await this.noteWithDetails(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())}))
} }
public async getEmojiReactions(id: string): Promise<Response<Array<Entity.Reaction>>> { public async getEmojiReactions(id: string): Promise<Response<Array<Entity.Reaction>>> {