From 29099e463580b33d1cbde56fcc2e6198544c8c5e Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 3 Sep 2023 01:32:39 +0200 Subject: [PATCH] [mastodon-client] Proper note deletion response, resolves #159 --- packages/megalodon/src/entities/status.ts | 2 +- packages/megalodon/src/misskey.ts | 8 +++++--- packages/megalodon/src/misskey/api_client.ts | 2 +- packages/megalodon/test/unit/misskey/api_client.spec.ts | 4 ++-- packages/megalodon/test/unit/parser.spec.ts | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/megalodon/src/entities/status.ts b/packages/megalodon/src/entities/status.ts index f27f728b5..df458c7a6 100644 --- a/packages/megalodon/src/entities/status.ts +++ b/packages/megalodon/src/entities/status.ts @@ -18,7 +18,7 @@ namespace Entity { in_reply_to_account_id: string | null; reblog: Status | null; content: string; - plain_content: string | null; + text: string | null; created_at: string; emojis: Emoji[]; replies_count: number; diff --git a/packages/megalodon/src/misskey.ts b/packages/megalodon/src/misskey.ts index 1d99fe6e8..45839a134 100644 --- a/packages/megalodon/src/misskey.ts +++ b/packages/megalodon/src/misskey.ts @@ -1518,7 +1518,7 @@ export default class Misskey implements MegalodonInterface { const origin = idx < 0 ? null : status.account.acct.substring(idx + 1); status.mentions = ( - await this.getMentions(status.plain_content!, origin, cache) + await this.getMentions(status.text!, origin, cache) ).filter((p) => p != null); for (const m of status.mentions.filter( (value, index, array) => array.indexOf(value) === index, @@ -1699,10 +1699,12 @@ export default class Misskey implements MegalodonInterface { /** * POST /api/notes/delete */ - public async deleteStatus(id: string): Promise> { - return this.client.post<{}>("/api/notes/delete", { + public async deleteStatus(id: string): Promise> { + const status = await this.getStatus(id); + await this.client.post<{}>("/api/notes/delete", { noteId: id, }); + return status; } /** diff --git a/packages/megalodon/src/misskey/api_client.ts b/packages/megalodon/src/misskey/api_client.ts index 47932cbf1..a08968448 100644 --- a/packages/megalodon/src/misskey/api_client.ts +++ b/packages/megalodon/src/misskey/api_client.ts @@ -319,7 +319,7 @@ namespace MisskeyAPI { in_reply_to_account_id: n.reply?.userId ?? null, reblog: n.renote ? this.note(n.renote, host) : null, content: n.text ? this.escapeMFM(n.text) : "", - plain_content: n.text ? n.text : null, + text: n.text ? n.text : null, created_at: n.createdAt, // Remove reaction emojis with names containing @ from the emojis list. emojis: n.emojis diff --git a/packages/megalodon/test/unit/misskey/api_client.spec.ts b/packages/megalodon/test/unit/misskey/api_client.spec.ts index 7cf33b983..23740fa91 100644 --- a/packages/megalodon/test/unit/misskey/api_client.spec.ts +++ b/packages/megalodon/test/unit/misskey/api_client.spec.ts @@ -201,7 +201,7 @@ describe('api_client', () => { renoteId: null } const megalodonStatus = converter.note(note, user.host || 'misskey.io') - expect(megalodonStatus.plain_content).toEqual(plainContent) + expect(megalodonStatus.text).toEqual(plainContent) expect(megalodonStatus.content).toEqual(content) }) it('html tags should be escaped', () => { @@ -225,7 +225,7 @@ describe('api_client', () => { renoteId: null } const megalodonStatus = converter.note(note, user.host || 'misskey.io') - expect(megalodonStatus.plain_content).toEqual(plainContent) + expect(megalodonStatus.text).toEqual(plainContent) expect(megalodonStatus.content).toEqual(content) }) }) diff --git a/packages/megalodon/test/unit/parser.spec.ts b/packages/megalodon/test/unit/parser.spec.ts index 5174a647c..c748aae70 100644 --- a/packages/megalodon/test/unit/parser.spec.ts +++ b/packages/megalodon/test/unit/parser.spec.ts @@ -32,7 +32,7 @@ const status: Entity.Status = { in_reply_to_account_id: null, reblog: null, content: 'hoge', - plain_content: 'hoge', + text: 'hoge', created_at: '2019-03-26T21:40:32', emojis: [], replies_count: 0,