[mastodon-client] Proper note deletion response, resolves #159

This commit is contained in:
Laura Hausmann 2023-09-03 01:32:39 +02:00
parent 74941f35e4
commit 29099e4635
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605
5 changed files with 10 additions and 8 deletions

View File

@ -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;

View File

@ -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<Response<{}>> {
return this.client.post<{}>("/api/notes/delete", {
public async deleteStatus(id: string): Promise<Response<Entity.Status>> {
const status = await this.getStatus(id);
await this.client.post<{}>("/api/notes/delete", {
noteId: id,
});
return status;
}
/**

View File

@ -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

View File

@ -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)
})
})

View File

@ -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,