Skip to content

Commit

Permalink
Add entity and method for StatusSource
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Feb 15, 2023
1 parent faab18c commit fd16f1f
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 3 deletions.
7 changes: 7 additions & 0 deletions megalodon/src/entities/status_source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Entity {
export type StatusSource = {
id: string
text: string
spoiler_text: string
}
}
1 change: 1 addition & 0 deletions megalodon/src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/// <reference path="./entities/stats.ts" />
/// <reference path="./entities/status.ts" />
/// <reference path="./entities/status_params.ts" />
/// <reference path="./entities/status_source.ts" />
/// <reference path="./entities/tag.ts" />
/// <reference path="./entities/token.ts" />
/// <reference path="./entities/urls.ts" />
Expand Down
10 changes: 9 additions & 1 deletion megalodon/src/mastodon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ export default class Mastodon implements MegalodonInterface {
language?: string
quote_id?: string
}
): Promise<Response<Entity.Status|Entity.ScheduledStatus>> {
): Promise<Response<Entity.Status | Entity.ScheduledStatus>> {
let params = {
status: status
}
Expand Down Expand Up @@ -1294,6 +1294,14 @@ export default class Mastodon implements MegalodonInterface {
})
}

public async getStatusSource(id: string): Promise<Response<Entity.StatusSource>> {
return this.client.get<MastodonAPI.Entity.StatusSource>(`/api/v1/statuses/${id}/source`).then(res => {
return Object.assign(res, {
data: MastodonAPI.Converter.status_source(res.data)
})
})
}

public async getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>> {
return this.client.get<Array<MastodonAPI.Entity.Account>>(`/api/v1/statuses/${id}/reblogged_by`).then(res => {
return Object.assign(res, {
Expand Down
2 changes: 2 additions & 0 deletions megalodon/src/mastodon/api_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions megalodon/src/mastodon/entities/status_source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace MastodonEntity {
export type StatusSource = {
id: string
text: string
spoiler_text: string
}
}
1 change: 1 addition & 0 deletions megalodon/src/mastodon/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/// <reference path="./entities/stats.ts" />
/// <reference path="./entities/status.ts" />
/// <reference path="./entities/status_params.ts" />
/// <reference path="./entities/status_source.ts" />
/// <reference path="./entities/tag.ts" />
/// <reference path="./entities/token.ts" />
/// <reference path="./entities/urls.ts" />
Expand Down
10 changes: 9 additions & 1 deletion megalodon/src/megalodon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ export interface MegalodonInterface {
language?: string
quote_id?: string
}
): Promise<Response<Entity.Status|Entity.ScheduledStatus>>
): Promise<Response<Entity.Status | Entity.ScheduledStatus>>
/**
* GET /api/v1/statuses/:id
*
Expand Down Expand Up @@ -685,6 +685,14 @@ export interface MegalodonInterface {
* @return Context
*/
getStatusContext(id: string, options?: { limit?: number; max_id?: string; since_id?: string }): Promise<Response<Entity.Context>>
/**
* 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<Response<Entity.StatusSource>>
/**
* GET /api/v1/statuses/:id/reblogged_by
*
Expand Down
7 changes: 7 additions & 0 deletions megalodon/src/misskey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,13 @@ export default class Misskey implements MegalodonInterface {
})
}

public async getStatusSource(_id: string): Promise<Response<Entity.StatusSource>> {
return new Promise((_, reject) => {
const err = new NoImplementedError('misskey does not support')
reject(err)
})
}

/**
* POST /api/notes/renotes
*/
Expand Down
10 changes: 9 additions & 1 deletion megalodon/src/pleroma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ export default class Pleroma implements MegalodonInterface {
scheduled_at?: string
language?: string
}
): Promise<Response<Entity.Status|Entity.ScheduledStatus>> {
): Promise<Response<Entity.Status | Entity.ScheduledStatus>> {
let params = {
status: status
}
Expand Down Expand Up @@ -1280,6 +1280,14 @@ export default class Pleroma implements MegalodonInterface {
})
}

public async getStatusSource(id: string): Promise<Response<Entity.StatusSource>> {
return this.client.get<PleromaAPI.Entity.StatusSource>(`/api/v1/statuses/${id}/source`).then(res => {
return Object.assign(res, {
data: PleromaAPI.Converter.status_source(res.data)
})
})
}

public async getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>> {
return this.client.get<Array<PleromaAPI.Entity.Account>>(`/api/v1/statuses/${id}/reblogged_by`).then(res => {
return Object.assign(res, {
Expand Down
2 changes: 2 additions & 0 deletions megalodon/src/pleroma/api_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions megalodon/src/pleroma/entities/status_source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace PleromaEntity {
export type StatusSource = {
id: string
text: string
spoiler_text: string
}
}
1 change: 1 addition & 0 deletions megalodon/src/pleroma/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/// <reference path="./entities/stats.ts" />
/// <reference path="./entities/status.ts" />
/// <reference path="./entities/status_params.ts" />
/// <reference path="./entities/status_source.ts" />
/// <reference path="./entities/tag.ts" />
/// <reference path="./entities/token.ts" />
/// <reference path="./entities/urls.ts" />
Expand Down

0 comments on commit fd16f1f

Please sign in to comment.