[mastodon-client] return actual status bookmark state

This commit is contained in:
Laura Hausmann 2023-07-10 00:05:52 +02:00
parent c1e43407d5
commit 02ddbe2363
Signed by: zotan
GPG key ID: D044E84C5BE01605
3 changed files with 17 additions and 1 deletions

View file

@ -1243,9 +1243,17 @@ export default class Misskey implements MegalodonInterface {
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);
status.bookmarked = await this.isStatusBookmarked(n.id);
return this.addMentionsToStatus(status, cache);
}
public async isStatusBookmarked(id: string) : Promise<boolean> {
return this.client
.post<MisskeyAPI.Entity.State>('/api/notes/state', {
noteId: id
}).then(p => p.data.isFavorited ?? false);
}
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;

View file

@ -40,7 +40,8 @@ namespace MisskeyAPI {
export type GetAll = MisskeyEntity.GetAll
export type UserKey = MisskeyEntity.UserKey
export type Session = MisskeyEntity.Session
export type Stats = MisskeyEntity.Stats
export type Stats = MisskeyEntity.Stats
export type State = MisskeyEntity.State
export type APIEmoji = { emojis: Emoji[] }
}

View file

@ -0,0 +1,7 @@
namespace MisskeyEntity {
export type State = {
isFavorited: boolean
isMutedThread: boolean
isWatching: boolean
}
}