[mastodon-client] return actual status bookmark state
This commit is contained in:
parent
c1e43407d5
commit
02ddbe2363
@ -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;
|
||||
|
@ -41,6 +41,7 @@ namespace MisskeyAPI {
|
||||
export type UserKey = MisskeyEntity.UserKey
|
||||
export type Session = MisskeyEntity.Session
|
||||
export type Stats = MisskeyEntity.Stats
|
||||
export type State = MisskeyEntity.State
|
||||
export type APIEmoji = { emojis: Emoji[] }
|
||||
}
|
||||
|
||||
|
7
packages/megalodon/src/misskey/entities/state.ts
Normal file
7
packages/megalodon/src/misskey/entities/state.ts
Normal file
@ -0,0 +1,7 @@
|
||||
namespace MisskeyEntity {
|
||||
export type State = {
|
||||
isFavorited: boolean
|
||||
isMutedThread: boolean
|
||||
isWatching: boolean
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user