From fd16f1f6dc2ef6119937c996531120b15fb37edb Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Thu, 16 Feb 2023 01:24:44 +0900
Subject: [PATCH] Add entity and method for StatusSource
---
megalodon/src/entities/status_source.ts | 7 +++++++
megalodon/src/entity.ts | 1 +
megalodon/src/mastodon.ts | 10 +++++++++-
megalodon/src/mastodon/api_client.ts | 2 ++
megalodon/src/mastodon/entities/status_source.ts | 7 +++++++
megalodon/src/mastodon/entity.ts | 1 +
megalodon/src/megalodon.ts | 10 +++++++++-
megalodon/src/misskey.ts | 7 +++++++
megalodon/src/pleroma.ts | 10 +++++++++-
megalodon/src/pleroma/api_client.ts | 2 ++
megalodon/src/pleroma/entities/status_source.ts | 7 +++++++
megalodon/src/pleroma/entity.ts | 1 +
12 files changed, 62 insertions(+), 3 deletions(-)
create mode 100644 megalodon/src/entities/status_source.ts
create mode 100644 megalodon/src/mastodon/entities/status_source.ts
create mode 100644 megalodon/src/pleroma/entities/status_source.ts
diff --git a/megalodon/src/entities/status_source.ts b/megalodon/src/entities/status_source.ts
new file mode 100644
index 000000000..0de7030ed
--- /dev/null
+++ b/megalodon/src/entities/status_source.ts
@@ -0,0 +1,7 @@
+namespace Entity {
+ export type StatusSource = {
+ id: string
+ text: string
+ spoiler_text: string
+ }
+}
diff --git a/megalodon/src/entity.ts b/megalodon/src/entity.ts
index b66535408..e0b323c06 100644
--- a/megalodon/src/entity.ts
+++ b/megalodon/src/entity.ts
@@ -30,6 +30,7 @@
///
///
///
+///
///
///
///
diff --git a/megalodon/src/mastodon.ts b/megalodon/src/mastodon.ts
index 58f5e7871..f9685561b 100644
--- a/megalodon/src/mastodon.ts
+++ b/megalodon/src/mastodon.ts
@@ -1106,7 +1106,7 @@ export default class Mastodon implements MegalodonInterface {
language?: string
quote_id?: string
}
- ): Promise> {
+ ): Promise> {
let params = {
status: status
}
@@ -1294,6 +1294,14 @@ export default class Mastodon implements MegalodonInterface {
})
}
+ public async getStatusSource(id: string): Promise> {
+ return this.client.get(`/api/v1/statuses/${id}/source`).then(res => {
+ return Object.assign(res, {
+ data: MastodonAPI.Converter.status_source(res.data)
+ })
+ })
+ }
+
public async getStatusRebloggedBy(id: string): Promise>> {
return this.client.get>(`/api/v1/statuses/${id}/reblogged_by`).then(res => {
return Object.assign(res, {
diff --git a/megalodon/src/mastodon/api_client.ts b/megalodon/src/mastodon/api_client.ts
index 6b6062d3f..21bfe3be3 100644
--- a/megalodon/src/mastodon/api_client.ts
+++ b/megalodon/src/mastodon/api_client.ts
@@ -473,6 +473,7 @@ namespace MastodonAPI {
export type Stats = MastodonEntity.Stats
export type Status = MastodonEntity.Status
export type StatusParams = MastodonEntity.StatusParams
+ export type StatusSource = MastodonEntity.StatusSource
export type Tag = MastodonEntity.Tag
export type Token = MastodonEntity.Token
export type URLs = MastodonEntity.URLs
@@ -630,6 +631,7 @@ namespace MastodonAPI {
quote: s.quote !== undefined && s.quote !== null
})
export const status_params = (s: Entity.StatusParams): MegalodonEntity.StatusParams => s
+ export const status_source = (s: Entity.StatusSource): MegalodonEntity.StatusSource => s
export const tag = (t: Entity.Tag): MegalodonEntity.Tag => t
export const token = (t: Entity.Token): MegalodonEntity.Token => t
export const urls = (u: Entity.URLs): MegalodonEntity.URLs => u
diff --git a/megalodon/src/mastodon/entities/status_source.ts b/megalodon/src/mastodon/entities/status_source.ts
new file mode 100644
index 000000000..f8ca42c03
--- /dev/null
+++ b/megalodon/src/mastodon/entities/status_source.ts
@@ -0,0 +1,7 @@
+namespace MastodonEntity {
+ export type StatusSource = {
+ id: string
+ text: string
+ spoiler_text: string
+ }
+}
diff --git a/megalodon/src/mastodon/entity.ts b/megalodon/src/mastodon/entity.ts
index ef8baf8fc..199872a3d 100644
--- a/megalodon/src/mastodon/entity.ts
+++ b/megalodon/src/mastodon/entity.ts
@@ -29,6 +29,7 @@
///
///
///
+///
///
///
///
diff --git a/megalodon/src/megalodon.ts b/megalodon/src/megalodon.ts
index e23524be2..a18edf663 100644
--- a/megalodon/src/megalodon.ts
+++ b/megalodon/src/megalodon.ts
@@ -646,7 +646,7 @@ export interface MegalodonInterface {
language?: string
quote_id?: string
}
- ): Promise>
+ ): Promise>
/**
* GET /api/v1/statuses/:id
*
@@ -685,6 +685,14 @@ export interface MegalodonInterface {
* @return Context
*/
getStatusContext(id: string, options?: { limit?: number; max_id?: string; since_id?: string }): Promise>
+ /**
+ * GET /api/v1/statuses/:id/source
+ *
+ * Obtain the source properties for a status so that it can be edited.
+ * @param id The target status id.
+ * @return StatusSource
+ */
+ getStatusSource(id: string): Promise>
/**
* GET /api/v1/statuses/:id/reblogged_by
*
diff --git a/megalodon/src/misskey.ts b/megalodon/src/misskey.ts
index 187c0f534..17d63651e 100644
--- a/megalodon/src/misskey.ts
+++ b/megalodon/src/misskey.ts
@@ -1149,6 +1149,13 @@ export default class Misskey implements MegalodonInterface {
})
}
+ public async getStatusSource(_id: string): Promise> {
+ return new Promise((_, reject) => {
+ const err = new NoImplementedError('misskey does not support')
+ reject(err)
+ })
+ }
+
/**
* POST /api/notes/renotes
*/
diff --git a/megalodon/src/pleroma.ts b/megalodon/src/pleroma.ts
index 948717776..cc3940168 100644
--- a/megalodon/src/pleroma.ts
+++ b/megalodon/src/pleroma.ts
@@ -1097,7 +1097,7 @@ export default class Pleroma implements MegalodonInterface {
scheduled_at?: string
language?: string
}
- ): Promise> {
+ ): Promise> {
let params = {
status: status
}
@@ -1280,6 +1280,14 @@ export default class Pleroma implements MegalodonInterface {
})
}
+ public async getStatusSource(id: string): Promise> {
+ return this.client.get(`/api/v1/statuses/${id}/source`).then(res => {
+ return Object.assign(res, {
+ data: PleromaAPI.Converter.status_source(res.data)
+ })
+ })
+ }
+
public async getStatusRebloggedBy(id: string): Promise>> {
return this.client.get>(`/api/v1/statuses/${id}/reblogged_by`).then(res => {
return Object.assign(res, {
diff --git a/megalodon/src/pleroma/api_client.ts b/megalodon/src/pleroma/api_client.ts
index e470161d5..1d917e0f1 100644
--- a/megalodon/src/pleroma/api_client.ts
+++ b/megalodon/src/pleroma/api_client.ts
@@ -45,6 +45,7 @@ namespace PleromaAPI {
export type Stats = PleromaEntity.Stats
export type Status = PleromaEntity.Status
export type StatusParams = PleromaEntity.StatusParams
+ export type StatusSource = PleromaEntity.StatusSource
export type Tag = PleromaEntity.Tag
export type Token = PleromaEntity.Token
export type URLs = PleromaEntity.URLs
@@ -237,6 +238,7 @@ namespace PleromaAPI {
quote: s.reblog !== null && s.reblog.content !== s.content
})
export const status_params = (s: Entity.StatusParams): MegalodonEntity.StatusParams => s
+ export const status_source = (s: Entity.StatusSource): MegalodonEntity.StatusSource => s
export const tag = (t: Entity.Tag): MegalodonEntity.Tag => t
export const token = (t: Entity.Token): MegalodonEntity.Token => t
export const urls = (u: Entity.URLs): MegalodonEntity.URLs => u
diff --git a/megalodon/src/pleroma/entities/status_source.ts b/megalodon/src/pleroma/entities/status_source.ts
new file mode 100644
index 000000000..57d2bea78
--- /dev/null
+++ b/megalodon/src/pleroma/entities/status_source.ts
@@ -0,0 +1,7 @@
+namespace PleromaEntity {
+ export type StatusSource = {
+ id: string
+ text: string
+ spoiler_text: string
+ }
+}
diff --git a/megalodon/src/pleroma/entity.ts b/megalodon/src/pleroma/entity.ts
index a2567b3b1..285dd528e 100644
--- a/megalodon/src/pleroma/entity.ts
+++ b/megalodon/src/pleroma/entity.ts
@@ -30,6 +30,7 @@
///
///
///
+///
///
///
///