refs #1472 Add APIs regarding tags
This commit is contained in:
parent
0dfc9228eb
commit
eb61ce0935
|
@ -5,5 +5,6 @@ namespace Entity {
|
|||
name: string
|
||||
url: string
|
||||
history: Array<History> | null
|
||||
following: boolean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1063,6 +1063,33 @@ export default class Mastodon implements MegalodonInterface {
|
|||
}
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/tags
|
||||
// ======================================
|
||||
public async getTag(id: string): Promise<Response<Entity.Tag>> {
|
||||
return this.client.get<MastodonAPI.Entity.Tag>(`/api/v1/tags/${id}`).then(res => {
|
||||
return Object.assign(res, {
|
||||
data: MastodonAPI.Converter.tag(res.data)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
public async followTag(id: string): Promise<Response<Entity.Tag>> {
|
||||
return this.client.post<MastodonAPI.Entity.Tag>(`/api/v1/tags/${id}/follow`).then(res => {
|
||||
return Object.assign(res, {
|
||||
data: MastodonAPI.Converter.tag(res.data)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
public async unfollowTag(id: string): Promise<Response<Entity.Tag>> {
|
||||
return this.client.post<MastodonAPI.Entity.Tag>(`/api/v1/tags/${id}/unfollow`).then(res => {
|
||||
return Object.assign(res, {
|
||||
data: MastodonAPI.Converter.tag(res.data)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// statuses
|
||||
// ======================================
|
||||
|
|
|
@ -5,5 +5,6 @@ namespace MastodonEntity {
|
|||
name: string
|
||||
url: string
|
||||
history: Array<History> | null
|
||||
following: boolean
|
||||
}
|
||||
}
|
||||
|
|
|
@ -592,6 +592,30 @@ export interface MegalodonInterface {
|
|||
*/
|
||||
getSuggestions(limit?: number): Promise<Response<Array<Entity.Account>>>
|
||||
// ======================================
|
||||
// accounts/tag
|
||||
// ======================================
|
||||
/**
|
||||
* GET /api/v1/tags/:id
|
||||
*
|
||||
* @param id Target hashtag id.
|
||||
* @return Tag
|
||||
*/
|
||||
getTag(id: string): Promise<Response<Entity.Tag>>
|
||||
/**
|
||||
* POST /api/v1/tags/:id/follow
|
||||
*
|
||||
* @param id Target hashtag id.
|
||||
* @return Tag
|
||||
*/
|
||||
followTag(id: string): Promise<Response<Entity.Tag>>
|
||||
/**
|
||||
* POST /api/v1/tags/:id/unfollow
|
||||
*
|
||||
* @param id Target hashtag id.
|
||||
* @return Tag
|
||||
*/
|
||||
unfollowTag(id: string): Promise<Response<Entity.Tag>>
|
||||
// ======================================
|
||||
// statuses
|
||||
// ======================================
|
||||
/**
|
||||
|
|
|
@ -978,6 +978,30 @@ export default class Misskey implements MegalodonInterface {
|
|||
.then(res => ({ ...res, data: res.data.map(u => MisskeyAPI.Converter.userDetail(u)) }))
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/tags
|
||||
// ======================================
|
||||
public async getTag(_id: string): Promise<Response<Entity.Tag>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('misskey does not support')
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
|
||||
public async followTag(_id: string): Promise<Response<Entity.Tag>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('misskey does not support')
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
|
||||
public async unfollowTag(_id: string): Promise<Response<Entity.Tag>> {
|
||||
return new Promise((_, reject) => {
|
||||
const err = new NoImplementedError('misskey does not support')
|
||||
reject(err)
|
||||
})
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// statuses
|
||||
// ======================================
|
||||
|
@ -2000,7 +2024,7 @@ export default class Misskey implements MegalodonInterface {
|
|||
data: {
|
||||
accounts: [],
|
||||
statuses: [],
|
||||
hashtags: res.data.map(h => ({ name: h, url: h, history: null }))
|
||||
hashtags: res.data.map(h => ({ name: h, url: h, history: null, following: false }))
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -403,7 +403,8 @@ namespace MisskeyAPI {
|
|||
return {
|
||||
name: h.tag,
|
||||
url: h.tag,
|
||||
history: null
|
||||
history: null,
|
||||
following: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1055,6 +1055,33 @@ export default class Pleroma implements MegalodonInterface {
|
|||
}
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// accounts/tags
|
||||
// ======================================
|
||||
public async getTag(id: string): Promise<Response<Entity.Tag>> {
|
||||
return this.client.get<PleromaAPI.Entity.Tag>(`/api/v1/tags/${id}`).then(res => {
|
||||
return Object.assign(res, {
|
||||
data: PleromaAPI.Converter.tag(res.data)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
public async followTag(id: string): Promise<Response<Entity.Tag>> {
|
||||
return this.client.post<PleromaAPI.Entity.Tag>(`/api/v1/tags/${id}/follow`).then(res => {
|
||||
return Object.assign(res, {
|
||||
data: PleromaAPI.Converter.tag(res.data)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
public async unfollowTag(id: string): Promise<Response<Entity.Tag>> {
|
||||
return this.client.post<PleromaAPI.Entity.Tag>(`/api/v1/tags/${id}/unfollow`).then(res => {
|
||||
return Object.assign(res, {
|
||||
data: PleromaAPI.Converter.tag(res.data)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// ======================================
|
||||
// statuses
|
||||
// ======================================
|
||||
|
|
|
@ -5,5 +5,6 @@ namespace PleromaEntity {
|
|||
name: string
|
||||
url: string
|
||||
history: Array<History> | null
|
||||
following: boolean
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue